Search in sources :

Example 1 with ErrorStoppingCriteria

use of gdsc.smlm.fitting.nonlinear.stop.ErrorStoppingCriteria in project GDSC-SMLM by aherbert.

the class BoundedFunctionSolverTest method getLVM.

private NonLinearFit getLVM(int bounded, int clamping, boolean mle) {
    Gaussian2DFunction f = GaussianFunctionFactory.create2D(1, size, size, flags, null);
    StoppingCriteria sc = new ErrorStoppingCriteria(5);
    sc.setMaximumIterations(100);
    NonLinearFit solver = (bounded != 0 || clamping != 0) ? new BoundedNonLinearFit(f, sc, null) : new NonLinearFit(f, sc);
    if (clamping != 0) {
        BoundedNonLinearFit bsolver = (BoundedNonLinearFit) solver;
        ParameterBounds bounds = new ParameterBounds(f);
        bounds.setClampValues(defaultClampValues);
        bounds.setDynamicClamp(clamping == 2);
        bsolver.setBounds(bounds);
    }
    solver.setMLE(mle);
    solver.setInitialLambda(1);
    return solver;
}
Also used : Gaussian2DFunction(gdsc.smlm.function.gaussian.Gaussian2DFunction) ErrorStoppingCriteria(gdsc.smlm.fitting.nonlinear.stop.ErrorStoppingCriteria) ErrorStoppingCriteria(gdsc.smlm.fitting.nonlinear.stop.ErrorStoppingCriteria)

Example 2 with ErrorStoppingCriteria

use of gdsc.smlm.fitting.nonlinear.stop.ErrorStoppingCriteria in project GDSC-SMLM by aherbert.

the class FitConfiguration method createStoppingCriteria.

/**
	 * Creates the appropriate stopping criteria for the configuration
	 * 
	 * @param func
	 *            The Gaussian function
	 * @param params
	 *            The Gaussian parameters
	 * @return The stopping criteria
	 */
public StoppingCriteria createStoppingCriteria(Gaussian2DFunction func, double[] params) {
    StoppingCriteria stoppingCriteria;
    if (fitCriteria == FitCriteria.PARAMETERS) {
        ParameterStoppingCriteria sc = new ParameterStoppingCriteria(func);
        sc.setSignificantDigits(significantDigits);
        addPeakRestrictions(func, sc, params);
        stoppingCriteria = sc;
    } else if (fitCriteria == FitCriteria.COORDINATES) {
        GaussianStoppingCriteria sc = new GaussianStoppingCriteria(func);
        sc.setDelta(delta);
        addPeakRestrictions(func, sc, params);
        stoppingCriteria = sc;
    } else {
        ErrorStoppingCriteria sc = new ErrorStoppingCriteria();
        sc.setSignificantDigits(significantDigits);
        sc.setAvoidPlateau(fitCriteria == FitCriteria.LEAST_SQUARED_PLUS);
        stoppingCriteria = sc;
    }
    // Removed to reduce verbosity of logging output
    //stoppingCriteria.setLog(log);
    stoppingCriteria.setMinimumIterations(minIterations);
    stoppingCriteria.setMaximumIterations(maxIterations);
    return stoppingCriteria;
}
Also used : GaussianStoppingCriteria(gdsc.smlm.fitting.nonlinear.stop.GaussianStoppingCriteria) ParameterStoppingCriteria(gdsc.smlm.fitting.nonlinear.stop.ParameterStoppingCriteria) GaussianStoppingCriteria(gdsc.smlm.fitting.nonlinear.stop.GaussianStoppingCriteria) StoppingCriteria(gdsc.smlm.fitting.nonlinear.StoppingCriteria) ParameterStoppingCriteria(gdsc.smlm.fitting.nonlinear.stop.ParameterStoppingCriteria) ErrorStoppingCriteria(gdsc.smlm.fitting.nonlinear.stop.ErrorStoppingCriteria) ErrorStoppingCriteria(gdsc.smlm.fitting.nonlinear.stop.ErrorStoppingCriteria)

Aggregations

ErrorStoppingCriteria (gdsc.smlm.fitting.nonlinear.stop.ErrorStoppingCriteria)2 StoppingCriteria (gdsc.smlm.fitting.nonlinear.StoppingCriteria)1 GaussianStoppingCriteria (gdsc.smlm.fitting.nonlinear.stop.GaussianStoppingCriteria)1 ParameterStoppingCriteria (gdsc.smlm.fitting.nonlinear.stop.ParameterStoppingCriteria)1 Gaussian2DFunction (gdsc.smlm.function.gaussian.Gaussian2DFunction)1