use of uk.ac.sussex.gdsc.smlm.results.procedures.WidthResultProcedure in project GDSC-SMLM by aherbert.
the class FilterResults method analyseResults.
/**
* Analyse the results and determine the range for each filter.
*/
private boolean analyseResults() {
IJ.showStatus("Analysing results ...");
final ArrayList<String> error = new ArrayList<>();
try {
wp = new WidthResultProcedure(results, DistanceUnit.PIXEL);
wp.getW();
final float[] limits = MathUtils.limits(wp.wx);
maxWidth = limits[1];
minWidth = limits[0];
averageWidth = MathUtils.sum(wp.wx) / wp.size();
} catch (final DataException ex) {
error.add(ex.getMessage());
wp = null;
maxWidth = minWidth = 0;
}
try {
pp = new PrecisionResultProcedure(results);
pp.getPrecision();
final double[] limits = MathUtils.limits(pp.precisions);
maxPrecision = limits[1];
minPrecision = limits[0];
} catch (final DataException ex) {
error.add(ex.getMessage());
pp = null;
maxPrecision = minPrecision = 0;
}
try {
sp = new StandardResultProcedure(results, DistanceUnit.PIXEL);
sp.getXyr();
// Re-use for convenience
sp.intensity = new float[sp.x.length];
sp.background = new float[sp.x.length];
sp.z = new float[sp.x.length];
for (int i = 0; i < sp.size(); i++) {
if (i % 64 == 0) {
IJ.showProgress(i, sp.size());
}
final PeakResult result = sp.peakResults[i];
final float drift = getDrift(result, sp.x[i], sp.y[i]);
if (maxDrift < drift) {
maxDrift = drift;
}
if (minDrift > drift) {
minDrift = drift;
}
final float signal = result.getIntensity();
if (maxSignal < signal) {
maxSignal = signal;
}
if (minSignal > signal) {
minSignal = signal;
}
final float snr = getSnr(result);
if (maxSnr < snr) {
maxSnr = snr;
}
if (minSnr > snr) {
minSnr = snr;
}
// for convenience
sp.z[i] = drift;
sp.intensity[i] = signal;
sp.background[i] = snr;
}
} catch (final DataException ex) {
error.add(ex.getMessage());
sp = null;
}
if (error.size() == 3 || sp == null) {
final StringBuilder sb = new StringBuilder("Unable to analyse the results:\n");
for (final String s : error) {
sb.append(s).append(".\n");
}
IJ.error(TITLE, sb.toString());
return false;
}
ImageJUtils.finished();
return true;
}
Aggregations