use of ij.gui.ExtendedGenericDialog in project GDSC-SMLM by aherbert.
the class PulseActivationAnalysis method showCrossTalkAnalysisDialog.
private boolean showCrossTalkAnalysisDialog() {
ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
gd.addMessage(TextUtils.wrap("Crosstalk analysis requires a sample singly labelled with only one photo-switchable probe and imaged with the full pulse lifecycle. The probe should be activated by the pulse in the target channel. Activations from the pulse in other channels is crosstalk.", 80));
String[] ch = new String[channels];
for (int i = 0; i < ch.length; i++) ch[i] = "Channel " + (i + 1);
gd.addChoice("Target", ch, "Channel " + targetChannel);
gd.showDialog();
if (gd.wasCanceled())
return false;
targetChannel = gd.getNextChoiceIndex() + 1;
return true;
}
use of ij.gui.ExtendedGenericDialog in project GDSC-SMLM by aherbert.
the class PulseActivationAnalysis method showSimulationDialog.
private boolean showSimulationDialog() {
ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
SimulationDistribution[] distributionValues = SimulationDistribution.values();
String[] distribution = SettingsManager.getNames((Object[]) distributionValues);
// Random crosstalk if not set
if (Maths.max(ct) == 0) {
RandomDataGenerator rdg = getRandomDataGenerator();
for (int i = 0; i < ct.length; i++) // Have some crosstalk
ct[i] = rdg.nextUniform(0.05, 0.15);
}
// Three channel
for (int c = 0; c < 3; c++) {
String ch = "_C" + (c + 1);
gd.addNumericField("Molcules" + ch, sim_nMolecules[c], 0);
gd.addChoice("Distribution" + ch, distribution, distribution[sim_distribution[c].ordinal()]);
gd.addNumericField("Precision_" + ch, sim_precision[c], 3);
gd.addNumericField("Crosstalk_" + ctNames[2 * c], ct[2 * c], 3);
gd.addNumericField("Crosstalk_" + ctNames[2 * c + 1], ct[2 * c + 1], 3);
}
gd.showDialog();
if (gd.wasCanceled())
return false;
int count = 0;
for (int c = 0; c < 3; c++) {
sim_nMolecules[c] = (int) Math.abs(gd.getNextNumber());
if (sim_nMolecules[c] > 0)
count++;
sim_distribution[c] = distributionValues[gd.getNextChoiceIndex()];
sim_precision[c] = Math.abs(gd.getNextNumber());
ct[2 * c] = Math.abs(gd.getNextNumber());
ct[2 * c + 1] = Math.abs(gd.getNextNumber());
}
if (gd.invalidNumber())
return false;
if (count < 2) {
IJ.error(TITLE, "Simulation requires at least 2 channels");
return false;
}
try {
for (int i = 0; i < ct.length; i += 2) {
if (sim_nMolecules[i / 2] > 0)
validateCrosstalk(i, i + 1);
}
} catch (IllegalArgumentException ex) {
IJ.error(TITLE, ex.getMessage());
return false;
}
return true;
}
use of ij.gui.ExtendedGenericDialog in project GDSC-SMLM by aherbert.
the class PulseActivationAnalysis method showDialog.
private boolean showDialog(boolean crosstalkMode) {
TITLE = ((crosstalkMode) ? "Crosstalk " : "Pulse ") + TITLE;
ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
if (crosstalkMode)
gd.addMessage("Analyse crosstalk activation rate");
else
gd.addMessage("Count & plot molecules activated after a pulse");
ResultsManager.addInput(gd, "Input", inputOption, InputSource.MEMORY_CLUSTERED);
int min = (crosstalkMode) ? 2 : 1;
gd.addSlider("Channels", min, MAX_CHANNELS, channels);
gd.showDialog();
if (gd.wasCanceled())
return false;
inputOption = ResultsManager.getInputSource(gd);
channels = (int) gd.getNextNumber();
if (channels < min || channels > MAX_CHANNELS) {
IJ.error(TITLE, "Channels must be between " + min + " and " + MAX_CHANNELS);
return false;
}
return true;
}
use of ij.gui.ExtendedGenericDialog in project GDSC-SMLM by aherbert.
the class PulseActivationAnalysis method showPulseCycleDialog.
private boolean showPulseCycleDialog() {
ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
gd.addMessage("Specify the pulse cycle");
gd.addNumericField("Repeat_interval", repeatInterval, 0);
gd.addNumericField("Dark_frames_for_new_activation", darkFramesForNewActivation, 0);
for (int c = 1; c <= channels; c++) gd.addNumericField("Activation_frame_C" + c, startFrame[c - 1], 0);
gd.showDialog();
if (gd.wasCanceled())
return false;
repeatInterval = (int) gd.getNextNumber();
if (repeatInterval < channels) {
IJ.error(TITLE, "Repeat interval must be greater than the number of channels: " + channels);
return false;
}
darkFramesForNewActivation = Math.max(1, (int) gd.getNextNumber());
for (int c = 1; c <= channels; c++) {
int frame = (int) gd.getNextNumber();
if (frame < 1 || frame > repeatInterval) {
IJ.error(TITLE, "Channel " + c + " activation frame must within the repeat interval");
return false;
}
startFrame[c - 1] = frame;
}
// Check all start frames are unique
for (int i = 0; i < channels; i++) for (int j = i + 1; j < channels; j++) if (startFrame[i] == startFrame[j]) {
IJ.error(TITLE, "Start frames must be unique for each channel");
return false;
}
return true;
}
use of ij.gui.ExtendedGenericDialog in project GDSC-SMLM by aherbert.
the class DensityImage method showDialog.
private boolean showDialog() {
ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
gd.addHelp(About.HELP_URL);
// Build a list of all images with a region ROI
List<String> titles = new LinkedList<String>();
if (WindowManager.getWindowCount() > 0) {
for (int imageID : WindowManager.getIDList()) {
ImagePlus imp = WindowManager.getImage(imageID);
if (imp != null && imp.getRoi() != null && imp.getRoi().isArea())
titles.add(imp.getTitle());
}
}
gd.addMessage("Show an image using the localisation density");
ResultsManager.addInput(gd, inputOption, InputSource.MEMORY);
gd.addNumericField("Radius", radius, 3);
if (!titles.isEmpty())
gd.addCheckbox((titles.size() == 1) ? "Use_ROI" : "Choose_ROI", chooseRoi);
gd.addCheckbox("Adjust_for_border", adjustForBorder);
gd.addSlider("Image_Scale", 1, 15, imageScale);
gd.addCheckbox("Cumulative_image", cumulativeImage);
gd.addCheckbox("Use_square_approx", useSquareApproximation);
gd.addNumericField("Square_resolution", resolution, 0);
gd.addChoice("Score", ScoreMethods, ScoreMethods[scoreMethodIndex]);
gd.addMessage("Filter localisations using the L-score / Relative density.\nFiltered results will be added to memory:");
gd.addCheckbox("Filter_localisations", filterLocalisations);
gd.addNumericField("Filter_threshold", filterThreshold, 2);
gd.addCheckbox("Compute_Ripleys_L_plot", computeRipleysPlot);
gd.showDialog();
if (gd.wasCanceled())
return false;
inputOption = ResultsManager.getInputSource(gd);
radius = (float) gd.getNextNumber();
if (!titles.isEmpty())
chooseRoi = gd.getNextBoolean();
adjustForBorder = gd.getNextBoolean();
imageScale = (int) gd.getNextNumber();
cumulativeImage = gd.getNextBoolean();
useSquareApproximation = gd.getNextBoolean();
resolution = (int) gd.getNextNumber();
scoreMethodIndex = gd.getNextChoiceIndex();
filterLocalisations = gd.getNextBoolean();
filterThreshold = gd.getNextNumber();
computeRipleysPlot = gd.getNextBoolean();
// Check arguments
try {
Parameters.isAboveZero("Radius", radius);
Parameters.isAboveZero("Image scale", imageScale);
Parameters.isAboveZero("Resolution", resolution);
} catch (IllegalArgumentException e) {
IJ.error(TITLE, e.getMessage());
return false;
}
if (!titles.isEmpty() && chooseRoi) {
if (titles.size() == 1) {
roiImage = titles.get(0);
Recorder.recordOption("Image", roiImage);
} else {
String[] items = titles.toArray(new String[titles.size()]);
gd = new ExtendedGenericDialog(TITLE);
gd.addMessage("Select the source image for the ROI");
gd.addChoice("Image", items, roiImage);
gd.showDialog();
if (gd.wasCanceled())
return false;
roiImage = gd.getNextChoice();
}
ImagePlus imp = WindowManager.getImage(roiImage);
roiBounds = imp.getRoi().getBounds();
roiImageWidth = imp.getWidth();
roiImageHeight = imp.getHeight();
} else {
roiBounds = null;
}
return true;
}
Aggregations