Search in sources :

Example 86 with ExtendedGenericDialog

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

the class TraceMolecules method showDynamicTraceDialog.

private boolean showDynamicTraceDialog() {
    pluginTitle = outputName + " Molecules";
    final ExtendedGenericDialog gd = new ExtendedGenericDialog(pluginTitle);
    gd.addHelp(HelpUrls.getUrl("dynamic-trace-molecules"));
    readSettings();
    ResultsManager.addInput(gd, pluginSettings.inputOption, InputSource.MEMORY);
    // Dynamic Multiple Target Tracing
    final TextField tfD = gd.addAndGetNumericField("Diffusion_coefficient", settings.getDiffusionCoefficentMaximum(), 3, 6, "um^2/s");
    final TextField tfW = gd.addAndGetNumericField("Temporal_window", settings.getTemporalWindow(), 0, 6, "frames");
    final TextField tfLdw = gd.addAndGetNumericField("Local_diffusion_weight", settings.getLocalDiffusionWeight(), 2);
    final TextField tfOiw = gd.addAndGetNumericField("On_intensity_weight", settings.getOnIntensityWeight(), 2);
    final TextField tfDdf = gd.addAndGetNumericField("Disappearance_decay_factor", settings.getDisappearanceDecayFactor(), 0, 6, "frames");
    final TextField tfDt = gd.addAndGetNumericField("Disappearance_threshold", settings.getDisappearanceThreshold(), 0, 6, "frames");
    final Checkbox cbDld = gd.addAndGetCheckbox("Disable_local_diffusion_model", settings.getDisableLocalDiffusionModel());
    final Checkbox cbDim = gd.addAndGetCheckbox("Disable_intensity_model", settings.getDisableIntensityModel());
    // Allow reset to defaults
    gd.addAndGetButton("Defaults", e -> {
        final DmttConfiguration config = DmttConfiguration.newBuilder(1).build();
        tfD.setText(String.valueOf(settings.getDiffusionCoefficentMaximum()));
        tfW.setText(String.valueOf(config.getTemporalWindow()));
        tfLdw.setText(String.valueOf(config.getLocalDiffusionWeight()));
        tfOiw.setText(String.valueOf(config.getOnIntensityWeight()));
        tfDdf.setText(String.valueOf(config.getDisappearanceDecayFactor()));
        tfDt.setText(String.valueOf(config.getDisappearanceThreshold()));
        cbDld.setState(config.isDisableLocalDiffusionModel());
        cbDim.setState(config.isDisableIntensityModel());
    });
    gd.addCheckbox("Save_traces", settings.getSaveTraces());
    gd.addCheckbox("Show_histograms", settings.getShowHistograms());
    gd.addCheckbox("Save_trace_data", settings.getSaveTraceData());
    gd.showDialog();
    if (gd.wasCanceled() || !readDynamicTraceDialog(gd)) {
        return false;
    }
    // Load the results
    results = ResultsManager.loadInputResults(pluginSettings.inputOption, true, null, null);
    if (MemoryPeakResults.isEmpty(results)) {
        IJ.error(pluginTitle, "No results could be loaded");
        IJ.showStatus("");
        return false;
    }
    // Store exposure time in seconds
    exposureTime = results.getCalibrationReader().getExposureTime() / 1000;
    return true;
}
Also used : DmttConfiguration(uk.ac.sussex.gdsc.smlm.results.DynamicMultipleTargetTracing.DmttConfiguration) Checkbox(java.awt.Checkbox) TextField(java.awt.TextField) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)

Example 87 with ExtendedGenericDialog

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

the class TrackPopulationAnalysis method showHasCategoryDialog.

private static boolean showHasCategoryDialog(List<MemoryPeakResults> combinedResults) {
    // Check if all results have a category
    if (combinedResults.stream().filter(MemoryPeakResults::hasCategory).count() == combinedResults.size()) {
        final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
        gd.addHelp(HelpUrls.getUrl("track-population-analysis"));
        gd.addMessage("Input results contain categories.\n \nUse the categories as the track sub-populations?");
        gd.enableYesNoCancel();
        gd.hideCancelButton();
        gd.showDialog();
        return gd.wasOKed();
    }
    return false;
}
Also used : MemoryPeakResults(uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults) NonBlockingExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.NonBlockingExtendedGenericDialog) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)

Example 88 with ExtendedGenericDialog

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

the class TrackPopulationAnalysis method showDialog.

private boolean showDialog(boolean hasCategory) {
    final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
    gd.addHelp(HelpUrls.getUrl("track-population-analysis"));
    gd.addSlider("Window", 5, 20, settings.window);
    gd.addSlider("Min_track_length", 2, 20, settings.minTrackLength);
    gd.addMessage("Anomalous diffusion coefficient");
    gd.addNumericField("Fit_significance", settings.significance, -2);
    gd.addNumericField("Min_alpha", settings.minAlpha, -3);
    gd.addNumericField("Max_alpha", settings.maxAlpha, -3);
    if (!hasCategory) {
        gd.addMessage("Multi-variate Gaussian mixture Expectation-Maximisation");
        gd.addCheckbox("Ignore_alpha", settings.ignoreAlpha);
        gd.addSlider("Max_components", 2, 10, settings.maxComponents);
        gd.addSlider("Min_weight", 0.01, 1, settings.minWeight);
        gd.addNumericField("Max_iterations", settings.maxIterations, 0);
        gd.addNumericField("Relative_error", settings.relativeError, -1);
        gd.addNumericField("Repeats", settings.repeats, 0);
        gd.addNumericField("Seed", settings.seed, 0);
        gd.addCheckbox("Debug", settings.debug);
    }
    gd.addMessage("Output options");
    gd.addNumericField("Histogram_bins", settings.histogramBins, 0);
    gd.addChoice("LUT", LutHelper.getLutNames(), settings.lutIndex);
    gd.showDialog();
    if (gd.wasCanceled()) {
        return false;
    }
    settings.window = (int) gd.getNextNumber();
    settings.minTrackLength = (int) gd.getNextNumber();
    settings.significance = gd.getNextNumber();
    settings.minAlpha = gd.getNextNumber();
    settings.maxAlpha = gd.getNextNumber();
    if (!hasCategory) {
        settings.ignoreAlpha = gd.getNextBoolean();
        settings.maxComponents = (int) gd.getNextNumber();
        settings.minWeight = gd.getNextNumber();
        settings.maxIterations = (int) gd.getNextNumber();
        settings.relativeError = gd.getNextNumber();
        settings.repeats = (int) gd.getNextNumber();
        settings.seed = (int) gd.getNextNumber();
        settings.debug = gd.getNextBoolean();
    }
    settings.histogramBins = (int) gd.getNextNumber();
    settings.lutIndex = gd.getNextChoiceIndex();
    if (gd.invalidNumber()) {
        return false;
    }
    // Check arguments
    try {
        // For fitting the alpha coefficient there should be:
        // (number of parameters) < (number of points)
        // where the number of points is the window size minus 1.
        ParameterUtils.isEqualOrAbove("Window", settings.window, 5);
        ParameterUtils.isEqualOrAbove("Min track length", settings.minTrackLength, 2);
        if (!hasCategory) {
            ParameterUtils.isEqualOrAbove("Max components", settings.maxComponents, 2);
            ParameterUtils.isPositive("Min weight", settings.minWeight);
            ParameterUtils.isAboveZero("Max iterations", settings.maxIterations);
            ParameterUtils.isAboveZero("Maximum N", settings.relativeError);
            ParameterUtils.isAboveZero("Repeats", settings.repeats);
        }
    } 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)

Example 89 with ExtendedGenericDialog

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

the class SplitResults method run.

@Override
public void run(String arg) {
    SmlmUsageTracker.recordPlugin(this.getClass(), arg);
    if (MemoryPeakResults.isMemoryEmpty()) {
        IJ.error(TITLE, "There are no fitting results in memory");
        return;
    }
    final String[] items = ImageJUtils.getImageList(ImageJUtils.GREY_8_16);
    if (items.length == 0) {
        IJ.error(TITLE, "There are no suitable mask images");
        return;
    }
    settings = Settings.load();
    // Show a dialog allowing the results set to be filtered
    final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
    gd.addMessage("Select a dataset to split");
    ResultsManager.addInput(gd, settings.inputOption, InputSource.MEMORY);
    gd.addChoice("Object_mask", items, settings.objectMask);
    gd.addCheckbox("Show_object_mask", settings.showObjectMask);
    gd.addCheckbox("Non_mask_dataset", settings.nonMaskDataset);
    gd.addHelp(HelpUrls.getUrl("split-results"));
    gd.showDialog();
    if (gd.wasCanceled()) {
        return;
    }
    settings.inputOption = ResultsManager.getInputSource(gd);
    settings.objectMask = gd.getNextChoice();
    settings.showObjectMask = gd.getNextBoolean();
    settings.nonMaskDataset = gd.getNextBoolean();
    settings.save();
    final MemoryPeakResults results = ResultsManager.loadInputResults(settings.inputOption, false, null, null);
    if (MemoryPeakResults.isEmpty(results)) {
        IJ.error(TITLE, "No results could be loaded");
        return;
    }
    final ImagePlus imp = WindowManager.getImage(settings.objectMask);
    if (imp == null) {
        IJ.error(TITLE, "No object mask could be found");
        return;
    }
    splitResults(results, imp.getProcessor());
}
Also used : MemoryPeakResults(uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog) ImagePlus(ij.ImagePlus)

Example 90 with ExtendedGenericDialog

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

the class SpotInspector method showDialog.

private boolean showDialog() {
    final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
    gd.addHelp(HelpUrls.getUrl("spot-inspector"));
    settings = Settings.load();
    ResultsManager.addInput(gd, settings.inputOption, InputSource.MEMORY);
    gd.addChoice("Ranking", Settings.SORT_ORDER, settings.sortOrderIndex);
    gd.addSlider("Radius", 1, 15, settings.radius);
    gd.addCheckbox("Calibrated_table", settings.showCalibratedValues);
    gd.addCheckbox("Plot_score", settings.plotScore);
    gd.addCheckbox("Plot_histogram", settings.plotHistogram);
    gd.addNumericField("Histogram_bins", settings.histogramBins, 0);
    gd.addCheckbox("Remove_outliers", settings.removeOutliers);
    gd.showDialog();
    if (gd.wasCanceled()) {
        return false;
    }
    settings.inputOption = ResultsManager.getInputSource(gd);
    settings.sortOrderIndex = gd.getNextChoiceIndex();
    settings.radius = (int) gd.getNextNumber();
    settings.showCalibratedValues = gd.getNextBoolean();
    settings.plotScore = gd.getNextBoolean();
    settings.plotHistogram = gd.getNextBoolean();
    settings.histogramBins = (int) gd.getNextNumber();
    settings.removeOutliers = gd.getNextBoolean();
    settings.save();
    // Check arguments
    try {
        ParameterUtils.isAboveZero("Radius", settings.radius);
    } catch (final IllegalArgumentException ex) {
        IJ.error(TITLE, ex.getMessage());
        return false;
    }
    return true;
}
Also used : 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