Search in sources :

Example 1 with JumpDistanceAnalysis

use of gdsc.smlm.fitting.JumpDistanceAnalysis in project GDSC-SMLM by aherbert.

the class TraceDiffusion method fitJumpDistance.

/**
	 * Fit the jump distance histogram.
	 * <p>
	 * Update the plot by adding the fit line(s).
	 * 
	 * @param jumpDistances
	 *            (in um^2)
	 * @param jdHistogram
	 * @return The fitted coefficients and fractions
	 */
private double[][] fitJumpDistance(StoredDataStatistics jumpDistances, double[][] jdHistogram) {
    final double msd = jumpDistances.getMean();
    final double meanDistance = Math.sqrt(msd) * 1e3;
    // TODO:
    // Q. Should the beta be expressed using the mean-distance or MSD? 
    // Q. Should it be normalised to the frame length. If not then the beta will be invariant on 
    // jump distance length
    beta = meanDistance / precision;
    Utils.log("Jump Distance analysis : N = %d, Time = %d frames (%s seconds). MSD = %s um^2/jump, Mean Distance = %s nm/jump, Precision = %s nm, Beta = %s", jumpDistances.getN(), settings.jumpDistance, Utils.rounded(settings.jumpDistance * exposureTime, 4), Utils.rounded(msd, 4), Utils.rounded(meanDistance, 4), Utils.rounded(precision, 4), Utils.rounded(beta, 4));
    IJLogger logger = new IJLogger(debugFitting, debugFitting);
    JumpDistanceAnalysis jd = new JumpDistanceAnalysis(logger);
    jd.setFitRestarts(settings.fitRestarts);
    jd.setMinFraction(minFraction);
    jd.setMinDifference(minDifference);
    jd.setMinN(myMinN);
    jd.setMaxN(maxN);
    // Update the plot with the fit
    jd.setCurveLogger(this);
    // Set the calibration
    jd.setN(settings.jumpDistance);
    jd.setDeltaT(exposureTime);
    if (settings.precisionCorrection)
        jd.setError(precision, true);
    jd.setMsdCorrection(settings.msdCorrection);
    double[][] fit;
    if (settings.mle)
        fit = jd.fitJumpDistancesMLE(jumpDistances.getValues(), jdHistogram);
    else
        fit = jd.fitJumpDistanceHistogram(jumpDistances.getMean(), jdHistogram);
    // Get the raw fitted D and convert it to a calibrated D*
    if (fit != null) {
        fit[0] = jd.calculateApparentDiffusionCoefficient(fit[0]);
        // Check the largest D
        checkTraceDistance(fit[0][0]);
        ic = jd.getInformationCriterion();
    }
    return fit;
}
Also used : JumpDistanceAnalysis(gdsc.smlm.fitting.JumpDistanceAnalysis) IJLogger(gdsc.core.ij.IJLogger)

Aggregations

IJLogger (gdsc.core.ij.IJLogger)1 JumpDistanceAnalysis (gdsc.smlm.fitting.JumpDistanceAnalysis)1