Search in sources :

Example 71 with ExtendedGenericDialog

use of uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog in project GDSC-SMLM by aherbert.

the class DarkTimeAnalysis method showDialog.

private boolean showDialog() {
    final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
    gd.addHelp(HelpUrls.getUrl("dark-time-analysis"));
    settings = Settings.load();
    gd.addMessage("Compute the cumulative dark-time histogram");
    ResultsManager.addInput(gd, settings.inputOption, InputSource.MEMORY);
    gd.addChoice("Method", METHOD, METHOD[settings.method]);
    gd.addSlider("Search_distance (nm)", 5, 150, settings.searchDistance);
    gd.addNumericField("Max_dark_time (seconds)", settings.maxDarkTime, 2);
    gd.addSlider("Percentile", 0, 100, settings.percentile);
    gd.addSlider("Histogram_bins", -1, 100, settings.histogramBins);
    gd.showDialog();
    if (gd.wasCanceled()) {
        return false;
    }
    settings.inputOption = gd.getNextChoice();
    settings.method = gd.getNextChoiceIndex();
    settings.searchDistance = gd.getNextNumber();
    settings.maxDarkTime = gd.getNextNumber();
    settings.percentile = gd.getNextNumber();
    settings.histogramBins = (int) gd.getNextNumber();
    settings.save();
    // Check arguments
    try {
        ParameterUtils.isAboveZero("Search distance", settings.searchDistance);
        ParameterUtils.isPositive("Percentile", settings.percentile);
    } catch (final IllegalArgumentException ex) {
        IJ.error(TITLE, ex.getMessage());
        return false;
    }
    return true;
}
Also used : ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)

Example 72 with ExtendedGenericDialog

use of uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog in project GDSC-SMLM by aherbert.

the class DensityEstimator method showDialog.

private boolean showDialog() {
    settings = Settings.load();
    final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
    gd.addHelp(HelpUrls.getUrl("density-estimator"));
    gd.addMessage(TextUtils.wrap("Compute local density using NxN squares around localisations. The border size " + "should reflect the extent of the PSF in pixels (N=2*border+1). All overlapping " + "PSFs are joined to an area and the density of localisations in each area is " + "computed.", 80));
    ResultsManager.addInput(gd, settings.inputOption, InputSource.MEMORY);
    gd.addSlider("Border", 0, 20, settings.border);
    gd.addCheckbox("Include_singles", settings.includeSingles);
    gd.showDialog();
    if (gd.wasCanceled()) {
        return false;
    }
    settings.inputOption = ResultsManager.getInputSource(gd);
    settings.border = (int) gd.getNextNumber();
    settings.includeSingles = gd.getNextBoolean();
    settings.save();
    return true;
}
Also used : ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)

Example 73 with ExtendedGenericDialog

use of uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog in project GDSC-SMLM by aherbert.

the class AstigmatismModelManager method run.

@Override
public void run(String arg) {
    SmlmUsageTracker.recordPlugin(this.getClass(), arg);
    String[] options = OPTIONS;
    final AstigmatismModelSettings settings = AstigmatismModelSettingsHolder.getSettings();
    if (settings.getAstigmatismModelResourcesCount() == 0) {
        options = OPTIONS2;
    }
    pluginSettings = readAstigmatismModelManagerSettings();
    final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
    gd.addChoice("Option", options, pluginSettings.getOption());
    gd.addHelp(HelpUrls.getUrl("astigmatism-model-manager"));
    gd.showDialog();
    if (gd.wasCanceled()) {
        return;
    }
    pluginSettings.setOption(gd.getNextChoiceIndex());
    switch(pluginSettings.getOption()) {
        case 5:
            exportModel();
            break;
        case 4:
            invertModel();
            break;
        case 3:
            deleteModel();
            break;
        case 2:
            viewModel();
            break;
        case 1:
            importModel();
            break;
        default:
            createModel();
    }
    writeAstigmatismModelManagerSettings(pluginSettings);
}
Also used : AstigmatismModelSettings(uk.ac.sussex.gdsc.smlm.data.config.PSFProtos.AstigmatismModelSettings) NonBlockingExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.NonBlockingExtendedGenericDialog) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)

Example 74 with ExtendedGenericDialog

use of uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog in project GDSC-SMLM by aherbert.

the class AstigmatismModelManager method exportModel.

private void exportModel() {
    final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
    final String[] models = listAstigmatismModels(false);
    gd.addChoice("Model", models, pluginSettings.getSelected());
    gd.addFilenameField("Filename", pluginSettings.getFilename());
    gd.addHelp(HelpUrls.getUrl("astigmatism-model-manager-export"));
    gd.showDialog();
    if (gd.wasCanceled()) {
        return;
    }
    final String name = gd.getNextChoice();
    pluginSettings.setSelected(name);
    pluginSettings.setFilename(gd.getNextString());
    // Try and get the named resource
    final AstigmatismModel model = AstigmatismModelSettingsHolder.getSettings().getAstigmatismModelResourcesMap().get(name);
    if (model == null) {
        IJ.error(TITLE, "Failed to find astigmatism model: " + name);
        return;
    }
    if (!SettingsManager.toJson(model, new File(pluginSettings.getFilename()), 0)) {
        IJ.error(TITLE, "Failed to export astigmatism model: " + name);
        return;
    }
    ImageJUtils.log("Exported astigmatism model: %s to %s", name, pluginSettings.getFilename());
}
Also used : AstigmatismModel(uk.ac.sussex.gdsc.smlm.data.config.PSFProtos.AstigmatismModel) NonBlockingExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.NonBlockingExtendedGenericDialog) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog) File(java.io.File)

Example 75 with ExtendedGenericDialog

use of uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog in project GDSC-SMLM by aherbert.

the class AstigmatismModelManager method showFitDialog.

private boolean showFitDialog() {
    guessScale();
    final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
    gd.addMessage("Use Gaussian 2D PSF fitting to create an astigmatism z-model");
    gd.addNumericField("nm_per_slice", pluginSettings.getNmPerSlice(), 0);
    gd.addHelp(HelpUrls.getUrl("astigmatism-model-manager-create"));
    gd.showDialog();
    if (gd.wasCanceled()) {
        return false;
    }
    pluginSettings.setNmPerSlice(gd.getNextNumber());
    writeAstigmatismModelManagerSettings(pluginSettings);
    // Check arguments
    try {
        ParameterUtils.isPositive("nm/slice", pluginSettings.getNmPerSlice());
    } catch (final IllegalArgumentException ex) {
        IJ.error(TITLE, ex.getMessage());
        return false;
    }
    return true;
}
Also used : NonBlockingExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.NonBlockingExtendedGenericDialog) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)

Aggregations

ExtendedGenericDialog (uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)151 NonBlockingExtendedGenericDialog (uk.ac.sussex.gdsc.core.ij.gui.NonBlockingExtendedGenericDialog)38 CalibrationWriter (uk.ac.sussex.gdsc.smlm.data.config.CalibrationWriter)21 MemoryPeakResults (uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults)14 Checkbox (java.awt.Checkbox)13 ImagePlus (ij.ImagePlus)12 File (java.io.File)11 Rectangle (java.awt.Rectangle)10 TextField (java.awt.TextField)10 ResultsImageSettings (uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsImageSettings)10 FitConfiguration (uk.ac.sussex.gdsc.smlm.engine.FitConfiguration)10 Choice (java.awt.Choice)9 ArrayList (java.util.ArrayList)9 DistanceUnit (uk.ac.sussex.gdsc.smlm.data.config.UnitProtos.DistanceUnit)9 LocalList (uk.ac.sussex.gdsc.core.utils.LocalList)8 CalibrationReader (uk.ac.sussex.gdsc.smlm.data.config.CalibrationReader)7 ResultsSettings (uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsSettings)7 ResultsTableSettings (uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsTableSettings)7 IJ (ij.IJ)6 GenericDialog (ij.gui.GenericDialog)5