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;
}
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;
}
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;
}
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();
}
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;
}
Aggregations