use of gdsc.smlm.fitting.FitResult in project GDSC-SMLM by aherbert.
the class BenchmarkSpotFit method addToStats.
private void addToStats(gdsc.smlm.results.filter.MultiPathFitResult.FitResult fitResult, StoredDataStatistics[][] stats) {
if (fitResult == null)
return;
final FitResult actualFitResult = (FitResult) fitResult.getData();
if (fitResult.status != 0) {
// Add the evaluations for spots that were not OK
stats[0][FILTER_ITERATIONS].add(actualFitResult.getIterations());
stats[0][FILTER_EVALUATIONS].add(actualFitResult.getEvaluations());
return;
}
if (fitResult.results == null)
return;
boolean isMatch = false;
for (int resultIndex = 0; resultIndex < fitResult.results.length; resultIndex++) {
BasePreprocessedPeakResult result = (BasePreprocessedPeakResult) fitResult.results[resultIndex];
// Q. Only build stats on new results?
if (!result.isNewResult())
continue;
// This was fit - Get statistics
final double precision = Math.sqrt(result.getLocationVariance());
final double signal = result.getSignal();
final double snr = result.getSNR();
final double width = result.getXSDFactor();
final double xShift = result.getXRelativeShift2();
final double yShift = result.getYRelativeShift2();
// Since these two are combined for filtering and the max is what matters.
final double shift = (xShift > yShift) ? Math.sqrt(xShift) : Math.sqrt(yShift);
final double eshift = Math.sqrt(xShift + yShift);
stats[0][FILTER_SIGNAL].add(signal);
stats[0][FILTER_SNR].add(snr);
if (width < 1)
stats[0][FILTER_MIN_WIDTH].add(width);
else
stats[0][FILTER_MAX_WIDTH].add(width);
stats[0][FILTER_SHIFT].add(shift);
stats[0][FILTER_ESHIFT].add(eshift);
stats[0][FILTER_PRECISION].add(precision);
if (resultIndex == 0) {
stats[0][FILTER_ITERATIONS].add(actualFitResult.getIterations());
stats[0][FILTER_EVALUATIONS].add(actualFitResult.getEvaluations());
}
// Add to the TP or FP stats
// If it has assignments then it was a match to something
isMatch |= result.hasAssignments();
final int index = (result.hasAssignments()) ? 1 : 2;
stats[index][FILTER_SIGNAL].add(signal);
stats[index][FILTER_SNR].add(snr);
if (width < 1)
stats[index][FILTER_MIN_WIDTH].add(width);
else
stats[index][FILTER_MAX_WIDTH].add(width);
stats[index][FILTER_SHIFT].add(shift);
stats[index][FILTER_ESHIFT].add(eshift);
stats[index][FILTER_PRECISION].add(precision);
if (resultIndex == 0) {
}
}
final int index = (isMatch) ? 1 : 2;
stats[index][FILTER_ITERATIONS].add(actualFitResult.getIterations());
stats[index][FILTER_EVALUATIONS].add(actualFitResult.getEvaluations());
}
Aggregations