Search in sources :

Example 6 with FitEngine

use of gdsc.smlm.engine.FitEngine in project GDSC-SMLM by aherbert.

the class PeakFit method runMaximaFitting.

/**
	 * Load the selected results from memory. All multiple frame results are added directly to the results. All single
	 * frame
	 * results are added to a list of candidate maxima per frame and fitted using the configured parameters.
	 */
private void runMaximaFitting() {
    MemoryPeakResults results = ResultsManager.loadInputResults(inputOption, false);
    if (results == null || results.size() == 0) {
        log("No results for maxima fitting");
        return;
    }
    // No check for imageSource since this has been check in the calling method
    int totalFrames = source.getFrames();
    // Store the indices of each new time-frame
    results.sort();
    List<PeakResult> candidateMaxima = results.getResults();
    // Use the FitEngine to allow multi-threading.
    FitEngine engine = createFitEngine(getNumberOfThreads(totalFrames));
    final int step = Utils.getProgressInterval(totalFrames);
    runTime = System.nanoTime();
    boolean shutdown = false;
    int slice = candidateMaxima.get(0).getFrame();
    ArrayList<PeakResult> sliceCandidates = new ArrayList<PeakResult>();
    Iterator<PeakResult> iter = candidateMaxima.iterator();
    while (iter.hasNext()) {
        PeakResult r = iter.next();
        if (slice != r.getFrame()) {
            if (escapePressed()) {
                shutdown = true;
                break;
            }
            if (slice % step == 0) {
                if (Utils.showStatus("Slice: " + slice + " / " + totalFrames))
                    IJ.showProgress(slice, totalFrames);
            }
            // Process results
            if (!processResults(engine, sliceCandidates, slice))
                break;
            sliceCandidates.clear();
        }
        slice = r.getFrame();
        sliceCandidates.add(r);
    }
    // Process final results
    if (!shutdown)
        processResults(engine, sliceCandidates, slice);
    engine.end(shutdown);
    time = engine.getTime();
    runTime = System.nanoTime() - runTime;
    showResults();
    source.close();
}
Also used : FitEngine(gdsc.smlm.engine.FitEngine) ArrayList(java.util.ArrayList) MemoryPeakResults(gdsc.smlm.results.MemoryPeakResults) PeakResult(gdsc.smlm.results.PeakResult) ExtendedPeakResult(gdsc.smlm.results.ExtendedPeakResult)

Aggregations

FitEngine (gdsc.smlm.engine.FitEngine)6 MemoryPeakResults (gdsc.smlm.results.MemoryPeakResults)4 Rectangle (java.awt.Rectangle)4 ArrayList (java.util.ArrayList)3 FitParameters (gdsc.smlm.engine.FitParameters)2 ParameterisedFitJob (gdsc.smlm.engine.ParameterisedFitJob)2 FitConfiguration (gdsc.smlm.fitting.FitConfiguration)2 ImageSource (gdsc.smlm.results.ImageSource)2 ImageStack (ij.ImageStack)2 ClusterPoint (gdsc.core.clustering.ClusterPoint)1 BasePoint (gdsc.core.match.BasePoint)1 ImageExtractor (gdsc.core.utils.ImageExtractor)1 Random (gdsc.core.utils.Random)1 StoredDataStatistics (gdsc.core.utils.StoredDataStatistics)1 FitEngineConfiguration (gdsc.smlm.engine.FitEngineConfiguration)1 FitJob (gdsc.smlm.engine.FitJob)1 SpotFilter (gdsc.smlm.filters.SpotFilter)1 FitResult (gdsc.smlm.fitting.FitResult)1 FitStatus (gdsc.smlm.fitting.FitStatus)1 IJImageSource (gdsc.smlm.ij.IJImageSource)1