Search in sources :

Example 26 with Checkbox

use of java.awt.Checkbox in project GDSC-SMLM by aherbert.

the class CreateData method showDialog.

/**
	 * Show a dialog allowing the parameters for a simulation to be performed
	 * 
	 * @return True if the parameters were collected
	 */
private boolean showDialog() {
    // In track mode we do not need a time, illumination model or blinking model.
    // Fixed length tracks will be drawn, non-overlapping in time. This is the simplest
    // simulation for moving molecules
    GenericDialog gd = new GenericDialog(TITLE);
    globalSettings = SettingsManager.loadSettings();
    settings = globalSettings.getCreateDataSettings();
    if (settings.stepsPerSecond < 1)
        settings.stepsPerSecond = 1;
    String[] backgroundImages = createBackgroundImageList();
    gd.addNumericField("Pixel_pitch (nm)", settings.pixelPitch, 2);
    gd.addNumericField("Size (px)", settings.size, 0);
    gd.addNumericField("Depth (nm)", settings.depth, 0);
    gd.addCheckbox("Fixed_depth", settings.fixedDepth);
    if (!trackMode)
        gd.addNumericField("Seconds", settings.seconds, 1);
    gd.addNumericField("Exposure_time (ms)", settings.exposureTime, 1);
    gd.addSlider("Steps_per_second", 1, 15, settings.stepsPerSecond);
    if (!trackMode) {
        gd.addChoice("Illumination", ILLUMINATION, settings.illumination);
        gd.addNumericField("Pulse_interval", settings.pulseInterval, 0);
        gd.addNumericField("Pulse_ratio", settings.pulseRatio, 2);
    }
    if (backgroundImages != null)
        gd.addChoice("Background_image", backgroundImages, settings.backgroundImage);
    if (extraOptions)
        gd.addCheckbox("No_poisson_noise", !settings.poissonNoise);
    gd.addNumericField("Background (photons)", settings.background, 2);
    gd.addNumericField("EM_gain", settings.getEmGain(), 2);
    gd.addNumericField("Camera_gain (ADU/e-)", settings.getCameraGain(), 4);
    gd.addNumericField("Quantum_efficiency", settings.getQuantumEfficiency(), 2);
    gd.addNumericField("Read_noise (e-)", settings.readNoise, 2);
    gd.addNumericField("Bias", settings.bias, 0);
    List<String> imageNames = addPSFOptions(gd);
    gd.addMessage("--- Fluorophores ---");
    Component splitLabel = gd.getMessage();
    gd.addChoice("Distribution", DISTRIBUTION, settings.distribution);
    gd.addNumericField("Particles", settings.particles, 0);
    gd.addCheckbox("Compound_molecules", settings.compoundMolecules);
    gd.addNumericField("Diffusion_rate (um^2/sec)", settings.diffusionRate, 2);
    String[] diffusionTypes = SettingsManager.getNames((Object[]) DiffusionType.values());
    gd.addChoice("Diffusion_type", diffusionTypes, diffusionTypes[settings.getDiffusionType().ordinal()]);
    gd.addSlider("Fixed_fraction (%)", 0, 100, settings.fixedFraction * 100);
    gd.addChoice("Confinement", CONFINEMENT, settings.confinement);
    gd.addNumericField("Photons (sec^-1)", settings.photonsPerSecond, 0);
    // We cannot use the correlation moe with fixed life time tracks 
    String[] dist = (trackMode) ? Arrays.copyOf(PHOTON_DISTRIBUTION, PHOTON_DISTRIBUTION.length - 1) : PHOTON_DISTRIBUTION;
    gd.addChoice("Photon_distribution", dist, settings.photonDistribution);
    gd.addNumericField("On_time (ms)", settings.tOn, 2);
    if (!trackMode) {
        gd.addNumericField("Off_time_short (ms)", settings.tOffShort, 2);
        gd.addNumericField("Off_time_long (ms)", settings.tOffLong, 2);
        gd.addNumericField("n_Blinks_Short", settings.nBlinksShort, 2);
        gd.addNumericField("n_Blinks_Long", settings.nBlinksLong, 2);
        gd.addCheckbox("Use_geometric_distribution", settings.nBlinksGeometricDistribution);
    }
    gd.addMessage("--- Peak filtering ---");
    gd.addSlider("Min_Photons", 0, 50, settings.minPhotons);
    gd.addSlider("Min_SNR_t1", 0, 20, settings.minSNRt1);
    gd.addSlider("Min_SNR_tN", 0, 10, settings.minSNRtN);
    gd.addMessage("--- Save options ---");
    Component splitLabel2 = gd.getMessage();
    gd.addCheckbox("Raw_image", settings.rawImage);
    gd.addCheckbox("Save_image", settings.saveImage);
    gd.addCheckbox("Save_image_results", settings.saveImageResults);
    gd.addCheckbox("Save_fluorophores", settings.saveFluorophores);
    gd.addCheckbox("Save_localisations", settings.saveLocalisations);
    gd.addMessage("--- Report options ---");
    gd.addCheckbox("Show_histograms", settings.showHistograms);
    gd.addCheckbox("Choose_histograms", settings.chooseHistograms);
    gd.addNumericField("Histogram_bins", settings.histogramBins, 0);
    gd.addCheckbox("Remove_outliers", settings.removeOutliers);
    gd.addSlider("Density_radius (N x HWHM)", 0, 4.5, settings.densityRadius);
    gd.addNumericField("Depth-of-field (nm)", settings.depthOfField, 0);
    if (gd.getLayout() != null) {
        GridBagLayout grid = (GridBagLayout) gd.getLayout();
        int xOffset = 0, yOffset = 0;
        int lastY = -1, rowCount = 0;
        for (Component comp : gd.getComponents()) {
            // Check if this should be the second major column
            if (comp == splitLabel || comp == splitLabel2) {
                xOffset += 2;
                yOffset -= rowCount;
                rowCount = 0;
            }
            // Reposition the field
            GridBagConstraints c = grid.getConstraints(comp);
            if (lastY != c.gridy)
                rowCount++;
            lastY = c.gridy;
            c.gridx = c.gridx + xOffset;
            c.gridy = c.gridy + yOffset;
            c.insets.left = c.insets.left + 10 * xOffset;
            c.insets.top = 0;
            c.insets.bottom = 0;
            grid.setConstraints(comp, c);
        }
        if (IJ.isLinux())
            gd.setBackground(new Color(238, 238, 238));
    }
    gd.showDialog();
    if (gd.wasCanceled())
        return false;
    settings.pixelPitch = Math.abs(gd.getNextNumber());
    settings.size = Math.abs((int) gd.getNextNumber());
    settings.depth = Math.abs(gd.getNextNumber());
    settings.fixedDepth = gd.getNextBoolean();
    if (!trackMode)
        settings.seconds = Math.abs(gd.getNextNumber());
    settings.exposureTime = Math.abs(gd.getNextNumber());
    settings.stepsPerSecond = Math.abs(gd.getNextNumber());
    if (!trackMode) {
        settings.illumination = gd.getNextChoice();
        settings.pulseInterval = Math.abs((int) gd.getNextNumber());
        settings.pulseRatio = Math.abs(gd.getNextNumber());
    }
    if (backgroundImages != null)
        settings.backgroundImage = gd.getNextChoice();
    if (extraOptions)
        poissonNoise = settings.poissonNoise = !gd.getNextBoolean();
    settings.background = Math.abs(gd.getNextNumber());
    settings.setEmGain(Math.abs(gd.getNextNumber()));
    settings.setCameraGain(Math.abs(gd.getNextNumber()));
    settings.setQuantumEfficiency(Math.abs(gd.getNextNumber()));
    settings.readNoise = Math.abs(gd.getNextNumber());
    settings.bias = Math.abs((int) gd.getNextNumber());
    if (!collectPSFOptions(gd, imageNames))
        return false;
    settings.distribution = gd.getNextChoice();
    settings.particles = Math.abs((int) gd.getNextNumber());
    settings.compoundMolecules = gd.getNextBoolean();
    settings.diffusionRate = Math.abs(gd.getNextNumber());
    settings.setDiffusionType(gd.getNextChoiceIndex());
    settings.fixedFraction = Math.abs(gd.getNextNumber() / 100.0);
    settings.confinement = gd.getNextChoice();
    settings.photonsPerSecond = Math.abs((int) gd.getNextNumber());
    settings.photonDistribution = gd.getNextChoice();
    settings.tOn = Math.abs(gd.getNextNumber());
    if (!trackMode) {
        settings.tOffShort = Math.abs(gd.getNextNumber());
        settings.tOffLong = Math.abs(gd.getNextNumber());
        settings.nBlinksShort = Math.abs(gd.getNextNumber());
        settings.nBlinksLong = Math.abs(gd.getNextNumber());
        settings.nBlinksGeometricDistribution = gd.getNextBoolean();
    }
    minPhotons = settings.minPhotons = gd.getNextNumber();
    minSNRt1 = settings.minSNRt1 = gd.getNextNumber();
    minSNRtN = settings.minSNRtN = gd.getNextNumber();
    settings.rawImage = gd.getNextBoolean();
    settings.saveImage = gd.getNextBoolean();
    settings.saveImageResults = gd.getNextBoolean();
    settings.saveFluorophores = gd.getNextBoolean();
    settings.saveLocalisations = gd.getNextBoolean();
    settings.showHistograms = gd.getNextBoolean();
    settings.chooseHistograms = gd.getNextBoolean();
    settings.histogramBins = (int) gd.getNextNumber();
    settings.removeOutliers = gd.getNextBoolean();
    settings.densityRadius = (float) gd.getNextNumber();
    settings.depthOfField = (float) Math.abs(gd.getNextNumber());
    // Ensure tN threshold is more lenient
    if (settings.minSNRt1 < settings.minSNRtN) {
        double tmp = settings.minSNRt1;
        settings.minSNRt1 = settings.minSNRtN;
        settings.minSNRtN = tmp;
    }
    // Save before validation so that the current values are preserved.
    SettingsManager.saveSettings(globalSettings);
    // Check arguments
    try {
        Parameters.isAboveZero("Pixel Pitch", settings.pixelPitch);
        Parameters.isAboveZero("Size", settings.size);
        if (!settings.fixedDepth)
            Parameters.isPositive("Depth", settings.depth);
        if (!trackMode)
            Parameters.isAboveZero("Seconds", settings.seconds);
        Parameters.isAboveZero("Exposure time", settings.exposureTime);
        Parameters.isAboveZero("Steps per second", settings.stepsPerSecond);
        Parameters.isPositive("Background", settings.background);
        Parameters.isPositive("EM gain", settings.getEmGain());
        Parameters.isPositive("Camera gain", settings.getCameraGain());
        Parameters.isPositive("Read noise", settings.readNoise);
        double noiseRange = settings.readNoise * settings.getCameraGain() * 4;
        Parameters.isEqualOrAbove("Bias must prevent clipping the read noise (@ +/- 4 StdDev) so ", settings.bias, noiseRange);
        Parameters.isAboveZero("Particles", settings.particles);
        Parameters.isAboveZero("Photons", settings.photonsPerSecond);
        if (!imagePSF) {
            Parameters.isAboveZero("Wavelength", settings.wavelength);
            Parameters.isAboveZero("NA", settings.numericalAperture);
            Parameters.isBelow("NA", settings.numericalAperture, 2);
        }
        Parameters.isPositive("Diffusion rate", settings.diffusionRate);
        Parameters.isPositive("Fixed fraction", settings.fixedFraction);
        Parameters.isPositive("Pulse interval", settings.pulseInterval);
        Parameters.isAboveZero("Pulse ratio", settings.pulseRatio);
        Parameters.isAboveZero("tOn", settings.tOn);
        if (!trackMode) {
            Parameters.isAboveZero("tOff Short", settings.tOffShort);
            Parameters.isAboveZero("tOff Long", settings.tOffLong);
            Parameters.isPositive("n-Blinks Short", settings.nBlinksShort);
            Parameters.isPositive("n-Blinks Long", settings.nBlinksLong);
        }
        Parameters.isPositive("Min photons", settings.minPhotons);
        Parameters.isPositive("Min SNR t1", settings.minSNRt1);
        Parameters.isPositive("Min SNR tN", settings.minSNRtN);
        Parameters.isAbove("Histogram bins", settings.histogramBins, 1);
        Parameters.isPositive("Density radius", settings.densityRadius);
    } catch (IllegalArgumentException e) {
        IJ.error(TITLE, e.getMessage());
        return false;
    }
    if (gd.invalidNumber())
        return false;
    if (!getHistogramOptions())
        return false;
    String[] maskImages = null;
    if (settings.distribution.equals(DISTRIBUTION[MASK])) {
        maskImages = createDistributionImageList();
        if (maskImages != null) {
            gd = new GenericDialog(TITLE);
            gd.addMessage("Select the mask image for the distribution");
            gd.addChoice("Distribution_mask", maskImages, settings.distributionMask);
            if (maskListContainsStacks)
                gd.addNumericField("Distribution_slice_depth (nm)", settings.distributionMaskSliceDepth, 0);
            gd.showDialog();
            if (gd.wasCanceled())
                return false;
            settings.distributionMask = gd.getNextChoice();
            if (maskListContainsStacks)
                settings.distributionMaskSliceDepth = Math.abs(gd.getNextNumber());
        }
    } else if (settings.distribution.equals(DISTRIBUTION[GRID])) {
        gd = new GenericDialog(TITLE);
        gd.addMessage("Select grid for the distribution");
        gd.addNumericField("Cell_size", settings.cellSize, 0);
        gd.addSlider("p-binary", 0, 1, settings.probabilityBinary);
        gd.addNumericField("Min_binary_distance (nm)", settings.minBinaryDistance, 0);
        gd.addNumericField("Max_binary_distance (nm)", settings.maxBinaryDistance, 0);
        gd.showDialog();
        if (gd.wasCanceled())
            return false;
        settings.cellSize = (int) gd.getNextNumber();
        settings.probabilityBinary = gd.getNextNumber();
        settings.minBinaryDistance = gd.getNextNumber();
        settings.maxBinaryDistance = gd.getNextNumber();
        // Check arguments
        try {
            Parameters.isAboveZero("Cell size", settings.cellSize);
            Parameters.isPositive("p-binary", settings.probabilityBinary);
            Parameters.isEqualOrBelow("p-binary", settings.probabilityBinary, 1);
            Parameters.isPositive("Min binary distance", settings.minBinaryDistance);
            Parameters.isPositive("Max binary distance", settings.maxBinaryDistance);
            Parameters.isEqualOrBelow("Min binary distance", settings.minBinaryDistance, settings.maxBinaryDistance);
        } catch (IllegalArgumentException e) {
            IJ.error(TITLE, e.getMessage());
            return false;
        }
    }
    SettingsManager.saveSettings(globalSettings);
    if (settings.diffusionRate > 0 && settings.fixedFraction < 1) {
        if (settings.confinement.equals(CONFINEMENT[CONFINEMENT_SPHERE])) {
            gd = new GenericDialog(TITLE);
            gd.addMessage("Select the sphere radius for the diffusion confinement");
            gd.addSlider("Confinement_radius (nm)", 0, 2000, settings.confinementRadius);
            gd.showDialog();
            if (gd.wasCanceled())
                return false;
            settings.confinementRadius = gd.getNextNumber();
        } else if (settings.confinement.equals(CONFINEMENT[CONFINEMENT_MASK])) {
            if (maskImages == null)
                maskImages = createDistributionImageList();
            if (maskImages != null) {
                gd = new GenericDialog(TITLE);
                gd.addMessage("Select the mask image for the diffusion confinement");
                gd.addChoice("Confinement_mask", maskImages, settings.confinementMask);
                if (maskListContainsStacks)
                    gd.addNumericField("Confinement_slice_depth (nm)", settings.confinementMaskSliceDepth, 0);
                gd.showDialog();
                if (gd.wasCanceled())
                    return false;
                settings.confinementMask = gd.getNextChoice();
                if (maskListContainsStacks)
                    settings.confinementMaskSliceDepth = Math.abs(gd.getNextNumber());
            }
        }
    }
    SettingsManager.saveSettings(globalSettings);
    if (settings.compoundMolecules) {
        // Show a second dialog where the molecule configuration is specified
        gd = new GenericDialog(TITLE);
        gd.addMessage("Specify the compound molecules");
        gd.addTextAreas(settings.compoundText, null, 20, 80);
        gd.addCheckbox("Enable_2D_diffusion", settings.diffuse2D);
        gd.addCheckbox("Rotate_initial_orientation", settings.rotateInitialOrientation);
        gd.addCheckbox("Rotate_during_simulation", settings.rotateDuringSimulation);
        gd.addCheckbox("Enable_2D_rotation", settings.rotate2D);
        gd.addCheckbox("Show_example_compounds", false);
        if (Utils.isShowGenericDialog()) {
            @SuppressWarnings("rawtypes") Vector v = gd.getCheckboxes();
            Checkbox cb = (Checkbox) v.get(v.size() - 1);
            cb.addItemListener(this);
        }
        gd.showDialog();
        if (gd.wasCanceled())
            return false;
        settings.compoundText = gd.getNextText();
        settings.diffuse2D = gd.getNextBoolean();
        settings.rotateInitialOrientation = gd.getNextBoolean();
        settings.rotateDuringSimulation = gd.getNextBoolean();
        settings.rotate2D = gd.getNextBoolean();
        if (gd.getNextBoolean()) {
            logExampleCompounds();
            return false;
        }
    }
    SettingsManager.saveSettings(globalSettings);
    gd = new GenericDialog(TITLE);
    gd.addMessage("Configure the photon distribution: " + settings.photonDistribution);
    if (PHOTON_DISTRIBUTION[PHOTON_CUSTOM].equals(settings.photonDistribution)) {
        // Nothing more to be done
        return true;
    } else if (PHOTON_DISTRIBUTION[PHOTON_UNIFORM].equals(settings.photonDistribution)) {
        gd.addNumericField("Max_Photons (sec^-1)", settings.photonsPerSecondMaximum, 0);
    } else if (PHOTON_DISTRIBUTION[PHOTON_GAMMA].equals(settings.photonDistribution)) {
        gd.addNumericField("Photon_shape", settings.photonShape, 2);
    } else if (PHOTON_DISTRIBUTION[PHOTON_CORRELATED].equals(settings.photonDistribution)) {
        gd.addNumericField("Correlation (to total tOn)", settings.correlation, 2);
    } else {
        // Nothing more to be done
        return true;
    }
    gd.showDialog();
    if (gd.wasCanceled())
        return false;
    try {
        if (PHOTON_DISTRIBUTION[PHOTON_UNIFORM].equals(settings.photonDistribution)) {
            settings.photonsPerSecondMaximum = Math.abs((int) gd.getNextNumber());
            if (settings.photonsPerSecondMaximum < settings.photonsPerSecond)
                settings.photonsPerSecondMaximum = settings.photonsPerSecond;
        } else if (PHOTON_DISTRIBUTION[PHOTON_GAMMA].equals(settings.photonDistribution)) {
            settings.photonShape = Math.abs(gd.getNextNumber());
            Parameters.isAbove("Photon shape", settings.photonShape, 0);
        } else if (PHOTON_DISTRIBUTION[PHOTON_CORRELATED].equals(settings.photonDistribution)) {
            settings.correlation = gd.getNextNumber();
            Parameters.isEqualOrBelow("Correlation", settings.correlation, 1);
            Parameters.isEqualOrAbove("Correlation", settings.correlation, -1);
        }
    } catch (IllegalArgumentException e) {
        IJ.error(TITLE, e.getMessage());
        return false;
    }
    SettingsManager.saveSettings(globalSettings);
    return true;
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) GridBagLayout(java.awt.GridBagLayout) Color(java.awt.Color) Checkbox(java.awt.Checkbox) GenericDialog(ij.gui.GenericDialog) Component(java.awt.Component) Vector(java.util.Vector)

Example 27 with Checkbox

use of java.awt.Checkbox in project GDSC-SMLM by aherbert.

the class BatchPeakFit method showDialog.

/**
	 * Ask for parameters
	 * 
	 * @return True if not cancelled
	 */
private boolean showDialog() {
    GenericDialog gd = new GenericDialog(TITLE);
    gd.addHelp(About.HELP_URL);
    gd.addStringField("Config_filename", configFilename);
    gd.addCheckbox("Create_config_file", false);
    if (Utils.isShowGenericDialog()) {
        configFilenameText = (TextField) gd.getStringFields().get(0);
        configFilenameText.setColumns(30);
        configFilenameText.addMouseListener(this);
        Checkbox cb = (Checkbox) gd.getCheckboxes().get(0);
        cb.addItemListener(this);
    }
    gd.showDialog();
    if (gd.wasCanceled())
        return false;
    configFilename = gd.getNextString().trim();
    return true;
}
Also used : Checkbox(java.awt.Checkbox) GenericDialog(ij.gui.GenericDialog)

Example 28 with Checkbox

use of java.awt.Checkbox in project GDSC-SMLM by aherbert.

the class BatchPeakFit method itemStateChanged.

/*
	 * (non-Javadoc)
	 * 
	 * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
	 */
public void itemStateChanged(ItemEvent e) {
    // When the checkbox is clicked, create a default configuration file and update the
    // GenericDialog with the file location.		
    Checkbox cb = (Checkbox) e.getSource();
    if (cb.getState()) {
        cb.setState(false);
        Document doc = getDefaultSettingsXmlDocument();
        if (doc == null)
            return;
        try {
            // Look for nodes that are part of the fit configuration
            XPathFactory factory = XPathFactory.newInstance();
            XPath xpath = factory.newXPath();
            XPathExpression expr = xpath.compile("//gdsc.smlm.engine.FitEngineConfiguration//*");
            // For each node, add the name and value to the BatchParameters
            BatchSettings batchSettings = new BatchSettings();
            batchSettings.resultsDirectory = System.getProperty("java.io.tmpdir");
            batchSettings.images.add("/path/to/image.tif");
            Object result = expr.evaluate(doc, XPathConstants.NODESET);
            NodeList nodes = (NodeList) result;
            for (int i = 0; i < nodes.getLength(); i++) {
                Node node = nodes.item(i);
                if (// Only nodes with a single text entry
                node.getChildNodes().getLength() == 1) {
                    batchSettings.parameters.add(new ParameterSettings(node.getNodeName(), node.getTextContent()));
                }
            }
            // Save the settings file
            String[] path = Utils.decodePath(configFilenameText.getText());
            OpenDialog chooser = new OpenDialog("Settings_file", path[0], path[1]);
            if (chooser.getFileName() != null) {
                String newFilename = chooser.getDirectory() + chooser.getFileName();
                if (!newFilename.endsWith(".xml"))
                    newFilename += ".xml";
                FileOutputStream fs = null;
                try {
                    fs = new FileOutputStream(newFilename);
                    xs.toXML(batchSettings, fs);
                } finally {
                    if (fs != null) {
                        fs.close();
                    }
                }
                // Update dialog filename
                configFilenameText.setText(newFilename);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
Also used : XPath(javax.xml.xpath.XPath) XPathExpression(javax.xml.xpath.XPathExpression) ParameterSettings(gdsc.smlm.ij.settings.ParameterSettings) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Document(org.w3c.dom.Document) TransformerException(javax.xml.transform.TransformerException) XStreamException(com.thoughtworks.xstream.XStreamException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) OpenDialog(ij.io.OpenDialog) XPathFactory(javax.xml.xpath.XPathFactory) BatchSettings(gdsc.smlm.ij.settings.BatchSettings) Checkbox(java.awt.Checkbox) FileOutputStream(java.io.FileOutputStream)

Example 29 with Checkbox

use of java.awt.Checkbox in project GDSC-SMLM by aherbert.

the class BenchmarkFilterAnalysis method showScoreDialog.

private boolean showScoreDialog() {
    GenericDialog gd = new GenericDialog(TITLE);
    gd.addHelp(About.HELP_URL);
    addSimulationData(gd);
    // Get the last scored filter or default to the best filter
    getScoreFilter();
    gd.addSlider("Fail_count", 0, 20, scoreFailCount);
    if (BenchmarkSpotFit.computeDoublets)
        gd.addSlider("Residuals_threshold", 0.01, 1, scoreResidualsThreshold);
    gd.addNumericField("Duplicate_distance", scoreDuplicateDistance, 2);
    gd.addTextAreas(XmlUtils.convertQuotes(scoreFilter.toXML()), null, 6, 60);
    gd.addCheckbox("Reset_filter", false);
    //gd.addCheckbox("Show_table", showResultsTable);
    gd.addCheckbox("Show_summary", showSummaryTable);
    gd.addCheckbox("Clear_tables", clearTables);
    //gd.addSlider("Summary_top_n", 0, 20, summaryTopN);
    gd.addCheckbox("Save_best_filter", saveBestFilter);
    gd.addCheckbox("Save_template", saveTemplate);
    gd.addCheckbox("Calculate_sensitivity", calculateSensitivity);
    gd.addSlider("Delta", 0.01, 1, delta);
    if (!simulationParameters.fixedDepth)
        gd.addCheckbox("Depth_recall_analysis", depthRecallAnalysis);
    gd.addCheckbox("Score_analysis", scoreAnalysis);
    gd.addChoice("Component_analysis", COMPONENT_ANALYSIS, COMPONENT_ANALYSIS[componentAnalysis]);
    gd.addStringField("Title", resultsTitle, 20);
    String[] labels = { "Show_TP", "Show_FP", "Show_FN" };
    gd.addCheckboxGroup(1, 3, labels, new boolean[] { showTP, showFP, showFN });
    // Dialog to have a reset checkbox. This reverts back to the default.
    if (Utils.isShowGenericDialog()) {
        final Checkbox cb = (Checkbox) (gd.getCheckboxes().get(0));
        @SuppressWarnings("unchecked") final Vector<TextField> v = gd.getNumericFields();
        final TextArea ta = gd.getTextArea1();
        cb.addItemListener(new ItemListener() {

            public void itemStateChanged(ItemEvent e) {
                if (cb.getState()) {
                    scoreFilter = null;
                    getScoreFilter();
                    int i = 0;
                    v.get(i++).setText(Integer.toString(scoreFailCount));
                    if (BenchmarkSpotFit.computeDoublets)
                        v.get(i++).setText(Double.toString(scoreResidualsThreshold));
                    v.get(i++).setText(Double.toString(scoreDuplicateDistance));
                    ta.setText(XmlUtils.convertQuotes(scoreFilter.toXML()));
                }
            }
        });
    }
    gd.showDialog();
    if (gd.wasCanceled())
        return false;
    scoreFailCount = (int) Math.abs(gd.getNextNumber());
    if (BenchmarkSpotFit.computeDoublets)
        scoreResidualsThreshold = Math.abs(gd.getNextNumber());
    scoreDuplicateDistance = Math.abs(gd.getNextNumber());
    String xml = gd.getNextText();
    try {
        scoreFilter = (DirectFilter) DirectFilter.fromXML(xml);
    } catch (Exception e) {
        scoreFilter = null;
        getScoreFilter();
    }
    boolean reset = gd.getNextBoolean();
    if (reset) {
        scoreFilter = null;
        getScoreFilter();
    }
    //showResultsTable = gd.getNextBoolean();
    showSummaryTable = gd.getNextBoolean();
    clearTables = gd.getNextBoolean();
    //summaryTopN = (int) Math.abs(gd.getNextNumber());
    saveBestFilter = gd.getNextBoolean();
    saveTemplate = gd.getNextBoolean();
    calculateSensitivity = gd.getNextBoolean();
    delta = gd.getNextNumber();
    if (!simulationParameters.fixedDepth)
        depthRecallAnalysis = gd.getNextBoolean();
    scoreAnalysis = gd.getNextBoolean();
    componentAnalysis = gd.getNextChoiceIndex();
    resultsTitle = gd.getNextString();
    showTP = gd.getNextBoolean();
    showFP = gd.getNextBoolean();
    showFN = gd.getNextBoolean();
    if (gd.invalidNumber())
        return false;
    resultsPrefix = BenchmarkSpotFit.resultPrefix + "\t" + resultsTitle + "\t";
    createResultsPrefix2(scoreFailCount, scoreResidualsThreshold, scoreDuplicateDistance);
    // Check there is one output
    if (!showSummaryTable && !calculateSensitivity && !saveBestFilter && !saveTemplate) {
        IJ.error(TITLE, "No output selected");
        return false;
    }
    // Check arguments
    try {
        Parameters.isAboveZero("Delta", delta);
        Parameters.isBelow("Delta", delta, 1);
    } catch (IllegalArgumentException e) {
        IJ.error(TITLE, e.getMessage());
        return false;
    }
    if (!selectTableColumns())
        return false;
    return true;
}
Also used : ItemEvent(java.awt.event.ItemEvent) TextArea(java.awt.TextArea) IOException(java.io.IOException) Checkbox(java.awt.Checkbox) GenericDialog(ij.gui.GenericDialog) NonBlockingGenericDialog(ij.gui.NonBlockingGenericDialog) TextField(java.awt.TextField) ItemListener(java.awt.event.ItemListener)

Example 30 with Checkbox

use of java.awt.Checkbox in project GDSC-SMLM by aherbert.

the class FreeFilterResults method showDialog.

private boolean showDialog() {
    ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
    gd.addHelp(About.HELP_URL);
    gd.addMessage("Select a dataset to filter");
    ResultsManager.addInput(gd, inputOption, InputSource.MEMORY);
    GlobalSettings gs = SettingsManager.loadSettings();
    filterSettings = gs.getFilterSettings();
    String text;
    try {
        text = XmlUtils.prettyPrintXml(filterSettings.freeFilter);
    } catch (Exception e) {
        text = filterSettings.freeFilter;
    }
    gd.addTextAreas(text, null, 20, 80);
    gd.addCheckbox("Show_demo_filters", false);
    if (Utils.isShowGenericDialog()) {
        Checkbox cb = (Checkbox) gd.getCheckboxes().get(0);
        cb.addItemListener(this);
    }
    gd.showDialog();
    if (gd.wasCanceled())
        return false;
    inputOption = ResultsManager.getInputSource(gd);
    filterSettings.freeFilter = gd.getNextText();
    boolean demoFilters = gd.getNextBoolean();
    if (demoFilters) {
        logDemoFilters(TITLE);
        return false;
    }
    return SettingsManager.saveSettings(gs);
}
Also used : Checkbox(java.awt.Checkbox) GlobalSettings(gdsc.smlm.ij.settings.GlobalSettings) ExtendedGenericDialog(ij.gui.ExtendedGenericDialog)

Aggregations

Checkbox (java.awt.Checkbox)54 TextField (java.awt.TextField)21 Choice (java.awt.Choice)18 GenericDialog (ij.gui.GenericDialog)13 ExtendedGenericDialog (uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)11 Vector (java.util.Vector)9 Component (java.awt.Component)8 Label (java.awt.Label)8 GlobalSettings (gdsc.smlm.ij.settings.GlobalSettings)7 Panel (java.awt.Panel)7 GridBagLayout (java.awt.GridBagLayout)5 SOCGameOption (soc.game.SOCGameOption)5 BasePoint (gdsc.core.match.BasePoint)4 PeakResultPoint (gdsc.smlm.ij.plugins.ResultsMatchCalculator.PeakResultPoint)4 Color (java.awt.Color)4 GridBagConstraints (java.awt.GridBagConstraints)4 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 CalibrationWriter (uk.ac.sussex.gdsc.smlm.data.config.CalibrationWriter)4 FitConfiguration (uk.ac.sussex.gdsc.smlm.engine.FitConfiguration)4