Search in sources :

Example 41 with ExtendedGenericDialog

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

the class EmGainAnalysis method showPmfDialog.

private boolean showPmfDialog() {
    final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
    gd.addHelp(HelpUrls.getUrl("em-gain-pmf"));
    gd.addMessage("Plot the probability mass function for EM-gain");
    gd.addNumericField("Gain", settings.settingGain, 2, 6, "Count/electron");
    gd.addNumericField("Noise", settings.settingNoise, 2, 6, "Count");
    gd.addNumericField("Photons", settings.settingPhotons, 2);
    gd.addChoice("Approx", Settings.APPROXIMATION_TYPE, settings.approximationType);
    gd.addCheckbox("Show_approximation", settings.showApproximation);
    if (extraOptions) {
        gd.addNumericField("Approximation_offset (%)", settings.settingOffset, 2);
    }
    gd.addNumericField("Remove_head", settings.head, 3);
    gd.addNumericField("Remove_tail", settings.tail, 3);
    gd.addCheckbox("Relative_delta", settings.relativeDelta);
    gd.showDialog();
    if (gd.wasCanceled()) {
        return false;
    }
    settings.settingGain = gd.getNextNumber();
    settings.settingNoise = Math.abs(gd.getNextNumber());
    settings.settingPhotons = Math.abs(gd.getNextNumber());
    settings.approximationType = gd.getNextChoiceIndex();
    settings.showApproximation = gd.getNextBoolean();
    if (extraOptions) {
        settings.settingOffset = gd.getNextNumber();
    }
    settings.head = Math.abs(gd.getNextNumber());
    settings.tail = Math.abs(gd.getNextNumber());
    settings.relativeDelta = gd.getNextBoolean();
    settings.save();
    return (!gd.invalidNumber() && settings.settingBias >= 0 && settings.settingGain >= 1 && settings.settingPhotons != 0 && settings.tail <= 0.5 && settings.head <= 0.5);
}
Also used : ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)

Example 42 with ExtendedGenericDialog

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

the class FilterResults method showDialog.

private boolean showDialog() {
    final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
    gd.addHelp(HelpUrls.getUrl("filter-results"));
    filterSettings = SettingsManager.readGuiFilterSettings(0).toBuilder();
    checkLimits();
    gd.addSlider("Max_drift", minDrift, maxDrift, filterSettings.getMaxDrift());
    gd.addSlider("Min_Signal", minSignal, maxSignal, filterSettings.getMinSignal());
    gd.addSlider("Min_SNR", minSnr, maxSnr, filterSettings.getMinSnr());
    gd.addSlider("Min_Precision", minPrecision, maxPrecision, filterSettings.getMaxPrecision());
    // TODO - If calibrated present the widths in nm
    gd.addMessage("Average Width = " + IJ.d2s(averageWidth, 3));
    gd.addSlider("Min_Width", minWidth, maxWidth, filterSettings.getMinWidth());
    gd.addSlider("Max_Width", minWidth, maxWidth, filterSettings.getMaxWidth());
    // Get a list of potential mask images
    final String[] items = getImageList();
    gd.addChoice("Mask", items, filterSettings.getMaskTitle());
    gd.showDialog();
    if (gd.wasCanceled()) {
        return false;
    }
    filterSettings.setMaxDrift((float) gd.getNextNumber());
    filterSettings.setMinSignal((float) gd.getNextNumber());
    filterSettings.setMinSnr((float) gd.getNextNumber());
    filterSettings.setMaxPrecision((float) gd.getNextNumber());
    filterSettings.setMinWidth((float) gd.getNextNumber());
    filterSettings.setMaxWidth((float) gd.getNextNumber());
    filterSettings.setMaskTitle(gd.getNextChoice());
    return SettingsManager.writeSettings(filterSettings.build());
}
Also used : ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)

Example 43 with ExtendedGenericDialog

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

the class FilterResults 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;
    }
    String inputOption = inputOptionRef.get();
    // Show a dialog allowing the results set to be filtered
    final 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);
    inputOptionRef.set(inputOption);
    results = ResultsManager.loadInputResults(inputOption, false, null, null);
    if (MemoryPeakResults.isEmpty(results)) {
        IJ.error(TITLE, "No results could be loaded");
        IJ.showStatus("");
        return;
    }
    if (!analyseResults()) {
        return;
    }
    if (!showDialog()) {
        return;
    }
    filterResults();
}
Also used : ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)

Example 44 with ExtendedGenericDialog

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

the class DrawClusters method showDialog.

private boolean showDialog() {
    final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
    final ArrayList<String> titles = new ArrayList<>(WindowManager.getImageCount());
    titles.add("[None]");
    final int[] idList = WindowManager.getIDList();
    if (idList != null) {
        for (final int id : idList) {
            final ImagePlus imp = WindowManager.getImage(id);
            if (imp != null) {
                titles.add(imp.getTitle());
            }
        }
    }
    settings = Settings.load();
    gd.addMessage("Draw the clusters on an image");
    ResultsManager.addInput(gd, "Input", settings.inputOption, InputSource.MEMORY_CLUSTERED);
    gd.addChoice("Image", titles.toArray(new String[0]), settings.title);
    gd.addNumericField("Image_size", settings.imageSize, 0);
    gd.addCheckbox("Expand_to_singles", settings.expandToSingles);
    gd.addSlider("Min_size", 1, 15, settings.minSize);
    gd.addSlider("Max_size", 0, 20, settings.maxSize);
    gd.addCheckbox("Traces (draw lines)", settings.drawLines);
    gd.addChoice("Sort", sorts, sorts[settings.sort]);
    gd.addCheckbox("Spline_fit (traces only)", settings.splineFit);
    gd.addCheckbox("Use_stack_position", settings.useStackPosition);
    gd.addChoice("LUT", LutHelper.getLutNames(), settings.lut);
    gd.addSlider("Line_width", 0, 0.5, settings.lineWidth);
    gd.addHelp(HelpUrls.getUrl("draw-clusters"));
    gd.showDialog();
    if (gd.wasCanceled()) {
        return false;
    }
    settings.inputOption = ResultsManager.getInputSource(gd);
    settings.title = gd.getNextChoice();
    settings.imageSize = (int) Math.abs(gd.getNextNumber());
    settings.expandToSingles = gd.getNextBoolean();
    settings.minSize = (int) Math.abs(gd.getNextNumber());
    settings.maxSize = (int) Math.abs(gd.getNextNumber());
    settings.drawLines = gd.getNextBoolean();
    settings.sort = gd.getNextChoiceIndex();
    settings.splineFit = gd.getNextBoolean();
    settings.useStackPosition = gd.getNextBoolean();
    settings.lut = gd.getNextChoiceIndex();
    settings.lineWidth = (float) gd.getNextNumber();
    settings.save();
    return true;
}
Also used : ArrayList(java.util.ArrayList) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog) ImagePlus(ij.ImagePlus)

Example 45 with ExtendedGenericDialog

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

the class BenchmarkFilterAnalysis method showDialog.

private boolean showDialog(int optimiseParameters) {
    final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
    final boolean showOptimiseFilter = (optimiseParameters & FLAG_OPTIMISE_FILTER) != 0;
    final boolean showOptimiseParams = (optimiseParameters & FLAG_OPTIMISE_PARAMS) != 0;
    final String helpKey = showOptimiseParams ? "benchmark-filter-parameters" : "benchmark-filter-analysis";
    addSimulationData(gd);
    // TODO - Make minimal filter configurable?
    gd.addSlider("Fail_count", 0, 20, settings.failCount);
    if (showOptimiseParams) {
        gd.addNumericField("Min_fail_count", settings.minFailCount, 0);
        gd.addNumericField("Max_fail_count", settings.maxFailCount, 0);
    }
    if (computeDoublets) {
        gd.addSlider("Residuals_threshold", 0.01, 1, settings.residualsThreshold);
        if (showOptimiseParams) {
            gd.addNumericField("Min_residuals_threshold", settings.minResidualsThreshold, 2);
            gd.addNumericField("Max_residuals_threshold", settings.maxResidualsThreshold, 2);
        }
    }
    final FitEngineConfiguration tmp = new FitEngineConfiguration();
    tmp.setDuplicateDistance(settings.duplicateDistance);
    tmp.setDuplicateDistanceAbsolute(settings.duplicateDistanceAbsolute);
    PeakFit.addDuplicateDistanceOptions(gd, new PeakFit.SimpleFitEngineConfigurationProvider(tmp));
    if (showOptimiseParams) {
        gd.addNumericField("Min_duplicate_distance", settings.minDuplicateDistance, 2);
        gd.addNumericField("Max_duplicate_distance", settings.maxDuplicateDistance, 2);
    }
    gd.addCheckbox("Reset", settings.reset);
    gd.addCheckbox("Show_table", settings.showResultsTable);
    gd.addCheckbox("Show_summary", settings.showSummaryTable);
    gd.addCheckbox("Clear_tables", settings.clearTables);
    gd.addSlider("Summary_top_n", 0, 20, settings.summaryTopN);
    gd.addNumericField("Summary_depth (nm)", settings.summaryDepth, 0);
    gd.addSlider("Plot_top_n", 0, 20, settings.plotTopN);
    gd.addCheckbox("Save_best_filter", settings.saveBestFilter);
    gd.addCheckbox("Save_template", settings.saveTemplate);
    gd.addCheckbox("Calculate_sensitivity", settings.calculateSensitivity);
    gd.addSlider("Delta", 0.01, 1, settings.delta);
    gd.addMessage("Match scoring");
    gd.addChoice("Criteria", Settings.COLUMNS, settings.criteriaIndex);
    gd.addNumericField("Criteria_limit", settings.criteriaLimit, 4);
    gd.addChoice("Score", Settings.COLUMNS, settings.scoreIndex);
    ImageJUtils.addMessage(gd, "Fitting match distance = %s nm; signal factor = %s", MathUtils.rounded(spotFitResults.distanceInPixels * simulationParameters.pixelPitch), MathUtils.rounded(fitSignalFactor));
    gd.addSlider("Upper_match_distance (%)", 0, 100, settings.upperMatchDistance);
    gd.addSlider("Partial_match_distance (%)", 0, 100, settings.partialMatchDistance);
    gd.addSlider("Upper_signal_factor (%)", 0, 100, settings.upperSignalFactor);
    gd.addSlider("Partial_signal_factor (%)", 0, 100, settings.partialSignalFactor);
    if (!simulationParameters.fixedDepth) {
        gd.addCheckbox("Depth_recall_analysis", settings.depthRecallAnalysis);
    }
    gd.addCheckbox("Score_analysis", settings.scoreAnalysis);
    gd.addChoice("Component_analysis", Settings.COMPONENT_ANALYSIS_OPTIONS, settings.componentAnalysis);
    if (showOptimiseFilter) {
        gd.addChoice("Evolve", Settings.EVOLVE_OPTIONS, settings.evolve);
        gd.addCheckbox("Repeat_evolve", settings.repeatEvolve);
    }
    if (showOptimiseParams) {
        gd.addChoice("Search", Settings.SEARCH_OPTIONS, settings.searchParam);
        gd.addCheckbox("Repeat_search", settings.repeatSearch);
    }
    gd.addStringField("Title", settings.resultsTitle, 20);
    final String[] labels = { "Show_TP", "Show_FP", "Show_FN" };
    gd.addCheckboxGroup(1, 3, labels, new boolean[] { settings.showTP, settings.showFP, settings.showFN });
    gd.addHelp(HelpUrls.getUrl(helpKey));
    gd.showDialog();
    if (gd.wasCanceled() || !readDialog(gd, optimiseParameters, tmp)) {
        return false;
    }
    if (!selectTableColumns()) {
        return false;
    }
    // We may have to read the results again if the ranking option has changed.
    // Also we must read the results with the maximum duplicate distance we may encounter.
    final double dd = settings.duplicateDistance;
    if (showOptimiseParams) {
        settings.duplicateDistance = settings.maxDuplicateDistance;
    }
    readResults();
    settings.duplicateDistance = dd;
    return true;
}
Also used : FitEngineConfiguration(uk.ac.sussex.gdsc.smlm.engine.FitEngineConfiguration) PeakFit(uk.ac.sussex.gdsc.smlm.ij.plugins.PeakFit) 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