Search in sources :

Example 41 with MemoryPeakResults

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

the class PCPALMMolecules method cropToRoi.

private MemoryPeakResults cropToRoi(MemoryPeakResults results) {
    Rectangle bounds = results.getBounds(true);
    area = (bounds.width * bounds.height * results.getNmPerPixel() * results.getNmPerPixel()) / 1e6;
    if (roiBounds == null) {
        return results;
    }
    // Adjust bounds relative to input results image
    double xscale = (double) roiImageWidth / bounds.width;
    double yscale = (double) roiImageHeight / bounds.height;
    roiBounds.x /= xscale;
    roiBounds.width /= xscale;
    roiBounds.y /= yscale;
    roiBounds.height /= yscale;
    float minX = (int) (roiBounds.x);
    float maxX = (int) Math.ceil(roiBounds.x + roiBounds.width);
    float minY = (int) (roiBounds.y);
    float maxY = (int) Math.ceil(roiBounds.y + roiBounds.height);
    // Update the area with the cropped region
    area *= (maxX - minX) / bounds.width;
    area *= (maxY - minY) / bounds.height;
    // Create a new set of results within the bounds
    MemoryPeakResults newResults = new MemoryPeakResults();
    newResults.begin();
    for (PeakResult peakResult : results.getResults()) {
        float x = peakResult.params[Gaussian2DFunction.X_POSITION];
        float y = peakResult.params[Gaussian2DFunction.Y_POSITION];
        if (x < minX || x > maxX || y < minY || y > maxY)
            continue;
        newResults.add(peakResult);
    }
    newResults.end();
    newResults.copySettings(results);
    newResults.setBounds(new Rectangle((int) minX, (int) minY, (int) (maxX - minX), (int) (maxY - minY)));
    return newResults;
}
Also used : Rectangle(java.awt.Rectangle) MemoryPeakResults(gdsc.smlm.results.MemoryPeakResults) PeakResult(gdsc.smlm.results.PeakResult)

Example 42 with MemoryPeakResults

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

the class TraceMolecules method saveResults.

static MemoryPeakResults saveResults(MemoryPeakResults sourceResults, Trace[] traces, String name) {
    MemoryPeakResults tracedResults = TraceManager.convertToPeakResults(sourceResults, traces);
    tracedResults.setName(sourceResults.getName() + " " + name);
    MemoryPeakResults.addResults(tracedResults);
    return tracedResults;
}
Also used : MemoryPeakResults(gdsc.smlm.results.MemoryPeakResults)

Example 43 with MemoryPeakResults

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

the class TraceMolecules method saveCentroidResults.

static MemoryPeakResults saveCentroidResults(MemoryPeakResults sourceResults, Trace[] traces, String name) {
    MemoryPeakResults tracedResults = TraceManager.convertToCentroidPeakResults(sourceResults, traces);
    tracedResults.setName(sourceResults.getName() + " " + name);
    MemoryPeakResults.addResults(tracedResults);
    return tracedResults;
}
Also used : MemoryPeakResults(gdsc.smlm.results.MemoryPeakResults)

Example 44 with MemoryPeakResults

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

the class CreateData method saveFixedAndMoving.

private void saveFixedAndMoving(MemoryPeakResults results, String title) {
    if (simpleMode || benchmarkMode || spotMode)
        return;
    if (settings.diffusionRate <= 0 || settings.fixedFraction >= 1)
        return;
    MemoryPeakResults fixedResults = copyMemoryPeakResults("Fixed");
    MemoryPeakResults movingResults = copyMemoryPeakResults("Moving");
    List<PeakResult> peakResults = results.getResults();
    // Sort using the ID
    Collections.sort(peakResults, new Comparator<PeakResult>() {

        public int compare(PeakResult o1, PeakResult o2) {
            return o1.getId() - o2.getId();
        }
    });
    int currentId = -1;
    MemoryPeakResults currentResults = movingResults;
    for (PeakResult p : peakResults) {
        // The ID was stored in the result's parameter standard deviation array
        if (currentId != p.getId()) {
            currentId = p.getId();
            currentResults = (movingMolecules.contains(currentId)) ? movingResults : fixedResults;
        }
        currentResults.add(p);
    }
    movingResults.end();
    fixedResults.end();
    // Reset the input results
    results.sort();
}
Also used : MemoryPeakResults(gdsc.smlm.results.MemoryPeakResults) PeakResult(gdsc.smlm.results.PeakResult) IdPeakResult(gdsc.smlm.results.IdPeakResult) ExtendedPeakResult(gdsc.smlm.results.ExtendedPeakResult)

Example 45 with MemoryPeakResults

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

the class BlinkEstimator method run.

/*
	 * (non-Javadoc)
	 * 
	 * @see ij.plugin.PlugIn#run(java.lang.String)
	 */
public void run(String arg) {
    SMLMUsageTracker.recordPlugin(this.getClass(), arg);
    // Require some fit results and selected regions
    if (MemoryPeakResults.isMemoryEmpty()) {
        IJ.error(TITLE, "There are no fitting results in memory");
        return;
    }
    if (!showDialog())
        return;
    MemoryPeakResults results = ResultsManager.loadInputResults(inputOption, true);
    if (results == null || results.size() == 0) {
        IJ.error(TITLE, "No results could be loaded");
        IJ.showStatus("");
        return;
    }
    msPerFrame = results.getCalibration().getExposureTime();
    Utils.log("%s: %d localisations", TITLE, results.size());
    showPlots = true;
    if (rangeFittedPoints > 0) {
        computeFitCurves(results, true);
    } else {
        computeBlinkingRate(results, true);
    }
}
Also used : MemoryPeakResults(gdsc.smlm.results.MemoryPeakResults)

Aggregations

MemoryPeakResults (gdsc.smlm.results.MemoryPeakResults)86 PeakResult (gdsc.smlm.results.PeakResult)40 Rectangle (java.awt.Rectangle)16 ArrayList (java.util.ArrayList)13 ExtendedPeakResult (gdsc.smlm.results.ExtendedPeakResult)10 ImagePlus (ij.ImagePlus)10 StoredDataStatistics (gdsc.core.utils.StoredDataStatistics)8 Statistics (gdsc.core.utils.Statistics)7 IJImageSource (gdsc.smlm.ij.IJImageSource)7 Calibration (gdsc.smlm.results.Calibration)7 ExtendedGenericDialog (ij.gui.ExtendedGenericDialog)7 FractionClassificationResult (gdsc.core.match.FractionClassificationResult)6 IJImagePeakResults (gdsc.smlm.ij.results.IJImagePeakResults)6 Trace (gdsc.smlm.results.Trace)6 LinkedList (java.util.LinkedList)6 BasePoint (gdsc.core.match.BasePoint)5 ImageStack (ij.ImageStack)5 Plot2 (ij.gui.Plot2)5 Point (java.awt.Point)5 ClusterPoint (gdsc.core.clustering.ClusterPoint)4