Search in sources :

Example 46 with GenericDialog

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

the class PCPALMFitting method selectNextCorrelation.

private boolean selectNextCorrelation(ArrayList<CorrelationResult> results) {
    ArrayList<String> titles = buildTitlesList(results);
    // Show a dialog allowing the user to select an input image
    if (titles.isEmpty())
        return false;
    GenericDialog gd = new GenericDialog(TITLE);
    gd.addHelp(About.HELP_URL);
    gd.addMessage("Select the next correlation curve\nFrequency domain curves are identified with *");
    int n = (results.size() + 1);
    if (IJ.isMacro())
        // Use blank default value so bad macro parameters return nothing
        gd.addStringField("R_" + n, "");
    else
        gd.addChoice("R_" + n, titles.toArray(new String[titles.size()]), "");
    gd.addMessage("Cancel to finish");
    gd.showDialog();
    if (gd.wasCanceled())
        return false;
    String title;
    if (IJ.isMacro())
        title = gd.getNextString();
    else
        title = gd.getNextChoice();
    // Check the correlation exists. If not then exit. This is mainly relevant for Macro mode since
    // the loop will continue otherwise since the titles list is not empty.
    String[] fields = title.split("\\*?:");
    try {
        int id = Integer.parseInt(fields[0]);
        for (CorrelationResult r : PCPALMAnalysis.results) {
            if (r.id == id) {
                results.add(r);
                return true;
            }
        }
    } catch (NumberFormatException e) {
    }
    return false;
}
Also used : GenericDialog(ij.gui.GenericDialog)

Example 47 with GenericDialog

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

the class PCPALMFitting method showDialog.

private boolean showDialog() {
    GenericDialog gd = new GenericDialog(TITLE);
    gd.addHelp(About.HELP_URL);
    // Build a list of results to use in the analysis
    if (!getCorrelationResults())
        return false;
    if (spatialDomain) {
        // Spatial domain results are just combined to a curve
        // Add option to save the results curve
        gd.addMessage("Options:");
        gd.addCheckbox("Save_correlation_curve", saveCorrelationCurve);
        gd.showDialog();
        if (gd.wasCanceled())
            return false;
        saveCorrelationCurve = gd.getNextBoolean();
        return true;
    }
    if (estimatedPrecision < 0 || copiedEstimatedPrecision != PCPALMMolecules.sigmaS) {
        copiedEstimatedPrecision = estimatedPrecision = PCPALMMolecules.sigmaS;
    }
    if (blinkingRate < 0 || copiedBlinkingRate != PCPALMAnalysis.blinkingRate) {
        copiedBlinkingRate = blinkingRate = PCPALMAnalysis.blinkingRate;
    }
    gd.addMessage("Analyse clusters using Pair Correlation.");
    gd.addNumericField("Estimated_precision", estimatedPrecision, 2);
    gd.addNumericField("Blinking_rate", blinkingRate, 2);
    gd.addCheckbox("Show_error_bars", showErrorBars);
    gd.addSlider("Fit_restarts", 0, 5, fitRestarts);
    gd.addCheckbox("Refit_using_LSE", useLSE);
    gd.addSlider("Fit_above_estimated_precision", 0, 2.5, fitAboveEstimatedPrecision);
    gd.addSlider("Fitting_tolerance", 0, 200, fittingTolerance);
    gd.addSlider("gr_random_threshold", 1, 2.5, gr_protein_threshold);
    gd.addCheckbox("Fit_clustered_models", fitClusteredModels);
    gd.addCheckbox("Save_correlation_curve", saveCorrelationCurve);
    gd.showDialog();
    if (gd.wasCanceled())
        return false;
    estimatedPrecision = gd.getNextNumber();
    blinkingRate = gd.getNextNumber();
    showErrorBars = gd.getNextBoolean();
    fitRestarts = (int) Math.abs(gd.getNextNumber());
    useLSE = gd.getNextBoolean();
    fitAboveEstimatedPrecision = Math.abs(gd.getNextNumber());
    fittingTolerance = Math.abs(gd.getNextNumber());
    gr_protein_threshold = gd.getNextNumber();
    fitClusteredModels = gd.getNextBoolean();
    saveCorrelationCurve = gd.getNextBoolean();
    // Check arguments
    try {
        Parameters.isAbove("Correlation distance", correlationDistance, 1);
        Parameters.isAbove("Estimated precision", estimatedPrecision, 0);
        Parameters.isAbove("Blinking_rate", blinkingRate, 0);
        Parameters.isAbove("gr random threshold", gr_protein_threshold, 1);
    } catch (IllegalArgumentException ex) {
        IJ.error(TITLE, ex.getMessage());
        return false;
    }
    return true;
}
Also used : GenericDialog(ij.gui.GenericDialog)

Example 48 with GenericDialog

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

the class PCPALMMolecules method showPCPALMDialog.

private boolean showPCPALMDialog() {
    GenericDialog gd = new GenericDialog(TITLE);
    gd.addHelp(About.HELP_URL);
    gd.addMessage("Estimate the average localisation precision by fitting histograms.\nUse the precision to trace localisations into molecule pulses.");
    gd.addNumericField("Histogram_bins", histogramBins, 0);
    gd.addChoice("Singles_mode", singlesMode, singlesMode[singlesModeIndex]);
    gd.addCheckbox("Simplex_fit", simplexFitting);
    gd.addCheckbox("Show_histograms", showHistograms);
    gd.addCheckbox("Binary_image", binaryImage);
    gd.addNumericField("Blinking_rate", blinkingRate, 2);
    gd.showDialog();
    if (gd.wasCanceled())
        return false;
    histogramBins = (int) gd.getNextNumber();
    singlesModeIndex = gd.getNextChoiceIndex();
    simplexFitting = gd.getNextBoolean();
    showHistograms = gd.getNextBoolean();
    binaryImage = gd.getNextBoolean();
    blinkingRate = gd.getNextNumber();
    // Check arguments
    try {
        Parameters.isAbove("Histogram bins", histogramBins, 1);
        Parameters.isEqualOrAbove("Blinking rate", blinkingRate, 1);
    } catch (IllegalArgumentException ex) {
        IJ.error(TITLE, ex.getMessage());
        return false;
    }
    return true;
}
Also used : ExtendedGenericDialog(ij.gui.ExtendedGenericDialog) GenericDialog(ij.gui.GenericDialog)

Example 49 with GenericDialog

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

the class PCPALMMolecules method showSimulationDialog.

private boolean showSimulationDialog() {
    GenericDialog gd = new GenericDialog(TITLE);
    gd.addHelp(About.HELP_URL);
    gd.addMessage("Simulate a random distribution of molecules.");
    gd.addNumericField("Molecules", nMolecules, 0);
    gd.addNumericField("Simulation_size (um)", simulationSize, 2);
    gd.addNumericField("Blinking_rate", blinkingRate, 2);
    gd.addChoice("Blinking_distribution", BLINKING_DISTRIBUTION, BLINKING_DISTRIBUTION[blinkingDistribution]);
    gd.addNumericField("Average_precision (nm)", sigmaS, 2);
    gd.addCheckbox("Show_histograms", showHistograms);
    gd.addCheckbox("Distance_analysis", distanceAnalysis);
    gd.addChoice("Cluster_simulation", CLUSTER_SIMULATION, CLUSTER_SIMULATION[clusterSimulation]);
    gd.addNumericField("Cluster_number", clusterNumber, 2);
    gd.addNumericField("Cluster_variation (SD)", clusterNumberSD, 2);
    gd.addNumericField("Cluster_radius", clusterRadius, 2);
    gd.addCheckbox("Show_cluster_mask", showClusterMask);
    gd.showDialog();
    if (gd.wasCanceled())
        return false;
    nMolecules = (int) Math.abs(gd.getNextNumber());
    simulationSize = Math.abs(gd.getNextNumber());
    blinkingRate = Math.abs(gd.getNextNumber());
    blinkingDistribution = gd.getNextChoiceIndex();
    sigmaS = Math.abs(gd.getNextNumber());
    showHistograms = gd.getNextBoolean();
    distanceAnalysis = gd.getNextBoolean();
    clusterSimulation = gd.getNextChoiceIndex();
    clusterNumber = Math.abs(gd.getNextNumber());
    clusterNumberSD = Math.abs(gd.getNextNumber());
    clusterRadius = Math.abs(gd.getNextNumber());
    showClusterMask = gd.getNextBoolean();
    // Check arguments
    try {
        Parameters.isAboveZero("Molecules", nMolecules);
        Parameters.isAboveZero("Simulation size", simulationSize);
        Parameters.isEqualOrAbove("Blinking rate", blinkingRate, 1);
        Parameters.isEqualOrAbove("Cluster number", clusterNumber, 1);
    } catch (IllegalArgumentException ex) {
        IJ.error(TITLE, ex.getMessage());
        return false;
    }
    return getPValue();
}
Also used : ExtendedGenericDialog(ij.gui.ExtendedGenericDialog) GenericDialog(ij.gui.GenericDialog)

Example 50 with GenericDialog

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

the class PCPALMMolecules method getPValue.

private boolean getPValue() {
    if (blinkingDistribution == 3) {
        GenericDialog gd = new GenericDialog(TITLE);
        gd.addMessage("Binomial distribution requires a p-value");
        gd.addSlider("p-Value (%)", 0, 100, 100 * p);
        gd.showDialog();
        if (gd.wasCanceled())
            return false;
        p = FastMath.max(FastMath.min(gd.getNextNumber(), 100), 0) / 100;
    }
    return true;
}
Also used : ExtendedGenericDialog(ij.gui.ExtendedGenericDialog) 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