Search in sources :

Example 11 with ExtendedGenericDialog

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;
}
Also used : NonBlockingExtendedGenericDialog(ij.gui.NonBlockingExtendedGenericDialog) ExtendedGenericDialog(ij.gui.ExtendedGenericDialog)

Example 12 with ExtendedGenericDialog

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;
}
Also used : RandomDataGenerator(org.apache.commons.math3.random.RandomDataGenerator) NonBlockingExtendedGenericDialog(ij.gui.NonBlockingExtendedGenericDialog) ExtendedGenericDialog(ij.gui.ExtendedGenericDialog)

Example 13 with ExtendedGenericDialog

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;
}
Also used : NonBlockingExtendedGenericDialog(ij.gui.NonBlockingExtendedGenericDialog) ExtendedGenericDialog(ij.gui.ExtendedGenericDialog)

Example 14 with ExtendedGenericDialog

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;
}
Also used : NonBlockingExtendedGenericDialog(ij.gui.NonBlockingExtendedGenericDialog) ExtendedGenericDialog(ij.gui.ExtendedGenericDialog)

Example 15 with ExtendedGenericDialog

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;
}
Also used : ExtendedGenericDialog(ij.gui.ExtendedGenericDialog) ImagePlus(ij.ImagePlus) LinkedList(java.util.LinkedList)

Aggregations

ExtendedGenericDialog (ij.gui.ExtendedGenericDialog)60 ImagePlus (ij.ImagePlus)11 NonBlockingExtendedGenericDialog (ij.gui.NonBlockingExtendedGenericDialog)8 FitEngineConfiguration (gdsc.smlm.engine.FitEngineConfiguration)6 GlobalSettings (gdsc.smlm.ij.settings.GlobalSettings)6 MemoryPeakResults (gdsc.smlm.results.MemoryPeakResults)6 Calibration (gdsc.smlm.results.Calibration)5 ClusterPoint (gdsc.core.clustering.ClusterPoint)4 FitConfiguration (gdsc.smlm.fitting.FitConfiguration)4 PeakResult (gdsc.smlm.results.PeakResult)4 Rectangle (java.awt.Rectangle)4 LinkedList (java.util.LinkedList)4 ArrayList (java.util.ArrayList)3 WeightedObservedPoint (org.apache.commons.math3.fitting.WeightedObservedPoint)3 IJImageSource (gdsc.smlm.ij.IJImageSource)2 IJTablePeakResults (gdsc.smlm.ij.results.IJTablePeakResults)2 ResultsSettings (gdsc.smlm.ij.settings.ResultsSettings)2 ImageSource (gdsc.smlm.results.ImageSource)2 Trace (gdsc.smlm.results.Trace)2 Filter (gdsc.smlm.results.filter.Filter)2