use of uk.ac.sussex.gdsc.core.data.procedures.FloatStackTrivalueProcedure in project GDSC-SMLM by aherbert.
the class CubicSplineManager method runViewCubicSpline.
private void runViewCubicSpline() {
final GenericDialog gd = new GenericDialog(TITLE);
final String[] models = listCubicSplines(false);
gd.addChoice("Model", models, pluginSettings.getSelected());
gd.addSlider("Magnification", 1, 5, pluginSettings.getMagnification());
gd.addHelp(HelpUrls.getUrl("cubic-spline-manager-view"));
gd.showDialog();
if (gd.wasCanceled()) {
return;
}
final String name = gd.getNextChoice();
pluginSettings.setSelected(name);
final int magnification = (int) gd.getNextNumber();
pluginSettings.setMagnification(magnification);
final CubicSplinePsf psfModel = load(name);
if (psfModel == null) {
IJ.log("Failed to find spline data for model: " + name);
return;
}
IJ.showStatus("Drawing cubic spline");
final FloatStackTrivalueProcedure p = new FloatStackTrivalueProcedure();
psfModel.splineData.sample(magnification, p, SimpleImageJTrackProgress.getInstance());
final ImageStack stack = new ImageStack(p.getXAxis().length, p.getYAxis().length);
for (final float[] pixels : p.getValue()) {
stack.addSlice(null, pixels);
}
final ImagePlus imp = ImageJUtils.display(name + " (upsampled)", stack);
final Calibration c = imp.getLocalCalibration();
c.setUnit("nm");
c.pixelWidth = c.pixelHeight = psfModel.imagePsf.getPixelSize() * magnification;
c.pixelDepth = psfModel.imagePsf.getPixelDepth() * magnification;
final int centre = 1 + (int) Math.round(psfModel.imagePsf.getZCentre() * magnification);
imp.setSlice(centre);
imp.resetDisplayRange();
imp.updateAndDraw();
IJ.showStatus("");
}
Aggregations