/** * The results of the {@link SR_EELS_CharacterisationPlugin} plugin are parsed. * * <p>This function extracts the values that describe the width of a spectrum depending on its * position on the camera. * * @return a polynomial that fits the given data points */ private SR_EELS_Polynomial_2D getFunctionWidth() { final double[][] vals = new double[importer.size()][3]; int i = 0; for (final float[] point : importer) { // The width of the spectrum -> z value vals[i][0] = point[8]; // Coordinate on the energy dispersive axis -> x value // The same value for top, centre and bottom. vals[i][1] = point[0] - CameraSetup.getFullWidth() / 2; // coordinate on the lateral axis -> y value // The indices for centre, top and bottom are 2, 4 and 6. vals[i][2] = point[2] - CameraSetup.getFullHeight() / 2; i++; } /* * Define the orders of the 2D polynomial. */ final int m = 2; final int n = 2; final SR_EELS_Polynomial_2D func = new SR_EELS_Polynomial_2D(m, n); final double[] b_fit = new double[(m + 1) * (n + 1)]; Arrays.fill(b_fit, 1.); final LMA lma = new LMA(func, b_fit, vals); lma.fit(); /* * TODO: Output information about the fit using IJ.log */ return new SR_EELS_Polynomial_2D(m, n, b_fit); }
/** * The results of the {@link SR_EELS_CharacterisationPlugin} plugin are parsed. * * <p>This function extracts the values that describe the pathway of the borders of a spectrum. * * @return a polynomial that fits the given data points */ private SR_EELS_Polynomial_2D getFunctionBorders() { final double[][] vals = new double[3 * importer.size()][3]; int i = 0; for (final float[] point : importer) { for (int j = 0; j < 3; j++) { // y coordinate of the fit function at the centre of the // image/camera -> // z value vals[i + j][0] = point[2 + 2 * j] - CameraSetup.getFullWidth() / 2; // Coordinate on the energy dispersive axis -> x value // The same value for top, centre and bottom. vals[i + j][1] = point[0] - CameraSetup.getFullHeight() / 2; // coordinate on the lateral axis -> y value // The indices for centre, top and bottom are 2, 4 and 6. vals[i + j][2] = importer.getYInterceptPoint(i / 3)[11 + j] - CameraSetup.getFullHeight() / 2; } i += 3; } /* * Define the orders of the 2D polynomial. */ final int m = 3; final int n = 2; final SR_EELS_Polynomial_2D func = new SR_EELS_Polynomial_2D(m, n); final double[] a_fit = new double[(m + 1) * (n + 1)]; Arrays.fill(a_fit, 1.); final LMA lma = new LMA(func, a_fit, vals); lma.fit(); /* * TODO: Output information about the fit using IJ.log */ return new SR_EELS_Polynomial_2D(m, n, a_fit); }