use of java.awt.Checkbox in project GDSC-SMLM by aherbert.
the class FreeFilterResults method showDialog.
private boolean showDialog() {
final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
gd.addHelp(HelpUrls.getUrl("free-filter-results"));
gd.addMessage("Select a dataset to filter");
ResultsManager.addInput(gd, inputOptionRef.get(), InputSource.MEMORY);
filterSettings = SettingsManager.readGuiFilterSettings(0).toBuilder();
String text;
try {
text = uk.ac.sussex.gdsc.core.utils.XmlUtils.prettyPrintXml(filterSettings.getFreeFilter());
} catch (final Exception ex) {
text = filterSettings.getFreeFilter();
}
gd.addTextAreas(text, null, 20, 80);
gd.addCheckbox("Show_demo_filters", false);
if (ImageJUtils.isShowGenericDialog()) {
final Checkbox cb = (Checkbox) gd.getCheckboxes().get(0);
cb.addItemListener(this::itemStateChanged);
}
gd.showDialog();
if (gd.wasCanceled()) {
return false;
}
inputOption = ResultsManager.getInputSource(gd);
filterSettings.setFreeFilter(gd.getNextText());
final boolean demoFilters = gd.getNextBoolean();
if (demoFilters) {
logDemoFilters(TITLE);
return false;
}
inputOptionRef.set(inputOption);
return SettingsManager.writeSettings(filterSettings.build());
}
use of java.awt.Checkbox in project GDSC-SMLM by aherbert.
the class DoubletAnalysis method showAnalysisDialog.
/**
* Show analysis dialog.
*
* @return true, if successful
*/
private boolean showAnalysisDialog() {
final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
gd.addHelp(HelpUrls.getUrl("doublet-filter-analysis"));
settings = Settings.load();
config = configRef.get().createCopy();
final StringBuilder sb = new StringBuilder("Filters the doublet fits and reports the performance increase\n");
// Show the fitting settings that will effect filters, i.e. fit standard deviation, fit width
final FitConfiguration fitConfig = config.getFitConfiguration();
sb.append("SD0 = ").append(MathUtils.rounded(fitConfig.getInitialXSd())).append("\n");
// sb.append("SD1 =
// ").append(MathUtils.rounded(fitConfig.getInitialPeakStdDev1())).append("\n");
sb.append("Fit Width = ").append(config.getFittingWidth()).append("\n");
gd.addMessage(sb.toString());
// Collect options for filtering
gd.addChoice("Selection_Criteria", Settings.SELECTION_CRITERIAS, settings.selectionCriteria);
filterFitConfig = filterFitConfigRef.get().createCopy();
// Copy the settings used when fitting
filterFitConfig.setCalibration(fitConfig.getCalibration());
filterFitConfig.setPsf(fitConfig.getPsf());
filterFitConfig.setFitSolverSettings(fitConfig.getFitSolverSettings());
final String[] templates = ConfigurationTemplate.getTemplateNames(true);
gd.addChoice("Template", templates, templates[0]);
// Allow the settings from the benchmark analysis to be used
gd.addCheckbox("Benchmark_settings", settings.analysisUseBenchmarkSettings);
gd.addCheckbox("Smart_filter", filterFitConfig.isSmartFilter());
gd.addSlider("Shift_factor", 0.01, 2, filterFitConfig.getCoordinateShiftFactor());
gd.addNumericField("Signal_strength", filterFitConfig.getSignalStrength(), 2);
gd.addNumericField("Min_photons", filterFitConfig.getMinPhotons(), 0);
gd.addSlider("Min_width_factor", 0, 0.99, filterFitConfig.getMinWidthFactor());
gd.addSlider("Max_width_factor", 1.01, 5, filterFitConfig.getMaxWidthFactor());
gd.addNumericField("Precision", filterFitConfig.getPrecisionThreshold(), 2);
gd.addChoice("Precision_method", SettingsManager.getPrecisionMethodNames(), filterFitConfig.getPrecisionMethod().ordinal());
gd.addNumericField("Drift_angle", settings.analysisDriftAngle, 2);
gd.addNumericField("Min_gap", settings.minGap, 2);
// Collect display options
gd.addCheckbox("Show_results", settings.analysisShowResults);
gd.addCheckbox("Show_Jaccard_Plot", settings.showJaccardPlot);
gd.addCheckbox("Use_max_residuals", settings.useMaxResiduals);
gd.addCheckbox("Logging", settings.analysisLogging);
gd.addStringField("Title", settings.analysisTitle);
gd.addCheckbox("Save_template", settings.saveTemplate);
// Add a mouse listener to the config file field
if (ImageJUtils.isShowGenericDialog()) {
final Vector<TextField> numerics = gd.getNumericFields();
final Vector<Checkbox> checkboxes = gd.getCheckboxes();
final Vector<Choice> choices = gd.getChoices();
choices.get(1).addItemListener(this);
checkboxes.get(0).addItemListener(this);
cbSmartFilter = checkboxes.get(1);
final Iterator<TextField> nu = numerics.iterator();
textCoordinateShiftFactor = nu.next();
textSignalStrength = nu.next();
textMinPhotons = nu.next();
textMinWidthFactor = nu.next();
textWidthFactor = nu.next();
textPrecisionThreshold = nu.next();
textPrecisionMethod = choices.get(2);
}
gd.addHelp(HelpUrls.getUrl("doublet-filter-analysis"));
gd.showDialog();
if (gd.wasCanceled()) {
return false;
}
if (gd.invalidNumber()) {
return false;
}
settings.selectionCriteria = gd.getNextChoiceIndex();
// Ignore the template
gd.getNextChoice();
settings.analysisUseBenchmarkSettings = gd.getNextBoolean();
filterFitConfig.setSmartFilter(gd.getNextBoolean());
filterFitConfig.setCoordinateShiftFactor(gd.getNextNumber());
filterFitConfig.setSignalStrength(gd.getNextNumber());
filterFitConfig.setMinPhotons(gd.getNextNumber());
filterFitConfig.setMinWidthFactor(gd.getNextNumber());
filterFitConfig.setMaxWidthFactor(gd.getNextNumber());
filterFitConfig.setPrecisionThreshold(gd.getNextNumber());
filterFitConfig.setPrecisionMethod(gd.getNextChoiceIndex());
settings.analysisDriftAngle = gd.getNextNumber();
settings.minGap = gd.getNextNumber();
settings.analysisShowResults = gd.getNextBoolean();
settings.showJaccardPlot = gd.getNextBoolean();
settings.useMaxResiduals = gd.getNextBoolean();
settings.analysisLogging = gd.getNextBoolean();
settings.analysisTitle = gd.getNextString();
settings.saveTemplate = gd.getNextBoolean();
settings.save();
filterFitConfigRef.set(filterFitConfig);
if (gd.invalidNumber()) {
return false;
}
if (settings.analysisUseBenchmarkSettings) {
return updateFilterConfiguration(filterFitConfig);
} else if (filterFitConfig.isSmartFilter()) {
return PeakFit.configureSmartFilter(filterFitConfig);
}
return true;
}
use of java.awt.Checkbox in project GDSC-SMLM by aherbert.
the class ResultsManager method showDialog.
private boolean showDialog() {
final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
gd.addHelp(HelpUrls.getUrl("results-manager"));
settings = Settings.load();
resultsSettings = SettingsManager.readResultsSettings(0).toBuilder();
gd.addMessage("Read the Peak Results and output to a new format");
gd.addMessage("Select the Peak Results");
addInput(gd, INPUT_NAME, settings.inputOption, new FilenameLoadOption[] { new FilenameLoadOption(settings.inputFilename) }, InputSource.MEMORY, InputSource.FILE);
final Choice inputChoice = gd.getLastChoice();
addTableResultsOptions(gd, resultsSettings, FLAG_TABLE_FORMAT);
addImageResultsOptions(gd, resultsSettings);
addFileResultsOptions(gd, resultsSettings, 0);
addInMemoryResultsOptions(gd, resultsSettings);
final Label messageLabel = (Label) gd.getMessage();
final Checkbox saveCheckbox = gd.getLastCheckbox();
// Hide the in-memory settings if the input is not a file
if (ImageJUtils.isShowGenericDialog()) {
final Label saveLabel = gd.getLastLabel();
final ItemListener listener = event -> {
final boolean enable = INPUT_FILE.equals(inputChoice.getSelectedItem());
if (enable != messageLabel.isVisible()) {
messageLabel.setVisible(enable);
saveCheckbox.setVisible(enable);
saveLabel.setVisible(enable);
gd.pack();
}
};
// Run once to set up
listener.itemStateChanged(null);
inputChoice.addItemListener(listener);
}
gd.showDialog();
if (gd.wasCanceled()) {
return false;
}
settings.inputOption = ResultsManager.getInputSource(gd);
settings.inputFilename = gd.getNextString();
resultsSettings.getResultsTableSettingsBuilder().setResultsTableFormatValue(gd.getNextChoiceIndex());
resultsSettings.getResultsImageSettingsBuilder().setImageTypeValue(gd.getNextChoiceIndex());
resultsSettings.getResultsFileSettingsBuilder().setFileFormatValue(gd.getNextChoiceIndex());
resultsSettings.getResultsFileSettingsBuilder().setResultsFilename(gd.getNextString());
resultsSettings.getResultsInMemorySettingsBuilder().setInMemory(gd.getNextBoolean());
gd.collectOptions();
// Check arguments
try {
final ResultsImageSettings.Builder imageSettings = resultsSettings.getResultsImageSettingsBuilder();
if (imageSettings.getImageType() == ResultsImageType.DRAW_INTENSITY_AVERAGE_PRECISION || imageSettings.getImageType() == ResultsImageType.DRAW_LOCALISATIONS_AVERAGE_PRECISION) {
ParameterUtils.isAboveZero("Image precision", imageSettings.getAveragePrecision());
}
ParameterUtils.isAboveZero("Image scale", imageSettings.getScale());
if (extraOptions) {
ParameterUtils.isPositive("Image rolling window", imageSettings.getRollingWindowSize());
}
} catch (final IllegalArgumentException ex) {
IJ.error(TITLE, ex.getMessage());
return false;
}
settings.save();
SettingsManager.writeSettings(resultsSettings.build());
return true;
}
use of java.awt.Checkbox in project GDSC-SMLM by aherbert.
the class PsfCreator method showAlignmentDialog.
private boolean showAlignmentDialog() {
final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
gd.addHelp(HelpUrls.getUrl("psf-creator"));
gd.addMessage("Use XYZ stack alignment to create a combined PSF");
final CalibrationWriter cw = CalibrationWriter.create(settings.getCalibration());
// These are ignored for reset
gd.addChoice("Alignment_mode", ALIGNMENT_MODE, settings.getAlignmentMode());
gd.addSlider("Z_radius (px)", 0, imp.getStackSize(), settings.getAlignmentZRadius());
gd.addChoice("PSF_type", PSF_TYPE, settings.getPsfType());
gd.addNumericField("nm_per_pixel", cw.getNmPerPixel(), 2, 6, "nm");
gd.addNumericField("nm_per_slice", settings.getNmPerSlice(), 0, 6, "nm");
PeakFit.addCameraOptions(gd, PeakFit.FLAG_NO_GAIN | PeakFit.FLAG_NO_READ_NOISE, cw);
// For reset
final LocalList<TextField> tf = new LocalList<>();
final LocalList<Checkbox> cb = new LocalList<>();
tf.add(gd.addAndGetSlider("Analysis_window", 0, 8, settings.getAnalysisWindow()));
tf.add(gd.addAndGetSlider("Smoothing", 0.1, 0.5, settings.getSmoothing()));
tf.add(gd.addAndGetSlider("CoM_z_window", 0, 8, settings.getComWindow()));
tf.add(gd.addAndGetSlider("CoM_border", 0, 0.5, settings.getComBorder()));
tf.add(gd.addAndGetSlider("Alignment_magnification", 1, 8, settings.getAlignmentMagnification()));
cb.add(gd.addAndGetCheckbox("Smooth_stack_signal", settings.getSmoothStackSignal()));
tf.add(gd.addAndGetSlider("Max_iterations", 1, 20, settings.getMaxIterations()));
if (settings.getInteractiveMode()) {
cb.add(gd.addAndGetCheckbox("Check_alignments", settings.getCheckAlignments()));
}
tf.add(gd.addAndGetNumericField("Sub-pixel_precision", settings.getSubPixelPrecision(), -2));
if (!settings.getInteractiveMode()) {
tf.add(gd.addAndGetNumericField("RMSD_XY_threshold", settings.getRmsdXyThreshold(), -2));
tf.add(gd.addAndGetNumericField("RMSD_Z_threshold", settings.getRmsdZThreshold(), -2));
tf.add(gd.addAndGetNumericField("CoM_shift_threshold", settings.getComShiftThreshold(), -2));
}
if (ImageJUtils.isShowGenericDialog()) {
gd.addAndGetButton("Reset", event -> {
final boolean interactive = PsfCreator.this.settings.getInteractiveMode();
final PSFCreatorSettings defaults = GuiProtosHelper.defaultPSFCreatorSettings;
int ti = 0;
int cbi = 0;
tf.get(ti++).setText(Double.toString(defaults.getAnalysisWindow()));
tf.get(ti++).setText(Double.toString(defaults.getSmoothing()));
tf.get(ti++).setText(Integer.toString(defaults.getComWindow()));
tf.get(ti++).setText(Double.toString(defaults.getComBorder()));
tf.get(ti++).setText(Integer.toString(defaults.getAlignmentMagnification()));
cb.get(cbi++).setState(defaults.getSmoothStackSignal());
tf.get(ti++).setText(Integer.toString(defaults.getMaxIterations()));
if (interactive) {
cb.get(cbi++).setState(defaults.getCheckAlignments());
}
tf.get(ti++).setText(Double.toString(defaults.getSubPixelPrecision()));
if (!interactive) {
tf.get(ti++).setText(Double.toString(defaults.getRmsdXyThreshold()));
tf.get(ti++).setText(Double.toString(defaults.getRmsdZThreshold()));
tf.get(ti++).setText(Double.toString(defaults.getComShiftThreshold()));
}
// Reset later options too
PsfCreator.this.settings.setPsfMagnification(defaults.getPsfMagnification());
PsfCreator.this.settings.setWindow(defaults.getWindow());
PsfCreator.this.settings.setSmoothStackSignal(defaults.getSmoothStackSignal());
PsfCreator.this.settings.setComBorder(defaults.getComBorder());
PsfCreator.this.settings.setCropBorder(0);
PsfCreator.this.settings.setCropStart(0);
PsfCreator.this.settings.setCropEnd(0);
});
}
gd.showDialog();
if (gd.wasCanceled()) {
return false;
}
settings.setAlignmentMode(gd.getNextChoiceIndex());
settings.setAlignmentZRadius((int) gd.getNextNumber());
settings.setPsfType(gd.getNextChoiceIndex());
cw.setNmPerPixel(gd.getNextNumber());
settings.setNmPerSlice(gd.getNextNumber());
cw.setCameraType(SettingsManager.getCameraTypeValues()[gd.getNextChoiceIndex()]);
settings.setAnalysisWindow((int) gd.getNextNumber());
settings.setSmoothing(gd.getNextNumber());
settings.setComWindow((int) gd.getNextNumber());
settings.setComBorder(gd.getNextNumber());
settings.setAlignmentMagnification((int) gd.getNextNumber());
settings.setSmoothStackSignal(gd.getNextBoolean());
settings.setMaxIterations((int) gd.getNextNumber());
if (settings.getInteractiveMode()) {
checkAlignments = gd.getNextBoolean();
settings.setCheckAlignments(checkAlignments);
}
settings.setSubPixelPrecision(gd.getNextNumber());
if (!settings.getInteractiveMode()) {
settings.setRmsdXyThreshold(gd.getNextNumber());
settings.setRmsdZThreshold(gd.getNextNumber());
settings.setComShiftThreshold(gd.getNextNumber());
}
gd.collectOptions();
nmPerPixel = cw.getNmPerPixel();
settings.setCalibration(cw.getBuilder());
SettingsManager.writeSettings(settings);
// Check arguments
try {
ParameterUtils.isPositive("nm/pixel", nmPerPixel);
ParameterUtils.isPositive("nm/slice", settings.getNmPerSlice());
// Since we do a local background estimation for each extracted PSF then we
// do not need the bias for non sCMOS cameras.
// if (!cw.isSCMOS())
// Parameters.isAboveZero("Bias", cw.getBias());
ParameterUtils.isEqualOrAbove("Projection magnification", settings.getAlignmentMagnification(), 1);
ParameterUtils.isEqualOrAbove("Max iterations", settings.getMaxIterations(), 1);
ParameterUtils.isEqualOrAbove("PSF magnification", settings.getPsfMagnification(), 1);
ParameterUtils.isAbove("Smoothing", settings.getSmoothing(), 0);
ParameterUtils.isBelow("Smoothing", settings.getSmoothing(), 1);
} catch (final IllegalArgumentException ex) {
IJ.error(TITLE, ex.getMessage());
return false;
}
return true;
}
Aggregations