Search in sources :

Example 51 with ExtendedGenericDialog

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

the class TraceMolecules method showHistogramsDialog.

private boolean showHistogramsDialog() {
    if (settings.getShowHistograms()) {
        final ExtendedGenericDialog gd = new ExtendedGenericDialog(pluginTitle);
        gd.addMessage("Select the histograms to display");
        gd.addCheckbox("Remove_outliers", settings.getRemoveOutliers());
        gd.addNumericField("Histogram_bins", settings.getHistogramBins(), 0);
        for (int i = 0; i < pluginSettings.displayHistograms.length; i++) {
            gd.addCheckbox(NAMES[i].replace(' ', '_'), pluginSettings.displayHistograms[i]);
        }
        gd.showDialog();
        if (gd.wasCanceled()) {
            return false;
        }
        settings.setRemoveOutliers(gd.getNextBoolean());
        settings.setHistogramBins((int) Math.abs(gd.getNextNumber()));
        for (int i = 0; i < pluginSettings.displayHistograms.length; i++) {
            pluginSettings.displayHistograms[i] = gd.getNextBoolean();
        }
        writeSettings();
    }
    return true;
}
Also used : ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog) ClusterPoint(uk.ac.sussex.gdsc.core.clustering.ClusterPoint)

Example 52 with ExtendedGenericDialog

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

the class TraceMolecules method showDialog.

private boolean showDialog() {
    pluginTitle = outputName + " Molecules";
    final ExtendedGenericDialog gd = new ExtendedGenericDialog(pluginTitle);
    gd.addHelp(HelpUrls.getUrl("trace-molecules"));
    readSettings();
    ResultsManager.addInput(gd, pluginSettings.inputOption, InputSource.MEMORY);
    gd.addNumericField("Distance_Threshold", settings.getDistanceThreshold(), 2, 6, "nm");
    gd.addNumericField("Distance_Exclusion", settings.getDistanceExclusion(), 2, 6, "nm");
    gd.addNumericField("Time_Threshold", settings.getTimeThreshold(), 2);
    gd.addChoice("Time_unit", SettingsManager.getTimeUnitNames(), settings.getTimeUnit().ordinal());
    final String[] traceModes = SettingsManager.getNames((Object[]) TraceManager.TraceMode.values());
    gd.addChoice("Trace_mode", traceModes, traceModes[getTraceMode(settings.getTraceMode()).ordinal()]);
    gd.addNumericField("Pulse_interval", settings.getPulseInterval(), 0, 6, "Frames");
    gd.addNumericField("Pulse_window", settings.getPulseWindow(), 0, 6, "Frames");
    gd.addCheckbox("Split_pulses", settings.getSplitPulses());
    gd.addCheckbox("Optimise", settings.getOptimise());
    gd.addCheckbox("Save_traces", settings.getSaveTraces());
    gd.addCheckbox("Show_histograms", settings.getShowHistograms());
    gd.addCheckbox("Save_trace_data", settings.getSaveTraceData());
    if (altKeyDown) {
        gd.addCheckbox("Debug", pluginSettings.inputDebugMode);
    }
    gd.showDialog();
    if (gd.wasCanceled() || !readDialog(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 : ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)

Example 53 with ExtendedGenericDialog

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

the class TrackPopulationAnalysis method checkCalibration.

/**
 * Check the results have a calibrated exposure time and pixel pitch. If not then show a dialog to
 * collect the calibration.
 *
 * @param results the results
 * @return True if calibrated
 */
private static boolean checkCalibration(MemoryPeakResults results) {
    if (results.getCalibration() == null || !results.getCalibrationReader().hasExposureTime() || !results.getCalibrationReader().hasNmPerPixel()) {
        final CalibrationWriter cal = results.getCalibrationWriterSafe();
        final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
        gd.addMessage("Uncalibrated results! Please enter the calibration:");
        gd.addNumericField("Exposure_time", cal.getExposureTime(), 2, 6, "ms");
        gd.addNumericField("Pixel_pitch", cal.getNmPerPixel(), 2, 6, "nm");
        gd.showDialog();
        if (gd.wasCanceled() || gd.invalidNumber()) {
            return false;
        }
        cal.setExposureTime(gd.getNextNumber());
        cal.setNmPerPixel(gd.getNextNumber());
        if (cal.getExposureTime() <= 0 || cal.getNmPerPixel() <= 0) {
            return false;
        }
        results.setCalibration(cal.getCalibration());
    }
    return true;
}
Also used : CalibrationWriter(uk.ac.sussex.gdsc.smlm.data.config.CalibrationWriter) NonBlockingExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.NonBlockingExtendedGenericDialog) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)

Example 54 with ExtendedGenericDialog

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

the class BenchmarkSmartSpotRanking method showDialog.

private boolean showDialog() {
    ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
    gd.addHelp(HelpUrls.getUrl("smart-spot-ranking"));
    settings = Settings.load();
    config = configRef.get().createCopy();
    ImageJUtils.addMessage(gd, "Rank candidate spots in the benchmark image created by " + CreateData.TITLE + " plugin\nand identified by the " + BenchmarkSpotFilter.TITLE + " plugin.\nPSF width = %s nm (Square pixel adjustment = %s nm)\n \n" + "Configure the fitting:", MathUtils.rounded(simulationParameters.sd), MathUtils.rounded(getSa()));
    gd.addSlider("Fraction_positives", 50, 100, settings.fractionPositives);
    gd.addSlider("Fraction_negatives_after_positives", 0, 100, settings.fractionNegativesAfterAllPositives);
    gd.addSlider("Min_negatives_after_positives", 0, 10, settings.negativesAfterAllPositives);
    gd.addCheckbox("Select_methods", settings.selectMethods);
    gd.addNumericField("Compact_bins", settings.compactBins, 0);
    gd.addChoice("Sort", Settings.sortMethods, settings.sortIndex);
    gd.addCheckbox("Use_fraction_scores", settings.useFractionScores);
    // Collect options for fitting that may effect ranking
    final double sa = getSa();
    gd.addNumericField("Initial_StdDev", sa / simulationParameters.pixelPitch, 3);
    gd.addSlider("Fitting_width", 2, 4.5, config.getFitting());
    // Output options
    gd.addCheckbox("Show_overlay", settings.showOverlay);
    if (extraOptions) {
        gd.addChoice("Noise_method", SettingsManager.getNoiseEstimatorMethodNames(), config.getNoiseMethod().getNumber());
    }
    gd.showDialog();
    if (gd.wasCanceled()) {
        return false;
    }
    settings.fractionPositives = Math.abs(gd.getNextNumber());
    settings.fractionNegativesAfterAllPositives = Math.abs(gd.getNextNumber());
    settings.negativesAfterAllPositives = (int) Math.abs(gd.getNextNumber());
    settings.selectMethods = gd.getNextBoolean();
    settings.compactBins = (int) Math.abs(gd.getNextNumber());
    settings.sortIndex = gd.getNextChoiceIndex();
    settings.useFractionScores = gd.getNextBoolean();
    // Collect options for fitting that may effect ranking
    config.getFitConfiguration().setInitialPeakStdDev(gd.getNextNumber());
    config.setFitting(gd.getNextNumber());
    settings.showOverlay = gd.getNextBoolean();
    if (extraOptions) {
        config.setNoiseMethod(SettingsManager.getNoiseEstimatorMethodValues()[gd.getNextChoiceIndex()]);
    }
    settings.save();
    configRef.set(config);
    if (gd.invalidNumber()) {
        return false;
    }
    methodNames = Settings.thresholdMethodNames.clone();
    if (settings.selectMethods) {
        int count = 0;
        int count1 = 0;
        int count2 = 0;
        methods = new AutoThreshold.Method[Settings.thresholdMethods.length];
        levels = new double[Settings.snrLevels.length];
        gd = new ExtendedGenericDialog(TITLE);
        gd.addHelp(HelpUrls.getUrl("smart-spot-ranking"));
        for (int i = 0; i < Settings.thresholdMethodNames.length; i++) {
            gd.addCheckbox(Settings.thresholdMethodNames[i], settings.thresholdMethodOptions[i]);
        }
        gd.showDialog();
        if (gd.wasCanceled()) {
            return false;
        }
        for (int i = 0, j = 0; i < Settings.thresholdMethodNames.length; i++) {
            settings.thresholdMethodOptions[i] = gd.getNextBoolean();
            if (settings.thresholdMethodOptions[i]) {
                methodNames[count++] = Settings.thresholdMethodNames[i];
                if (i < Settings.thresholdMethods.length) {
                    methods[count1++] = Settings.thresholdMethods[i];
                } else {
                    levels[count2++] = Settings.snrLevels[j++];
                }
            }
        }
        methodNames = Arrays.copyOf(methodNames, count);
        methods = Arrays.copyOf(methods, count1);
        levels = Arrays.copyOf(levels, count2);
    } else {
        // Do them all
        methods = Settings.thresholdMethods.clone();
        levels = Settings.snrLevels.clone();
    }
    if (methodNames.length == 0) {
        IJ.error(TITLE, "No methods selected");
        return false;
    }
    return true;
}
Also used : ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog) PeakResultPoint(uk.ac.sussex.gdsc.smlm.results.PeakResultPoint) AutoThreshold(uk.ac.sussex.gdsc.core.threshold.AutoThreshold)

Example 55 with ExtendedGenericDialog

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

the class TraceDiffusion method showDialog.

private boolean showDialog() {
    final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
    gd.addHelp(HelpUrls.getUrl("trace-diffusion"));
    clusteringSettings = SettingsManager.readClusteringSettings(0).toBuilder();
    gd.addCheckbox("Truncate_traces", clusteringSettings.getTruncate());
    gd.addCheckbox("Internal_distances", clusteringSettings.getInternalDistances());
    // gd.addCheckbox("Sub-sample_distances", settings.subSampledDistances);
    gd.addSlider("Fit_length", 2, 20, clusteringSettings.getFitLength());
    gd.addCheckbox("MSD_correction", clusteringSettings.getMsdCorrection());
    gd.addCheckbox("Precision_correction", clusteringSettings.getPrecisionCorrection());
    gd.addCheckbox("Maximum_likelihood", clusteringSettings.getMle());
    gd.addSlider("MLE_significance_level", 0, 0.5, settings.significanceLevel);
    gd.addSlider("Fit_restarts", 0, 10, clusteringSettings.getFitRestarts());
    gd.addSlider("Jump_distance", 1, 20, clusteringSettings.getJumpDistance());
    gd.addSlider("Minimum_difference", 0, 10, settings.minDifference);
    gd.addSlider("Minimum_fraction", 0, 1, settings.minFraction);
    if (extraOptions) {
        gd.addSlider("Minimum_N", 1, 10, settings.minN);
    }
    gd.addSlider("Maximum_N", 2, 10, settings.maxN);
    gd.addCheckbox("Debug_fitting", settings.debugFitting);
    gd.addCheckbox("Save_trace_distances", settings.saveTraceDistances);
    gd.addCheckbox("Save_raw_data", settings.saveRawData);
    gd.addCheckbox("Show_histograms", clusteringSettings.getShowHistograms());
    gd.addStringField("Title", settings.title);
    gd.showDialog();
    if (gd.wasCanceled() || !readDialog(gd)) {
        return false;
    }
    // Update the settings
    SettingsManager.writeSettings(clusteringSettings.build());
    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