Search in sources :

Example 16 with GenericDialog

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

the class BenchmarkFilterAnalysis method selectTableColumns.

private boolean selectTableColumns() {
    if (showResultsTable || showSummaryTable) {
        GenericDialog gd = new GenericDialog(TITLE);
        gd.addHelp(About.HELP_URL);
        gd.addMessage("Select the results:");
        for (int i = 0; i < COLUMNS.length; i++) gd.addCheckbox(COLUMNS[i], showColumns[i]);
        gd.showDialog();
        if (gd.wasCanceled())
            return false;
        for (int i = 0; i < COLUMNS.length; i++) showColumns[i] = gd.getNextBoolean();
        requireIntegerResults = false;
        for (int i = 0; i < 7; i++) {
            if (showColumns[i]) {
                requireIntegerResults = true;
                break;
            }
        }
    }
    return true;
}
Also used : GenericDialog(ij.gui.GenericDialog) NonBlockingGenericDialog(ij.gui.NonBlockingGenericDialog)

Example 17 with GenericDialog

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

the class BenchmarkFilterAnalysis method expandFilters.

/**
	 * If filters have been provided in FiltersSets of 3 then expand the filters into a set assuming the three represent
	 * min:max:increment.
	 */
private void expandFilters() {
    // Do not clear these when reading a new set of filters. 
    // The filters may be the same with slight modifications and so it is useful to keep the last settings.
    //searchRangeMap.clear();
    //stepSizeMap.clear();
    long[] expanded = new long[filterList.size()];
    String[] name = new String[expanded.length];
    int c = 0;
    boolean doIt = false;
    for (FilterSet filterSet : filterList) {
        if (filterSet.size() == 3 && filterSet.allSameType()) {
            name[c] = filterSet.getName();
            // Check we have min:max:increment by counting the combinations
            Filter f1 = filterSet.getFilters().get(0);
            Filter f2 = filterSet.getFilters().get(1);
            Filter f3 = filterSet.getFilters().get(2);
            int n = f1.getNumberOfParameters();
            double[] parameters = new double[n];
            double[] parameters2 = new double[n];
            double[] increment = new double[n];
            for (int i = 0; i < n; i++) {
                parameters[i] = f1.getParameterValue(i);
                parameters2[i] = f2.getParameterValue(i);
                increment[i] = f3.getParameterValue(i);
            }
            long combinations = countCombinations(parameters, parameters2, increment);
            if (combinations > 1) {
                expanded[c] = combinations;
                doIt = true;
            }
        }
        c++;
    }
    if (!doIt)
        return;
    GenericDialog gd = new GenericDialog(TITLE);
    gd.hideCancelButton();
    StringBuilder sb = new StringBuilder("The filter file contains potential triples of min:max:increment.\n \n");
    for (c = 0; c < expanded.length; c++) {
        if (expanded[c] > 0) {
            sb.append("Expand set [").append((c + 1)).append("]");
            if (!Utils.isNullOrEmpty(name[c]))
                sb.append(" ").append(name[c]);
            sb.append(" to ").append(expanded[c]).append(" filters\n");
        }
    }
    gd.addMessage(sb.toString());
    gd.addCheckbox("Expand_filters", expandFilters);
    gd.showDialog();
    if (!gd.wasCanceled()) {
        if (!(expandFilters = gd.getNextBoolean()))
            return;
    }
    IJ.showStatus("Expanding filters ...");
    List<FilterSet> filterList2 = new ArrayList<FilterSet>(filterList.size());
    for (FilterSet filterSet : filterList) {
        c = filterList2.size();
        if (expanded[c] == 0) {
            filterList2.add(filterSet);
            continue;
        }
        Filter f1 = filterSet.getFilters().get(0);
        Filter f2 = filterSet.getFilters().get(1);
        Filter f3 = filterSet.getFilters().get(2);
        final int n = f1.getNumberOfParameters();
        double[] parameters = new double[n];
        double[] parameters2 = new double[n];
        double[] increment = new double[n];
        for (int i = 0; i < n; i++) {
            parameters[i] = f1.getParameterValue(i);
            parameters2[i] = f2.getParameterValue(i);
            increment[i] = f3.getParameterValue(i);
        }
        List<Filter> list = expandFilters(f1, parameters, parameters2, increment);
        filterList2.add(new FilterSet(filterSet.getName(), list));
    }
    IJ.showStatus("");
    filterList = filterList2;
    Utils.log("Expanded input to %d filters in %s", countFilters(filterList), Utils.pleural(filterList.size(), "set"));
}
Also used : FilterSet(gdsc.smlm.results.filter.FilterSet) ArrayList(java.util.ArrayList) IDirectFilter(gdsc.smlm.results.filter.IDirectFilter) DirectFilter(gdsc.smlm.results.filter.DirectFilter) Filter(gdsc.smlm.results.filter.Filter) MultiPathFilter(gdsc.smlm.results.filter.MultiPathFilter) MaximaSpotFilter(gdsc.smlm.filters.MaximaSpotFilter) GenericDialog(ij.gui.GenericDialog) NonBlockingGenericDialog(ij.gui.NonBlockingGenericDialog)

Example 18 with GenericDialog

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

the class BenchmarkFilterAnalysis method showReportDialog.

private boolean showReportDialog() {
    GenericDialog gd = new GenericDialog(TITLE);
    gd.addHelp(About.HELP_URL);
    addSimulationData(gd);
    gd.addCheckbox("Show_table", showResultsTable);
    gd.addCheckbox("Show_summary", showSummaryTable);
    gd.addCheckbox("Clear_tables", clearTables);
    gd.addSlider("Summary_top_n", 0, 20, summaryTopN);
    gd.addCheckbox("Save_best_filter", saveBestFilter);
    gd.addCheckbox("Save_template", saveTemplate);
    gd.addCheckbox("Calculate_sensitivity", calculateSensitivity);
    gd.addSlider("Delta", 0.01, 1, delta);
    if (!simulationParameters.fixedDepth)
        gd.addCheckbox("Depth_recall_analysis", depthRecallAnalysis);
    gd.addCheckbox("Score_analysis", scoreAnalysis);
    gd.addChoice("Component_analysis", COMPONENT_ANALYSIS, COMPONENT_ANALYSIS[componentAnalysis]);
    gd.addStringField("Title", resultsTitle, 20);
    String[] labels = { "Show_TP", "Show_FP", "Show_FN" };
    gd.addCheckboxGroup(1, 3, labels, new boolean[] { showTP, showFP, showFN });
    gd.showDialog();
    if (gd.wasCanceled())
        return false;
    showResultsTable = gd.getNextBoolean();
    showSummaryTable = gd.getNextBoolean();
    clearTables = gd.getNextBoolean();
    summaryTopN = (int) Math.abs(gd.getNextNumber());
    saveBestFilter = gd.getNextBoolean();
    saveTemplate = gd.getNextBoolean();
    calculateSensitivity = gd.getNextBoolean();
    delta = gd.getNextNumber();
    if (!simulationParameters.fixedDepth)
        depthRecallAnalysis = gd.getNextBoolean();
    scoreAnalysis = gd.getNextBoolean();
    componentAnalysis = gd.getNextChoiceIndex();
    resultsTitle = gd.getNextString();
    showTP = gd.getNextBoolean();
    showFP = gd.getNextBoolean();
    showFN = gd.getNextBoolean();
    if (gd.invalidNumber())
        return false;
    resultsPrefix = BenchmarkSpotFit.resultPrefix + "\t" + resultsTitle + "\t";
    createResultsPrefix2();
    // Check there is one output
    if (!showResultsTable && !showSummaryTable && !calculateSensitivity && !saveBestFilter && !saveTemplate) {
        IJ.error(TITLE, "No output selected");
        return false;
    }
    // Check arguments
    try {
        Parameters.isAboveZero("Delta", delta);
        Parameters.isBelow("Delta", delta, 1);
    } catch (IllegalArgumentException e) {
        IJ.error(TITLE, e.getMessage());
        return false;
    }
    if (!selectTableColumns())
        return false;
    return true;
}
Also used : GenericDialog(ij.gui.GenericDialog) NonBlockingGenericDialog(ij.gui.NonBlockingGenericDialog)

Example 19 with GenericDialog

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

the class PSFDrift method showHWHM.

private void showHWHM(List<String> titles) {
    GenericDialog gd = new GenericDialog(TITLE);
    gd.addMessage("Select the input PSF image");
    gd.addChoice("PSF", titles.toArray(new String[titles.size()]), title);
    gd.addCheckbox("Use_offset", useOffset);
    gd.addNumericField("Scale", scale, 2);
    gd.showDialog();
    if (gd.wasCanceled())
        return;
    title = gd.getNextChoice();
    useOffset = gd.getNextBoolean();
    scale = gd.getNextNumber();
    imp = WindowManager.getImage(title);
    if (imp == null) {
        IJ.error(TITLE, "No PSF image for image: " + title);
        return;
    }
    psfSettings = getPSFSettings(imp);
    if (psfSettings == null) {
        IJ.error(TITLE, "No PSF settings for image: " + title);
        return;
    }
    int size = imp.getStackSize();
    ImagePSFModel psf = createImagePSF(1, size);
    double[] w0 = psf.getAllHWHM0();
    double[] w1 = psf.getAllHWHM1();
    double[] slice = Utils.newArray(w0.length, 1, 1.0);
    // Widths are in pixels
    String title = TITLE + " HWHM";
    Plot plot = new Plot(title, "Slice", "HWHM (px)");
    double[] limits = Maths.limits(w0);
    limits = Maths.limits(limits, w1);
    plot.setLimits(1, size, 0, limits[1] * 1.05);
    plot.setColor(Color.red);
    plot.addPoints(slice, w0, Plot.LINE);
    plot.setColor(Color.blue);
    plot.addPoints(slice, w1, Plot.LINE);
    plot.setColor(Color.black);
    plot.addLabel(0, 0, "X=red; Y=blue");
    Utils.display(title, plot);
}
Also used : GenericDialog(ij.gui.GenericDialog) Plot(ij.gui.Plot) ImagePSFModel(gdsc.smlm.model.ImagePSFModel)

Example 20 with GenericDialog

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

the class PSFCombiner method run.

/*
	 * (non-Javadoc)
	 * 
	 * @see ij.plugin.PlugIn#run(java.lang.String)
	 */
public void run(String arg) {
    SMLMUsageTracker.recordPlugin(this.getClass(), arg);
    // Build a list of suitable images
    titles = createImageList();
    if (titles.isEmpty()) {
        IJ.error(TITLE, "No suitable PSF images");
        return;
    }
    try {
        while (selectNextImage()) ;
    } catch (Exception e) {
        IJ.error(TITLE, e.getMessage());
        return;
    }
    if (input.isEmpty()) {
        return;
    }
    if (input.size() < 2) {
        IJ.error(TITLE, "Require at least 2 PSF images to combine");
        return;
    }
    GenericDialog gd = new GenericDialog(TITLE);
    gd.addMessage("Set the maximum z-depth +/- from the PSF centre");
    gd.addSlider("Z-depth", 20, 200, zDepth);
    gd.showDialog();
    if (gd.wasCanceled())
        return;
    zDepth = Math.abs((int) gd.getNextNumber());
    for (PSF psf : input) psf.crop(zDepth);
    combineImages();
}
Also used : GenericDialog(ij.gui.GenericDialog)

Aggregations

GenericDialog (ij.gui.GenericDialog)87 NonBlockingGenericDialog (ij.gui.NonBlockingGenericDialog)12 ExtendedGenericDialog (ij.gui.ExtendedGenericDialog)10 GlobalSettings (gdsc.smlm.ij.settings.GlobalSettings)9 Checkbox (java.awt.Checkbox)9 Color (java.awt.Color)8 Component (java.awt.Component)8 GridBagConstraints (java.awt.GridBagConstraints)8 GridBagLayout (java.awt.GridBagLayout)8 Rectangle (java.awt.Rectangle)7 BasePoint (gdsc.core.match.BasePoint)6 FitConfiguration (gdsc.smlm.fitting.FitConfiguration)6 PeakResultPoint (gdsc.smlm.ij.plugins.ResultsMatchCalculator.PeakResultPoint)6 Calibration (gdsc.smlm.results.Calibration)6 ArrayList (java.util.ArrayList)6 PeakResult (gdsc.smlm.results.PeakResult)5 TextField (java.awt.TextField)5 File (java.io.File)5 Vector (java.util.Vector)5 FitEngineConfiguration (gdsc.smlm.engine.FitEngineConfiguration)4