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