Search in sources :

Example 1 with PeakResultsReader

use of gdsc.smlm.results.PeakResultsReader in project GDSC-SMLM by aherbert.

the class ResultsManager method loadInputResults.

/**
	 * Load the results from the named input option
	 * 
	 * @param inputOption
	 * @param checkCalibration
	 *            Set to true to ensure the results have a valid calibration
	 * @return
	 */
public static MemoryPeakResults loadInputResults(String inputOption, boolean checkCalibration) {
    MemoryPeakResults results = null;
    PeakResultsReader reader = null;
    if (inputOption.equals(INPUT_NONE)) {
    } else if (inputOption.equals(INPUT_FILE)) {
        IJ.showStatus("Reading results file ...");
        reader = new PeakResultsReader(inputFilename);
        IJ.showStatus("Reading " + reader.getFormat() + " results file ...");
        ResultOption[] options = reader.getOptions();
        if (options != null)
            collectOptions(reader, options);
        reader.setTracker(new IJTrackProgress());
        results = reader.getResults();
        reader.getTracker().progress(1.0);
        if (results != null && results.size() > 0) {
            // If the name contains a .tif suffix then create an image source
            if (results.getName() != null && results.getName().contains(".tif") && results.getSource() == null) {
                int index = results.getName().indexOf(".tif");
                results.setSource(new IJImageSource(results.getName().substring(0, index)));
            }
        }
    } else {
        results = loadMemoryResults(inputOption);
    }
    if (results != null && results.size() > 0 && checkCalibration) {
        if (!checkCalibration(results, reader))
            results = null;
    }
    IJ.showStatus("");
    return results;
}
Also used : IJImageSource(gdsc.smlm.ij.IJImageSource) IJTrackProgress(gdsc.core.ij.IJTrackProgress) MemoryPeakResults(gdsc.smlm.results.MemoryPeakResults) PeakResultsReader(gdsc.smlm.results.PeakResultsReader)

Example 2 with PeakResultsReader

use of gdsc.smlm.results.PeakResultsReader in project GDSC-SMLM by aherbert.

the class CreateData method getSimulationResults.

private MemoryPeakResults getSimulationResults() {
    if (benchmarkAuto) {
        // Load directly from a results file. This is mainly to be used to load simulations 
        // saved to memory then saved to file. This is because the z-depth must be in the 
        // error field of the results.
        PeakResultsReader r = new PeakResultsReader(benchmarkFile);
        MemoryPeakResults results = r.getResults();
        if (results != null) {
            ResultsManager.checkCalibration(results);
            return results;
        }
    }
    // Load using a universal text file
    LocalisationList localisations = LoadLocalisations.loadLocalisations(benchmarkFile);
    if (localisations.isEmpty())
        return null;
    return localisations.toPeakResults();
}
Also used : LocalisationList(gdsc.smlm.ij.plugins.LoadLocalisations.LocalisationList) MemoryPeakResults(gdsc.smlm.results.MemoryPeakResults) PeakResultsReader(gdsc.smlm.results.PeakResultsReader)

Example 3 with PeakResultsReader

use of gdsc.smlm.results.PeakResultsReader in project GDSC-SMLM by aherbert.

the class FilterAnalysis method readResults.

private List<MemoryPeakResults> readResults() {
    if (resultsList != null && inputDirectory.equals(lastInputDirectory)) {
        GenericDialog gd = new GenericDialog(TITLE);
        gd.addMessage("Re-use results from the same directory (no to refresh)?");
        gd.enableYesNoCancel();
        gd.hideCancelButton();
        gd.showDialog();
        if (gd.wasOKed())
            return resultsList;
    }
    List<MemoryPeakResults> resultsList = new LinkedList<MemoryPeakResults>();
    File[] fileList = (new File(inputDirectory)).listFiles(new FilenameFilter() {

        public boolean accept(File dir, String name) {
            return (name.endsWith(".xls") || name.endsWith(".csv") || name.endsWith(".bin"));
        }
    });
    if (fileList != null) {
        // Exclude directories
        for (int i = 0; i < fileList.length; i++) {
            if (fileList[i].isFile()) {
                IJ.showStatus(String.format("Reading results ... %d/%d", i + 1, fileList.length));
                IJ.showProgress(i, fileList.length);
                PeakResultsReader reader = new PeakResultsReader(fileList[i].getPath());
                MemoryPeakResults results = reader.getResults();
                if (results != null && results.size() > 0) {
                    resultsList.add(results);
                }
            }
        }
    }
    IJ.showStatus("");
    IJ.showProgress(1);
    lastInputDirectory = inputDirectory;
    return resultsList;
}
Also used : FilenameFilter(java.io.FilenameFilter) GenericDialog(ij.gui.GenericDialog) MemoryPeakResults(gdsc.smlm.results.MemoryPeakResults) PeakResultsReader(gdsc.smlm.results.PeakResultsReader) File(java.io.File) LinkedList(java.util.LinkedList)

Example 4 with PeakResultsReader

use of gdsc.smlm.results.PeakResultsReader in project GDSC-SMLM by aherbert.

the class ShowResultsHeader method run.

/*
	 * (non-Javadoc)
	 * 
	 * @see ij.plugin.PlugIn#run(java.lang.String)
	 */
public void run(String arg) {
    SMLMUsageTracker.recordPlugin(this.getClass(), arg);
    GenericDialog gd = new GenericDialog(TITLE);
    gd.addMessage("Show the results header in the ImageJ log.\n(Double-click the string field to open a file chooser.)");
    gd.addStringField("Filename", inputFilename, 30);
    gd.addCheckbox("Raw", raw);
    textConfigFile = (TextField) gd.getStringFields().get(0);
    textConfigFile.addMouseListener(this);
    gd.showDialog();
    if (gd.wasCanceled())
        return;
    inputFilename = gd.getNextString();
    raw = gd.getNextBoolean();
    Prefs.set(Constants.inputFilename, inputFilename);
    PeakResultsReader reader = new PeakResultsReader(inputFilename);
    String header = reader.getHeader();
    if (header == null) {
        IJ.error(TITLE, "No header found in file: " + inputFilename);
        return;
    }
    if (raw) {
        // The ImageJ TextPanel class correctly stores lines with tab characters.
        // However when it is drawn in ij.text.TextCanvas using java.awt.Graphics.drawChars(...) 
        // the instance of this class is sun.java2d.SunGraphics2D which omits '\t' chars.
        // This may be a problem specific to the Linux JRE.
        // TODO - Find out if this is a Linux specific bug.
        // Output the raw text. This preserves the tabs in the Cut/Copy commands.
        IJ.log(header);
        //IJ.log(header.replace("\t", "    "));
        return;
    }
    // Output what information we can extract
    boolean found = false;
    found |= show("Format", reader.getFormat().toString());
    found |= show("Name", reader.getName());
    found |= show("Bounds", reader.getBounds());
    found |= show("Calibration", reader.getCalibration());
    found |= show("Configuration", reader.getConfiguration());
    if (!found)
        IJ.error(TITLE, "No header information found in file: " + inputFilename);
}
Also used : GenericDialog(ij.gui.GenericDialog) PeakResultsReader(gdsc.smlm.results.PeakResultsReader)

Aggregations

PeakResultsReader (gdsc.smlm.results.PeakResultsReader)4 MemoryPeakResults (gdsc.smlm.results.MemoryPeakResults)3 GenericDialog (ij.gui.GenericDialog)2 IJTrackProgress (gdsc.core.ij.IJTrackProgress)1 IJImageSource (gdsc.smlm.ij.IJImageSource)1 LocalisationList (gdsc.smlm.ij.plugins.LoadLocalisations.LocalisationList)1 File (java.io.File)1 FilenameFilter (java.io.FilenameFilter)1 LinkedList (java.util.LinkedList)1