use of uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog in project GDSC-SMLM by aherbert.
the class PcPalmMolecules method getRunMode.
private boolean getRunMode(boolean resultsAvailable) {
ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
// Build a list of all images with a region ROI
final List<String> titles = new LinkedList<>();
for (final int imageId : ImageJUtils.getIdList()) {
final ImagePlus imp = WindowManager.getImage(imageId);
if (imp != null && imp.getRoi() != null && imp.getRoi().isArea()) {
titles.add(imp.getTitle());
}
}
settings = Settings.load();
if (!resultsAvailable) {
settings.runMode = 3;
gd.addMessage("Simulate molecules for cluster analysis.\n" + "Computes a binary image from localisation data");
gd.addNumericField("Molecules", settings.numberOfMolecules, 0);
gd.addNumericField("Simulation_size (um)", settings.simulationSize, 2);
gd.addNumericField("Blinking_rate", settings.blinkingRate, 2);
gd.addChoice("Blinking_distribution", Settings.BLINKING_DISTRIBUTION, settings.blinkingDistribution);
gd.addNumericField("Average_precision (nm)", settings.sigmaS, 2);
gd.addCheckbox("Show_histograms", settings.showHistograms);
gd.addCheckbox("Distance_analysis", settings.distanceAnalysis);
gd.addChoice("Cluster_simulation", Settings.CLUSTER_SIMULATION, settings.clusterSimulation);
gd.addNumericField("Cluster_number", settings.clusterNumber, 2);
gd.addNumericField("Cluster_variation (SD)", settings.clusterNumberStdDev, 2);
gd.addNumericField("Cluster_radius", settings.clusterRadius, 2);
gd.addCheckbox("Show_cluster_mask", settings.showClusterMask);
Recorder.recordOption("Run_mode", Settings.RUN_MODE[settings.runMode]);
} else {
gd.addMessage("Prepare molecules for cluster analysis.\n" + "Computes a binary image from raw localisation data");
ResultsManager.addInput(gd, settings.inputOption, InputSource.MEMORY);
if (!titles.isEmpty()) {
gd.addCheckbox((titles.size() == 1) ? "Use_ROI" : "Choose_ROI", settings.chooseRoi);
}
gd.addChoice("Run_mode", Settings.RUN_MODE, settings.runMode);
}
gd.addMessage("Select options for low resolution image:");
gd.addSlider("Image_size (px)", 512, 2048, settings.lowResolutionImageSize);
gd.addSlider("ROI_size (um)", 1.5, 4, settings.roiSizeInUm);
gd.addMessage("Select options for high resolution image:");
gd.addCheckbox("Show_high_res_image", settings.showHighResolutionImage);
gd.addSlider("nm_per_pixel_limit", 0, 20, settings.nmPerPixelLimit);
gd.addMessage("Optionally remove all analysis results from memory");
gd.addCheckbox("Clear_results", settings.clearResults);
gd.addHelp(HelpUrls.getUrl("pc-palm-molecules"));
gd.showDialog();
if (gd.wasCanceled()) {
return false;
}
if (!resultsAvailable) {
settings.numberOfMolecules = (int) Math.abs(gd.getNextNumber());
settings.simulationSize = Math.abs(gd.getNextNumber());
settings.blinkingRate = Math.abs(gd.getNextNumber());
settings.blinkingDistribution = gd.getNextChoiceIndex();
settings.sigmaS = Math.abs(gd.getNextNumber());
settings.showHistograms = gd.getNextBoolean();
settings.distanceAnalysis = gd.getNextBoolean();
settings.clusterSimulation = gd.getNextChoiceIndex();
settings.clusterNumber = Math.abs(gd.getNextNumber());
settings.clusterNumberStdDev = Math.abs(gd.getNextNumber());
settings.clusterRadius = Math.abs(gd.getNextNumber());
settings.showClusterMask = gd.getNextBoolean();
} else {
settings.inputOption = ResultsManager.getInputSource(gd);
if (!titles.isEmpty()) {
settings.chooseRoi = gd.getNextBoolean();
}
settings.runMode = gd.getNextChoiceIndex();
}
settings.lowResolutionImageSize = (int) gd.getNextNumber();
settings.roiSizeInUm = gd.getNextNumber();
settings.showHighResolutionImage = gd.getNextBoolean();
settings.nmPerPixelLimit = Math.abs(gd.getNextNumber());
settings.clearResults = gd.getNextBoolean();
settings.save();
// Check arguments
try {
if (!resultsAvailable) {
ParameterUtils.isAboveZero("Molecules", settings.numberOfMolecules);
ParameterUtils.isAboveZero("Simulation size", settings.simulationSize);
ParameterUtils.isEqualOrAbove("Blinking rate", settings.blinkingRate, 1);
ParameterUtils.isEqualOrAbove("Cluster number", settings.clusterNumber, 1);
}
ParameterUtils.isAbove("Image scale", settings.lowResolutionImageSize, 1);
ParameterUtils.isAboveZero("ROI size", settings.roiSizeInUm);
} catch (final IllegalArgumentException ex) {
IJ.error(TITLE, ex.getMessage());
return false;
}
if (!titles.isEmpty() && settings.chooseRoi && resultsAvailable) {
if (titles.size() == 1) {
settings.roiImage = titles.get(0);
Recorder.recordOption("Image", settings.roiImage);
} else {
final String[] items = titles.toArray(new String[0]);
gd = new ExtendedGenericDialog(TITLE);
gd.addMessage("Select the source image for the ROI");
gd.addChoice("Image", items, settings.roiImage);
gd.showDialog();
if (gd.wasCanceled()) {
return false;
}
settings.roiImage = gd.getNextChoice();
}
final ImagePlus imp = WindowManager.getImage(settings.roiImage);
roiBounds = imp.getRoi().getBounds();
roiImageWidth = imp.getWidth();
roiImageHeight = imp.getHeight();
} else {
roiBounds = null;
}
if (!resultsAvailable && !getPValue()) {
return false;
}
if (settings.clearResults) {
PcPalmAnalysis.clearResults();
PcPalmFitting.clearResults();
}
return true;
}
use of uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog in project GDSC-SMLM by aherbert.
the class PeakResultTableModelFrame method doEditTableSettings.
private void doEditTableSettings() {
final PeakResultTableModel model = getModel();
if (model == null) {
return;
}
final ResultsTableSettings.Builder tableSettings = model.getTableSettings().toBuilder();
// Copied from ResultsManager.addTableResultsOptions
final ExtendedGenericDialog egd = new ExtendedGenericDialog("Table Settings", this);
egd.addChoice("Table_distance_unit", SettingsManager.getDistanceUnitNames(), tableSettings.getDistanceUnitValue());
egd.addChoice("Table_intensity_unit", SettingsManager.getIntensityUnitNames(), tableSettings.getIntensityUnitValue());
egd.addChoice("Table_angle_unit", SettingsManager.getAngleUnitNames(), tableSettings.getAngleUnitValue());
egd.addCheckbox("Table_show_fitting_data", tableSettings.getShowFittingData());
egd.addCheckbox("Table_show_noise_data", tableSettings.getShowNoiseData());
egd.addCheckbox("Table_show_precision", tableSettings.getShowPrecision());
egd.addSlider("Table_precision", 0, 10, tableSettings.getRoundingPrecision());
egd.addCheckbox("Table_show_counter", tableSettings.getShowRowCounter());
egd.showDialog();
if (egd.wasCanceled()) {
return;
}
tableSettings.setDistanceUnitValue(egd.getNextChoiceIndex());
tableSettings.setIntensityUnitValue(egd.getNextChoiceIndex());
tableSettings.setAngleUnitValue(egd.getNextChoiceIndex());
tableSettings.setShowFittingData(egd.getNextBoolean());
tableSettings.setShowNoiseData(egd.getNextBoolean());
tableSettings.setShowPrecision(egd.getNextBoolean());
tableSettings.setRoundingPrecision((int) egd.getNextNumber());
tableSettings.setShowRowCounter(egd.getNextBoolean());
model.setTableSettings(tableSettings.build());
}
use of uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog in project GDSC-SMLM by aherbert.
the class PeakFit method newWizardDialog.
private static ExtendedGenericDialog newWizardDialog(String... messages) {
final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
gd.addHelp(HelpUrls.getUrl("simple-fit"));
final String header = "-=-";
gd.addMessage(header + " " + TITLE + " Configuration Wizard " + header);
for (final String message : messages) {
gd.addMessage(TextUtils.wrap(message, 80));
}
return gd;
}
use of uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog in project GDSC-SMLM by aherbert.
the class PeakFit method addSingleFrameOverlay.
private void addSingleFrameOverlay() {
// If a single frame was processed add the peaks as an overlay if they are in memory
ImagePlus localImp = this.imp;
if (fitMaxima && singleFrame > 0 && source instanceof IJImageSource) {
final String title = source.getName();
localImp = WindowManager.getImage(title);
}
if (singleFrame > 0 && localImp != null) {
MemoryPeakResults memoryResults = null;
for (final PeakResults r : this.results.toArray()) {
if (r instanceof MemoryPeakResults) {
memoryResults = (MemoryPeakResults) r;
break;
}
}
if (memoryResults == null || memoryResults.size() == 0) {
return;
}
final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
gd.enableYesNoCancel();
gd.hideCancelButton();
gd.addMessage("Add the fitted localisations as an overlay?");
gd.showDialog();
if (!gd.wasOKed()) {
return;
}
final LUT lut = LutHelper.createLut(LutColour.ICE);
final Overlay o = new Overlay();
final int size = memoryResults.size();
final Counter j = new Counter(size);
final ImagePlus finalImp = localImp;
memoryResults.forEach(DistanceUnit.PIXEL, (XyResultProcedure) (x, y) -> {
final PointRoi roi = new OffsetPointRoi(x, y);
final Color c = LutHelper.getColour(lut, j.decrementAndGet(), size);
roi.setStrokeColor(c);
roi.setFillColor(c);
if (finalImp.getStackSize() > 1) {
roi.setPosition(singleFrame);
}
o.add(roi);
});
localImp.setOverlay(o);
localImp.getWindow().toFront();
}
}
use of uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog in project GDSC-SMLM by aherbert.
the class PeakFit method getPixelPitch.
private static boolean getPixelPitch(CalibrationWriter calibration) {
final ExtendedGenericDialog gd = newWizardDialog("Enter the size of each pixel. This is required to ensure the dimensions of the image" + " are calibrated.", "E.g. a camera with a 6.45um pixel size and a 60x objective will have a pitch of" + " 6450/60 = 107.5nm.");
// TODO - Add a pop-up calculator...
gd.addNumericField("Calibration", calibration.getNmPerPixel(), 2, 6, "nm/px");
gd.showDialog();
if (gd.wasCanceled()) {
return false;
}
calibration.setNmPerPixel(Math.abs(gd.getNextNumber()));
return true;
}
Aggregations