use of uk.ac.sussex.gdsc.smlm.function.gaussian.erf.SingleAstigmatismErfGaussian2DFunction in project GDSC-SMLM by aherbert.
the class FastMleJacobianGradient2ProcedureTest method gradientCalculatorComputesGradient.
@Override
@SeededTest
void gradientCalculatorComputesGradient(RandomSeed seed) {
gradientCalculatorComputesGradient(seed, 1, new SingleFreeCircularErfGaussian2DFunction(blockWidth, blockWidth));
gradientCalculatorComputesGradient(seed, 2, new MultiFreeCircularErfGaussian2DFunction(2, blockWidth, blockWidth));
// Use a reasonable z-depth function from the Smith, et al (2010) paper (page 377)
final double sx = 1.08;
final double sy = 1.01;
final double gamma = 0.389;
final double d = 0.531;
final double Ax = -0.0708;
final double Bx = -0.073;
final double Ay = 0.164;
final double By = 0.0417;
final HoltzerAstigmatismZModel zModel = HoltzerAstigmatismZModel.create(sx, sy, gamma, d, Ax, Bx, Ay, By);
gradientCalculatorComputesGradient(seed, 1, new SingleAstigmatismErfGaussian2DFunction(blockWidth, blockWidth, zModel));
}
use of uk.ac.sussex.gdsc.smlm.function.gaussian.erf.SingleAstigmatismErfGaussian2DFunction in project GDSC-SMLM by aherbert.
the class FastMleGradient2ProcedureTest method gradientCalculatorComputesGradient.
@SeededTest
void gradientCalculatorComputesGradient(RandomSeed seed) {
gradientCalculatorComputesGradient(seed, new SingleFreeCircularErfGaussian2DFunction(blockWidth, blockWidth));
// Use a reasonable z-depth function from the Smith, et al (2010) paper (page 377)
final double sx = 1.08;
final double sy = 1.01;
final double gamma = 0.389;
final double d = 0.531;
final double Ax = -0.0708;
final double Bx = -0.073;
final double Ay = 0.164;
final double By = 0.0417;
final HoltzerAstigmatismZModel zModel = HoltzerAstigmatismZModel.create(sx, sy, gamma, d, Ax, Bx, Ay, By);
gradientCalculatorComputesGradient(seed, new SingleAstigmatismErfGaussian2DFunction(blockWidth, blockWidth, zModel));
}
use of uk.ac.sussex.gdsc.smlm.function.gaussian.erf.SingleAstigmatismErfGaussian2DFunction in project GDSC-SMLM by aherbert.
the class GaussianPsfModel method createGaussianFunction.
private ErfGaussian2DFunction createGaussianFunction(final int x0range, final int x1range) {
final ErfGaussian2DFunction f = new SingleAstigmatismErfGaussian2DFunction(x0range, x1range, zModel);
f.setErfFunction(ErfGaussian2DFunction.ErfFunction.COMMONS_MATH);
return f;
}
use of uk.ac.sussex.gdsc.smlm.function.gaussian.erf.SingleAstigmatismErfGaussian2DFunction in project GDSC-SMLM by aherbert.
the class PsfModelGradient1FunctionTest method canComputeValueAndGradient.
@Test
void canComputeValueAndGradient() {
// Use a reasonable z-depth function from the Smith, et al (2010) paper (page 377)
final double sx = 1.08;
final double sy = 1.01;
final double gamma = 0.389;
final double d = 0.531;
final double Ax = -0.0708;
final double Bx = -0.073;
final double Ay = 0.164;
final double By = 0.0417;
final AstigmatismZModel zModel = HoltzerAstigmatismZModel.create(sx, sy, gamma, d, Ax, Bx, Ay, By);
// Small size ensure the PSF model covers the entire image
final int maxx = 11;
final int maxy = 11;
final double[] ve = new double[maxx * maxy];
final double[] vo = new double[maxx * maxy];
final double[][] ge = new double[maxx * maxy][];
final double[][] go = new double[maxx * maxy][];
final PsfModelGradient1Function psf = new PsfModelGradient1Function(new GaussianPsfModel(zModel), maxx, maxy);
final ErfGaussian2DFunction f = new SingleAstigmatismErfGaussian2DFunction(maxx, maxy, zModel);
f.setErfFunction(ErfFunction.COMMONS_MATH);
final double[] a2 = new double[Gaussian2DFunction.PARAMETERS_PER_PEAK + 1];
final DoubleDoubleBiPredicate equality = TestHelper.doublesAreClose(1e-8, 0);
final double c = maxx * 0.5;
for (int i = -1; i <= 1; i++) {
final double x0 = c + i * 0.33;
for (int j = -1; j <= 1; j++) {
final double x1 = c + j * 0.33;
for (int k = -1; k <= 1; k++) {
final double x2 = k * 0.33;
for (final double in : new double[] { 23.2, 405.67 }) {
// Background is constant for gradients so just use 1 value
final double[] a = new double[] { 2.2, in, x0, x1, x2 };
psf.initialise1(a);
psf.forEach(new Gradient1Procedure() {
int index = 0;
@Override
public void execute(double value, double[] dyDa) {
vo[index] = value;
go[index] = dyDa.clone();
index++;
}
});
a2[Gaussian2DFunction.BACKGROUND] = a[0];
a2[Gaussian2DFunction.SIGNAL] = a[1];
a2[Gaussian2DFunction.X_POSITION] = a[2] - 0.5;
a2[Gaussian2DFunction.Y_POSITION] = a[3] - 0.5;
a2[Gaussian2DFunction.Z_POSITION] = a[4];
f.initialise1(a2);
f.forEach(new Gradient1Procedure() {
int index = 0;
@Override
public void execute(double value, double[] dyDa) {
ve[index] = value;
ge[index] = dyDa.clone();
index++;
}
});
for (int ii = 0; ii < ve.length; ii++) {
TestAssertions.assertTest(ve[ii], vo[ii], equality);
TestAssertions.assertArrayTest(ge[ii], go[ii], equality);
}
}
}
}
}
}
Aggregations