Search in sources :

Example 51 with ExtendedGenericDialog

use of ij.gui.ExtendedGenericDialog in project GDSC-SMLM by aherbert.

the class FIRE method showInputDialog.

private boolean showInputDialog() {
    ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
    gd.addMessage("Compute the resolution using Fourier Ring Correlation");
    gd.addHelp(About.HELP_URL);
    // Build a list of all images with a region ROI
    List<String> titles = new LinkedList<String>();
    if (WindowManager.getWindowCount() > 0) {
        for (int imageID : WindowManager.getIDList()) {
            ImagePlus imp = WindowManager.getImage(imageID);
            if (imp != null && imp.getRoi() != null && imp.getRoi().isArea())
                titles.add(imp.getTitle());
        }
    }
    ResultsManager.addInput(gd, inputOption, InputSource.MEMORY);
    ResultsManager.addInput(gd, "Input2", inputOption2, InputSource.NONE, InputSource.MEMORY);
    if (!titles.isEmpty())
        gd.addCheckbox((titles.size() == 1) ? "Use_ROI" : "Choose_ROI", chooseRoi);
    gd.showDialog();
    if (gd.wasCanceled())
        return false;
    inputOption = ResultsManager.getInputSource(gd);
    inputOption2 = ResultsManager.getInputSource(gd);
    if (!titles.isEmpty())
        chooseRoi = gd.getNextBoolean();
    if (!titles.isEmpty() && chooseRoi) {
        if (titles.size() == 1) {
            roiImage = titles.get(0);
            Recorder.recordOption("Image", roiImage);
        } else {
            String[] items = titles.toArray(new String[titles.size()]);
            gd = new ExtendedGenericDialog(TITLE);
            gd.addMessage("Select the source image for the ROI");
            gd.addChoice("Image", items, roiImage);
            gd.showDialog();
            if (gd.wasCanceled())
                return false;
            roiImage = gd.getNextChoice();
        }
        ImagePlus imp = WindowManager.getImage(roiImage);
        roiBounds = imp.getRoi().getBounds();
        roiImageWidth = imp.getWidth();
        roiImageHeight = imp.getHeight();
    } else {
        roiBounds = null;
    }
    return true;
}
Also used : NonBlockingExtendedGenericDialog(ij.gui.NonBlockingExtendedGenericDialog) ExtendedGenericDialog(ij.gui.ExtendedGenericDialog) ImagePlus(ij.ImagePlus) LinkedList(java.util.LinkedList) WeightedObservedPoint(org.apache.commons.math3.fitting.WeightedObservedPoint)

Example 52 with ExtendedGenericDialog

use of ij.gui.ExtendedGenericDialog in project GDSC-SMLM by aherbert.

the class FilterResults method run.

/*
	 * (non-Javadoc)
	 * 
	 * @see ij.plugin.PlugIn#run(java.lang.String)
	 */
public void run(String arg) {
    SMLMUsageTracker.recordPlugin(this.getClass(), arg);
    if (MemoryPeakResults.isMemoryEmpty()) {
        IJ.error(TITLE, "There are no fitting results in memory");
        return;
    }
    // Show a dialog allowing the results set to be filtered
    ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
    gd.addMessage("Select a dataset to filter");
    ResultsManager.addInput(gd, inputOption, InputSource.MEMORY);
    gd.showDialog();
    if (gd.wasCanceled())
        return;
    inputOption = ResultsManager.getInputSource(gd);
    results = ResultsManager.loadInputResults(inputOption, false);
    if (results == null || results.size() == 0) {
        IJ.error(TITLE, "No results could be loaded");
        IJ.showStatus("");
        return;
    }
    analyseResults();
    if (!showDialog())
        return;
    filterResults();
}
Also used : ExtendedGenericDialog(ij.gui.ExtendedGenericDialog)

Example 53 with ExtendedGenericDialog

use of ij.gui.ExtendedGenericDialog in project GDSC-SMLM by aherbert.

the class Test_Plugin method run.

/*
	 * (non-Javadoc)
	 * 
	 * @see ij.plugin.PlugIn#run(java.lang.String)
	 */
@Override
public void run(String arg) {
    // The parameters that have options must be available statically for the OptionListener
    final String[] textFields = { "Some text", "More text" };
    final String[] optionFields = { "", "", "" };
    ExtendedGenericDialog gd = new ExtendedGenericDialog("Test");
    gd.addChoice("Select1", new String[] { "One", "Two" }, optionFields[0]);
    final Choice c2 = gd.addAndGetChoice("Select2", new String[] { "Three", "Four" }, optionFields[1]);
    gd.addAndGetButton("Options", new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            // This makes it model
            ExtendedGenericDialog gd2 = new ExtendedGenericDialog("Test2", null);
            gd2.addMessage(c2.getSelectedItem());
            gd2.showDialog(true);
            gd2.getNextChoice();
        }
    });
    gd.addStringField("Another", textFields[0]);
    gd.addStringField("Testing", textFields[1], 15, new OptionListener<TextField>() {

        @Override
        public void collectOptions(TextField field) {
            IJ.log(field.getText());
        }

        @Override
        public void collectOptions() {
            IJ.log(textFields[1]);
        }
    });
    gd.addFilenameField("File", "", 30);
    gd.addDirectoryField("Dir", "", 30);
    gd.addChoice("Select3", new String[] { "Five", "Six" }, optionFields[2], new OptionListener<Choice>() {

        @Override
        public void collectOptions(Choice field) {
            IJ.log(field.getSelectedItem());
        }

        @Override
        public void collectOptions() {
            IJ.log(optionFields[2]);
        }
    });
    gd.showDialog();
    optionFields[0] = gd.getNextChoice();
    optionFields[1] = gd.getNextChoice();
    textFields[0] = gd.getNextString();
    textFields[1] = gd.getNextString();
    optionFields[2] = gd.getNextChoice();
    gd.collectOptions();
}
Also used : Choice(java.awt.Choice) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) TextField(java.awt.TextField) ExtendedGenericDialog(ij.gui.ExtendedGenericDialog)

Example 54 with ExtendedGenericDialog

use of ij.gui.ExtendedGenericDialog in project GDSC-SMLM by aherbert.

the class CropResults method showDialog.

private boolean showDialog() {
    ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
    gd.addHelp(About.HELP_URL);
    // TODO - add option to crop using the bounding rectangle of an ROI on an open image.
    // See PC-PALM Molecules.
    // Build a list of all images with a region ROI
    TurboList<String> titles = new TurboList<String>(WindowManager.getWindowCount());
    if (WindowManager.getWindowCount() > 0) {
        for (int imageID : WindowManager.getIDList()) {
            ImagePlus imp = WindowManager.getImage(imageID);
            if (imp != null && imp.getRoi() != null && imp.getRoi().isArea())
                titles.add(imp.getTitle());
        }
    }
    Rectangle bounds = results.getBounds(true);
    gd.addMessage(String.format("x=%d,y=%d,w=%d,h=%d", bounds.x, bounds.y, bounds.width, bounds.height));
    gd.addNumericField("Border", border, 2);
    gd.addCheckbox("Select_region", selectRegion);
    gd.addNumericField("X", x, 2);
    gd.addNumericField("Y", y, 2);
    gd.addNumericField("Width", width, 2);
    gd.addNumericField("Height", height, 2);
    if (!titles.isEmpty()) {
        gd.addCheckbox("Use_ROI", useRoi);
        String[] items = titles.toArray(new String[titles.size()]);
        gd.addChoice("Image", items, roiImage);
    }
    gd.addCheckbox("Overwrite", overwrite);
    gd.showDialog();
    if (gd.wasCanceled())
        return false;
    border = Math.max(0, gd.getNextNumber());
    selectRegion = gd.getNextBoolean();
    x = gd.getNextNumber();
    y = gd.getNextNumber();
    width = Math.max(0, gd.getNextNumber());
    height = Math.max(0, gd.getNextNumber());
    if (!titles.isEmpty()) {
        myUseRoi = useRoi = gd.getNextBoolean();
        roiImage = gd.getNextChoice();
    }
    overwrite = gd.getNextBoolean();
    return true;
}
Also used : TurboList(gdsc.core.utils.TurboList) Rectangle(java.awt.Rectangle) ExtendedGenericDialog(ij.gui.ExtendedGenericDialog) ImagePlus(ij.ImagePlus)

Example 55 with ExtendedGenericDialog

use of ij.gui.ExtendedGenericDialog in project GDSC-SMLM by aherbert.

the class DarkTimeAnalysis method showDialog.

private boolean showDialog() {
    ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
    gd.addHelp(About.HELP_URL);
    gd.addMessage("Compute the cumulative dark-time histogram");
    ResultsManager.addInput(gd, inputOption, InputSource.MEMORY);
    gd.addChoice("Method", METHOD, METHOD[method]);
    gd.addSlider("Search_distance (nm)", 5, 150, searchDistance);
    gd.addNumericField("Max_dark_time (seconds)", maxDarkTime, 2);
    gd.addSlider("Percentile", 0, 100, percentile);
    gd.addSlider("Histogram_bins", -1, 100, nBins);
    gd.showDialog();
    if (gd.wasCanceled())
        return false;
    inputOption = gd.getNextChoice();
    method = gd.getNextChoiceIndex();
    searchDistance = gd.getNextNumber();
    maxDarkTime = gd.getNextNumber();
    percentile = gd.getNextNumber();
    nBins = (int) gd.getNextNumber();
    // Check arguments
    try {
        Parameters.isAboveZero("Search distance", searchDistance);
        Parameters.isPositive("Percentile", percentile);
    } catch (IllegalArgumentException e) {
        IJ.error(TITLE, e.getMessage());
        return false;
    }
    return true;
}
Also used : ExtendedGenericDialog(ij.gui.ExtendedGenericDialog)

Aggregations

ExtendedGenericDialog (ij.gui.ExtendedGenericDialog)60 ImagePlus (ij.ImagePlus)11 NonBlockingExtendedGenericDialog (ij.gui.NonBlockingExtendedGenericDialog)8 FitEngineConfiguration (gdsc.smlm.engine.FitEngineConfiguration)6 GlobalSettings (gdsc.smlm.ij.settings.GlobalSettings)6 MemoryPeakResults (gdsc.smlm.results.MemoryPeakResults)6 Calibration (gdsc.smlm.results.Calibration)5 ClusterPoint (gdsc.core.clustering.ClusterPoint)4 FitConfiguration (gdsc.smlm.fitting.FitConfiguration)4 PeakResult (gdsc.smlm.results.PeakResult)4 Rectangle (java.awt.Rectangle)4 LinkedList (java.util.LinkedList)4 ArrayList (java.util.ArrayList)3 WeightedObservedPoint (org.apache.commons.math3.fitting.WeightedObservedPoint)3 IJImageSource (gdsc.smlm.ij.IJImageSource)2 IJTablePeakResults (gdsc.smlm.ij.results.IJTablePeakResults)2 ResultsSettings (gdsc.smlm.ij.settings.ResultsSettings)2 ImageSource (gdsc.smlm.results.ImageSource)2 Trace (gdsc.smlm.results.Trace)2 Filter (gdsc.smlm.results.filter.Filter)2