Search in sources :

Example 1 with PeakResultsList

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

the class PulseActivationAnalysis method createOutput.

private PeakResultsList createOutput(int c) {
    PeakResultsList output = new PeakResultsList();
    output.copySettings(results);
    if (channels > 1)
        output.setName(results.getName() + " " + TITLE + " C" + c);
    else
        output.setName(results.getName() + " " + TITLE);
    // Store the set in memory
    MemoryPeakResults memoryResults = new MemoryPeakResults(this.results.size());
    output.addOutput(memoryResults);
    MemoryPeakResults.addResults(memoryResults);
    // Draw the super-resolution image
    Rectangle bounds = results.getBounds(true);
    addImageResults(output, results.getName(), bounds, results.getNmPerPixel(), results.getGain());
    output.begin();
    return output;
}
Also used : PeakResultsList(gdsc.smlm.results.PeakResultsList) Rectangle(java.awt.Rectangle) MemoryPeakResults(gdsc.smlm.results.MemoryPeakResults)

Example 2 with PeakResultsList

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

the class ResultsManager method run.

/*
	 * (non-Javadoc)
	 * 
	 * @see ij.plugin.PlugIn#run(java.lang.String)
	 */
public void run(String arg) {
    SMLMUsageTracker.recordPlugin(this.getClass(), arg);
    if (arg != null && arg.startsWith("clear")) {
        Collection<MemoryPeakResults> allResults;
        boolean removeAll = false;
        if (arg.contains("multi")) {
            MultiDialog md = new MultiDialog(TITLE, new MultiDialog.MemoryResultsItems());
            md.addSelected(selected);
            md.showDialog();
            if (md.wasCanceled())
                return;
            selected = md.getSelectedResults();
            if (selected.isEmpty())
                return;
            allResults = new ArrayList<MemoryPeakResults>(selected.size());
            for (String name : selected) {
                MemoryPeakResults r = MemoryPeakResults.getResults(name);
                if (r != null)
                    allResults.add(r);
            }
        } else {
            removeAll = true;
            allResults = MemoryPeakResults.getAllResults();
        }
        if (allResults.isEmpty())
            return;
        long memorySize = 0;
        int size = 0;
        for (MemoryPeakResults results : allResults) {
            memorySize += MemoryPeakResults.estimateMemorySize(results.getResults());
            size += results.size();
        }
        String memory = MemoryPeakResults.memorySizeString(memorySize);
        String count = Utils.pleural(size, "result");
        String sets = Utils.pleural(allResults.size(), "set");
        GenericDialog gd = new GenericDialog(TITLE);
        gd.addMessage(String.format("Do you want to remove %s from memory (%s, %s)?", count, sets, memory));
        gd.enableYesNoCancel();
        gd.showDialog();
        if (!gd.wasOKed())
            return;
        if (removeAll)
            MemoryPeakResults.clearMemory();
        else {
            for (MemoryPeakResults results : allResults) MemoryPeakResults.removeResults(results.getName());
        }
        SummariseResults.clearSummaryTable();
        IJ.log(String.format("Cleared %s (%s, %s)", count, sets, memory));
        return;
    }
    if (!showDialog())
        return;
    MemoryPeakResults results = loadResults(inputOption);
    if (results == null || results.size() == 0) {
        IJ.error(TITLE, "No results could be loaded");
        IJ.showStatus("");
        return;
    }
    results = cropToRoi(results);
    if (results.size() == 0) {
        IJ.error(TITLE, "No results within the crop region");
        return;
    }
    if (resultsSettings.resultsInMemory && fileInput)
        MemoryPeakResults.addResults(results);
    IJ.showStatus("Processing outputs ...");
    Rectangle bounds = results.getBounds(true);
    boolean showDeviations = resultsSettings.showDeviations && canShowDeviations(results);
    boolean showEndFrame = canShowEndFrame(results);
    boolean showId = canShowId(results);
    // Display the configured output
    PeakResultsList outputList = new PeakResultsList();
    outputList.copySettings(results);
    //String title = results.getSource();
    //if (title == null || title.length() == 0)
    //	output.setSource(TITLE);
    addTableResults(results, outputList, showDeviations, showEndFrame);
    addImageResults(outputList, results.getName(), bounds, results.getNmPerPixel(), results.getGain());
    addFileResults(outputList, showDeviations, showEndFrame, showId);
    // Reduce to single object for speed
    PeakResults output = (outputList.numberOfOutputs() == 1) ? outputList.toArray()[0] : outputList;
    output.begin();
    // Process in batches to provide progress
    List<PeakResult> list = results.getResults();
    int progress = 0;
    int totalProgress = list.size();
    int stepProgress = Utils.getProgressInterval(totalProgress);
    TurboList<PeakResult> batch = new TurboList<PeakResult>(stepProgress);
    for (PeakResult result : list) {
        if (progress % stepProgress == 0) {
            IJ.showProgress(progress, totalProgress);
        }
        progress++;
        batch.addf(result);
        if (batch.size() == stepProgress) {
            output.addAll(batch);
            batch.clearf();
            if (isInterrupted())
                break;
        }
    }
    IJ.showProgress(1);
    output.end();
    IJ.showStatus(String.format("Processed %d result%s", results.size(), (results.size() > 1) ? "s" : ""));
}
Also used : TurboList(gdsc.core.utils.TurboList) Rectangle(java.awt.Rectangle) PeakResult(gdsc.smlm.results.PeakResult) ExtendedPeakResult(gdsc.smlm.results.ExtendedPeakResult) PeakResultsList(gdsc.smlm.results.PeakResultsList) PeakResults(gdsc.smlm.results.PeakResults) IJImagePeakResults(gdsc.smlm.ij.results.IJImagePeakResults) IJTablePeakResults(gdsc.smlm.ij.results.IJTablePeakResults) MemoryPeakResults(gdsc.smlm.results.MemoryPeakResults) BinaryFilePeakResults(gdsc.smlm.results.BinaryFilePeakResults) MALKFilePeakResults(gdsc.smlm.results.MALKFilePeakResults) FilePeakResults(gdsc.smlm.results.FilePeakResults) ExtendedGenericDialog(ij.gui.ExtendedGenericDialog) GenericDialog(ij.gui.GenericDialog) MemoryPeakResults(gdsc.smlm.results.MemoryPeakResults)

Example 3 with PeakResultsList

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

the class PeakFit method initialiseImage.

/**
	 * Initialise a new image.
	 * <p>
	 * Does not set-up for fitting. This can be done using a subsequent call to {@link #initialiseFitting()}.
	 * <p>
	 * This mechanism allows additional result outputs to be added after initialisation using
	 * {@link #addPeakResults(PeakResults)}.
	 * 
	 * @param imageSource
	 *            The image source
	 * @param bounds
	 *            The region to process from the image
	 * @param ignoreBoundsForNoise
	 *            Set to true if the bounds should be ignored when computing the noise estimate for each frame
	 * @return
	 * 		True if the image was valid and the initialisation was successful
	 */
public boolean initialiseImage(ImageSource imageSource, Rectangle bounds, boolean ignoreBoundsForNoise) {
    // Initialise for image processing
    if (!setSource(imageSource))
        return false;
    this.ignoreBoundsForNoise = ignoreBoundsForNoise;
    if (bounds == null) {
        bounds = new Rectangle(0, 0, source.getWidth(), source.getHeight());
        // No region so no need to ignore the bounds.
        this.ignoreBoundsForNoise = false;
    }
    this.bounds = bounds;
    results = new PeakResultsList();
    time = 0;
    return true;
}
Also used : PeakResultsList(gdsc.smlm.results.PeakResultsList) Rectangle(java.awt.Rectangle)

Aggregations

PeakResultsList (gdsc.smlm.results.PeakResultsList)3 Rectangle (java.awt.Rectangle)3 MemoryPeakResults (gdsc.smlm.results.MemoryPeakResults)2 TurboList (gdsc.core.utils.TurboList)1 IJImagePeakResults (gdsc.smlm.ij.results.IJImagePeakResults)1 IJTablePeakResults (gdsc.smlm.ij.results.IJTablePeakResults)1 BinaryFilePeakResults (gdsc.smlm.results.BinaryFilePeakResults)1 ExtendedPeakResult (gdsc.smlm.results.ExtendedPeakResult)1 FilePeakResults (gdsc.smlm.results.FilePeakResults)1 MALKFilePeakResults (gdsc.smlm.results.MALKFilePeakResults)1 PeakResult (gdsc.smlm.results.PeakResult)1 PeakResults (gdsc.smlm.results.PeakResults)1 ExtendedGenericDialog (ij.gui.ExtendedGenericDialog)1 GenericDialog (ij.gui.GenericDialog)1