Search in sources :

Example 1 with FloatStackTrivalueProcedure

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("");
}
Also used : FloatStackTrivalueProcedure(uk.ac.sussex.gdsc.core.data.procedures.FloatStackTrivalueProcedure) ImageStack(ij.ImageStack) NonBlockingExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.NonBlockingExtendedGenericDialog) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog) GenericDialog(ij.gui.GenericDialog) Calibration(ij.measure.Calibration) ImagePlus(ij.ImagePlus)

Aggregations

ImagePlus (ij.ImagePlus)1 ImageStack (ij.ImageStack)1 GenericDialog (ij.gui.GenericDialog)1 Calibration (ij.measure.Calibration)1 FloatStackTrivalueProcedure (uk.ac.sussex.gdsc.core.data.procedures.FloatStackTrivalueProcedure)1 ExtendedGenericDialog (uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)1 NonBlockingExtendedGenericDialog (uk.ac.sussex.gdsc.core.ij.gui.NonBlockingExtendedGenericDialog)1