use of uk.ac.sussex.gdsc.smlm.function.gaussian.Gaussian2DFunction in project GDSC-SMLM by aherbert.
the class SimplePeakResultValidationData method compute.
private void compute() {
if (noise != -1) {
return;
}
final double[] spotParams = extractSpotParams(params, peakNumber);
// Adjust to the data frame
spotParams[Gaussian2DFunction.X_POSITION] += ox;
spotParams[Gaussian2DFunction.Y_POSITION] += oy;
// Add the 0.5 pixel offset to get the centre pixel
final int x = (int) (spotParams[Gaussian2DFunction.X_POSITION] + 0.5);
final int y = (int) (spotParams[Gaussian2DFunction.Y_POSITION] + 0.5);
// Do not evaluate over a large region for speed.
// Use only 50% of the Gaussian volume or 3 pixels.
int nx = getRange(spotParams[Gaussian2DFunction.X_SD] * Gaussian2DPeakResultHelper.R_2D_50, 3);
int ny = getRange(spotParams[Gaussian2DFunction.Y_SD] * Gaussian2DPeakResultHelper.R_2D_50, 3);
final Rectangle r1 = new Rectangle(x - nx, y - ny, 2 * nx + 1, 2 * ny + 1);
final Rectangle r2 = r1.intersection(new Rectangle(0, 0, maxx, maxy));
if (r2.width * r2.height <= 1) {
localBackground = params[Gaussian2DFunction.BACKGROUND];
// Assume photon shot noise.
noise = Math.sqrt(localBackground);
return;
}
// Get the region of the data
final double[] region = ic.getDoubleData(data, maxx, maxy, r2, null);
// Compute the function in the same region.
// Adjust the coordinates for clipping (r2 will be >= r1).
// This effectively makes nx/ny represent the number of pixels before the centre pixel
nx -= r2.x - r1.x;
ny -= r2.y - r1.y;
// Put the spot in the centre of the region
spotParams[Gaussian2DFunction.X_POSITION] += nx - x;
spotParams[Gaussian2DFunction.Y_POSITION] += ny - y;
final Gaussian2DFunction f = factory.create2D(1, r2.width, r2.height);
final double[] v = f.computeValues(spotParams);
final Statistics stats = new Statistics();
for (int i = 0; i < v.length; i++) {
stats.add(region[i] - v[i]);
}
localBackground = stats.getMean();
noise = stats.getStandardDeviation();
}
use of uk.ac.sussex.gdsc.smlm.function.gaussian.Gaussian2DFunction in project GDSC-SMLM by aherbert.
the class Image3DAlignerTest method createData.
private FloatImage3D createData(int x, int y, int z, double cx, double cy, double cz) {
final Gaussian2DFunction f = GaussianFunctionFactory.create2D(1, x, y, GaussianFunctionFactory.FIT_ASTIGMATISM, zModel);
final int length = x * y;
final float[] data = new float[z * length];
final double[] a = new double[1 + Gaussian2DFunction.PARAMETERS_PER_PEAK];
a[Gaussian2DFunction.SIGNAL] = 1;
a[Gaussian2DFunction.X_POSITION] = cx;
a[Gaussian2DFunction.Y_POSITION] = cy;
a[Gaussian2DFunction.X_SD] = 1;
a[Gaussian2DFunction.Y_SD] = 1;
final StandardFloatValueProcedure p = new StandardFloatValueProcedure();
for (int zz = 0; zz < z; zz++) {
final double dz = zz - cz;
// if (zz == 0 || zz == z - 1)
// logger.fine(FunctionUtils.getSupplier("%f %f %f", dz, zModel.getSx(dz), zModel.getSy(dz));
a[Gaussian2DFunction.Z_POSITION] = dz;
p.getValues(f, a, data, zz * length);
}
return new FloatImage3D(x, y, z, data);
}
use of uk.ac.sussex.gdsc.smlm.function.gaussian.Gaussian2DFunction in project GDSC-SMLM by aherbert.
the class Image2DAlignerTest method createData.
private static FloatImage2D createData(int x, int y, double cx, double cy) {
final Gaussian2DFunction f = GaussianFunctionFactory.create2D(1, x, y, GaussianFunctionFactory.FIT_ERF_FREE_CIRCLE, null);
final double[] a = new double[1 + Gaussian2DFunction.PARAMETERS_PER_PEAK];
a[Gaussian2DFunction.SIGNAL] = 1;
a[Gaussian2DFunction.X_POSITION] = cx;
a[Gaussian2DFunction.Y_POSITION] = cy;
a[Gaussian2DFunction.X_SD] = 1.2;
a[Gaussian2DFunction.Y_SD] = 1.1;
final StandardFloatValueProcedure p = new StandardFloatValueProcedure();
return new FloatImage2D(x, y, p.getValues(f, a));
}
use of uk.ac.sussex.gdsc.smlm.function.gaussian.Gaussian2DFunction in project GDSC-SMLM by aherbert.
the class DoubleDht3DTest method createData.
private static DoubleDht3D createData(double cx, double cy, double cz) {
final Gaussian2DFunction f = GaussianFunctionFactory.create2D(1, size, size, GaussianFunctionFactory.FIT_ASTIGMATISM, zModel);
final int length = size * size;
final double[] data = new double[size * length];
final double[] a = new double[1 + Gaussian2DFunction.PARAMETERS_PER_PEAK];
a[Gaussian2DFunction.SIGNAL] = 1;
a[Gaussian2DFunction.X_POSITION] = cx;
a[Gaussian2DFunction.Y_POSITION] = cy;
a[Gaussian2DFunction.X_SD] = 1;
a[Gaussian2DFunction.Y_SD] = 1;
final StandardValueProcedure p = new StandardValueProcedure();
for (int z = 0; z < size; z++) {
a[Gaussian2DFunction.Z_POSITION] = z - cz;
p.getValues(f, a, data, z * length);
}
return new DoubleDht3D(size, size, size, data, false);
}
use of uk.ac.sussex.gdsc.smlm.function.gaussian.Gaussian2DFunction in project GDSC-SMLM by aherbert.
the class FloatDht3DTest method createData.
private static FloatDht3D createData(double cx, double cy, double cz) {
final Gaussian2DFunction f = GaussianFunctionFactory.create2D(1, size, size, GaussianFunctionFactory.FIT_ASTIGMATISM, zModel);
final int length = size * size;
final float[] data = new float[size * length];
final double[] a = new double[1 + Gaussian2DFunction.PARAMETERS_PER_PEAK];
a[Gaussian2DFunction.SIGNAL] = 1;
a[Gaussian2DFunction.X_POSITION] = cx;
a[Gaussian2DFunction.Y_POSITION] = cy;
a[Gaussian2DFunction.X_SD] = 1;
a[Gaussian2DFunction.Y_SD] = 1;
final StandardFloatValueProcedure p = new StandardFloatValueProcedure();
for (int z = 0; z < size; z++) {
a[Gaussian2DFunction.Z_POSITION] = z - cz;
p.getValues(f, a, data, z * length);
}
return new FloatDht3D(size, size, size, data, false);
}
Aggregations