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();
}
Aggregations