Search in sources :

Example 6 with FitResult

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());
}
Also used : BasePreprocessedPeakResult(gdsc.smlm.results.filter.BasePreprocessedPeakResult) MultiPathFitResult(gdsc.smlm.results.filter.MultiPathFitResult) FitResult(gdsc.smlm.fitting.FitResult) PeakResultPoint(gdsc.smlm.ij.plugins.ResultsMatchCalculator.PeakResultPoint) BasePoint(gdsc.core.match.BasePoint)

Aggregations

FitResult (gdsc.smlm.fitting.FitResult)6 FitConfiguration (gdsc.smlm.fitting.FitConfiguration)2 Gaussian2DFitter (gdsc.smlm.fitting.Gaussian2DFitter)2 MultiPathFitResult (gdsc.smlm.results.filter.MultiPathFitResult)2 ClusterPoint (gdsc.core.clustering.ClusterPoint)1 BasePoint (gdsc.core.match.BasePoint)1 FitEngine (gdsc.smlm.engine.FitEngine)1 FitEngineConfiguration (gdsc.smlm.engine.FitEngineConfiguration)1 FitParameters (gdsc.smlm.engine.FitParameters)1 ParameterisedFitJob (gdsc.smlm.engine.ParameterisedFitJob)1 FitStatus (gdsc.smlm.fitting.FitStatus)1 PeakResultPoint (gdsc.smlm.ij.plugins.ResultsMatchCalculator.PeakResultPoint)1 ExtendedPeakResult (gdsc.smlm.results.ExtendedPeakResult)1 IdPeakResult (gdsc.smlm.results.IdPeakResult)1 ImageSource (gdsc.smlm.results.ImageSource)1 MemoryPeakResults (gdsc.smlm.results.MemoryPeakResults)1 PeakResult (gdsc.smlm.results.PeakResult)1 Trace (gdsc.smlm.results.Trace)1 BasePreprocessedPeakResult (gdsc.smlm.results.filter.BasePreprocessedPeakResult)1 PreprocessedPeakResult (gdsc.smlm.results.filter.PreprocessedPeakResult)1