use of uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults in project GDSC-SMLM by aherbert.
the class Filter method score.
/**
* Filter the results and return the performance score. Allows benchmarking the filter by marking
* the results as true or false.
*
* <p>Any input PeakResult with an original value that is not zero will be treated as a true
* result, all other results are false. The filter is run and the results are marked as true
* positive, false negative and false positive.
*
* <p>The number of consecutive rejections are counted per frame. When the configured number of
* failures is reached all remaining results for the frame are rejected. This assumes the results
* are ordered by the frame.
*
* @param resultsList a list of results to analyse
* @param failures the number of failures to allow per frame before all peaks are rejected
* @return the score
*/
public ClassificationResult score(List<MemoryPeakResults> resultsList, final int failures) {
final int[] s = new int[4];
for (final MemoryPeakResults peakResults : resultsList) {
setup(peakResults);
final FrameCounter counter = new FrameCounter();
peakResults.forEach((PeakResultProcedure) peak -> {
counter.advanceAndReset(peak.getFrame());
final boolean isTrue = peak.getOrigValue() != 0;
final boolean isPositive;
if (counter.getCount() > failures) {
isPositive = false;
} else {
isPositive = accept(peak);
}
if (isPositive) {
counter.reset();
} else {
counter.increment();
}
if (isTrue) {
if (isPositive) {
s[TP]++;
} else {
s[FN]++;
}
} else if (isPositive) {
s[FP]++;
} else {
s[TN]++;
}
});
end();
}
return new ClassificationResult(s[TP], s[FP], s[TN], s[FN]);
}
use of uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults in project GDSC-SMLM by aherbert.
the class PeakResultTableModel method toMemoryPeakResults.
// *************************************************************************/
// Data management
// *************************************************************************/
/**
* To memory peak results.
*
* @return the memory peak results
*/
public MemoryPeakResults toMemoryPeakResults() {
final ArrayPeakResultStore store = new ArrayPeakResultStore(data.size());
store.addArray(data.toArray());
final MemoryPeakResults results = new MemoryPeakResults(store);
results.setPsf(psf);
results.setCalibration(calibration);
results.setSource(source);
results.setConfiguration(configuration);
return results;
}
use of uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults in project GDSC-SMLM by aherbert.
the class PeakResultTableModelFrame method doResultsShowInfo.
private void doResultsShowInfo() {
// Delegate to Summarise Results
final PeakResultTableModel model = getModel();
final MemoryPeakResults results = model.toMemoryPeakResults();
results.setName("Table data: " + getTitle());
SummariseResults.showSummary(Collections.singletonList(results));
}
use of uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults in project GDSC-SMLM by aherbert.
the class PeakResultTableModelFrame method doResultsSave.
private void doResultsSave() {
final PeakResultTableModel model = getModel();
if (model == null || model.getRowCount() == 0) {
return;
}
final ExtendedGenericDialog gd = new ExtendedGenericDialog("Save Results", this);
if (TextUtils.isNullOrEmpty(saveName)) {
saveName = getTitle();
}
gd.addStringField("Results_set_name", saveName, 30);
gd.showDialog();
if (gd.wasCanceled()) {
return;
}
saveName = gd.getNextString();
if (TextUtils.isNullOrEmpty(saveName)) {
IJ.error("No results set name");
return;
}
final MemoryPeakResults results = model.toMemoryPeakResults();
results.setName(saveName);
MemoryPeakResults.addResults(results);
}
use of uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults in project GDSC-SMLM by aherbert.
the class TraceMolecules method saveResults.
/**
* Convert the traces to results.
*
* @param sourceResults the source results
* @param traces the traces
* @param name the name
* @return the memory peak results
*/
static MemoryPeakResults saveResults(MemoryPeakResults sourceResults, Trace[] traces, String name) {
final MemoryPeakResults tracedResults = TraceManager.convertToPeakResults(sourceResults, traces);
tracedResults.setName(sourceResults.getName() + " " + name);
MemoryPeakResults.addResults(tracedResults);
return tracedResults;
}
Aggregations