Search in sources :

Example 1 with FrcFireResult

use of uk.ac.sussex.gdsc.smlm.ij.frc.Frc.FrcFireResult in project GDSC-SMLM by aherbert.

the class Fire method calculateFireNumber.

/**
 * Calculate the Fourier Image REsolution (FIRE) number using the chosen threshold method. Should
 * be called after {@link #initialise(MemoryPeakResults, MemoryPeakResults)}.
 *
 * @param fourierMethod the fourier method
 * @param samplingMethod the sampling method
 * @param thresholdMethod the threshold method
 * @param images the images
 * @return The FIRE number
 */
public FireResult calculateFireNumber(FourierMethod fourierMethod, SamplingMethod samplingMethod, ThresholdMethod thresholdMethod, FireImages images) {
    if (images == null) {
        return null;
    }
    final Frc frc = new Frc();
    // Allow a progress tracker to be input.
    // This should be setup for the total number of repeats.
    // If parallelised then do not output the text status messages as they conflict.
    frc.setTrackProgress(progress);
    frc.setFourierMethod(fourierMethod);
    frc.setSamplingMethod(samplingMethod);
    frc.setPerimeterSamplingFactor(settings.perimeterSamplingFactor);
    final FrcCurve frcCurve = frc.calculateFrcCurve(images.ip1, images.ip2, images.nmPerPixel);
    if (frcCurve == null) {
        return null;
    }
    if (correctionQValue > 0) {
        Frc.applyQCorrection(frcCurve, correctionQValue, correctionMean, correctionSigma);
    }
    final double[] originalCorrelationCurve = frcCurve.getCorrelationValues();
    Frc.getSmoothedCurve(frcCurve, true);
    // Resolution in pixels
    final FrcFireResult result = Frc.calculateFire(frcCurve, thresholdMethod);
    if (result == null) {
        return new FireResult(Double.NaN, Double.NaN, frcCurve, originalCorrelationCurve);
    }
    final double fireNumber = result.fireNumber;
    // than 1/4 of R (the resolution).
    if (fireNumber > 0 && (images.nmPerPixel > fireNumber / 4)) {
        // Q. Should this be output somewhere else?
        ImageJUtils.log("%s Warning: The super-resolution pixel size (%s) should be smaller than 1/4 of R" + " (the resolution %s)", pluginTitle, MathUtils.rounded(images.nmPerPixel), MathUtils.rounded(fireNumber));
    }
    return new FireResult(fireNumber, result.correlation, frcCurve, originalCorrelationCurve);
}
Also used : Frc(uk.ac.sussex.gdsc.smlm.ij.frc.Frc) FrcCurve(uk.ac.sussex.gdsc.smlm.ij.frc.Frc.FrcCurve) FrcFireResult(uk.ac.sussex.gdsc.smlm.ij.frc.Frc.FrcFireResult) FrcFireResult(uk.ac.sussex.gdsc.smlm.ij.frc.Frc.FrcFireResult)

Aggregations

Frc (uk.ac.sussex.gdsc.smlm.ij.frc.Frc)1 FrcCurve (uk.ac.sussex.gdsc.smlm.ij.frc.Frc.FrcCurve)1 FrcFireResult (uk.ac.sussex.gdsc.smlm.ij.frc.Frc.FrcFireResult)1