Search in sources :

Example 11 with Checkbox

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

the class BenchmarkSpotFit method itemStateChanged.

public void itemStateChanged(ItemEvent e) {
    if (e.getSource() instanceof Checkbox) {
        Checkbox checkbox = (Checkbox) e.getSource();
        int failLimit;
        boolean includeNeighbours;
        double neighbourHeightThrehsold;
        boolean computeDoublets;
        MultiPathFilter myMultiFilter;
        if (checkbox.getState()) {
            FitConfiguration tmpFitConfig = new FitConfiguration();
            FitEngineConfiguration tmp = new FitEngineConfiguration(tmpFitConfig);
            // Collect residuals threshold
            tmpFitConfig.setComputeResiduals(true);
            if (BenchmarkFilterAnalysis.updateConfiguration(tmp, false)) {
                failLimit = tmp.getFailuresLimit();
                includeNeighbours = tmp.isIncludeNeighbours();
                neighbourHeightThrehsold = tmp.getNeighbourHeightThreshold();
                computeDoublets = tmp.getResidualsThreshold() < 1;
                final DirectFilter primaryFilter = tmpFitConfig.getSmartFilter();
                final double residualsThreshold = tmp.getResidualsThreshold();
                myMultiFilter = new MultiPathFilter(primaryFilter, minimalFilter, residualsThreshold);
            } else {
                IJ.log("Failed to update settings using the filter analysis");
                checkbox.setState(false);
                return;
            }
        } else {
            failLimit = config.getFailuresLimit();
            includeNeighbours = config.isIncludeNeighbours();
            neighbourHeightThrehsold = config.getNeighbourHeightThreshold();
            computeDoublets = BenchmarkSpotFit.computeDoublets;
            myMultiFilter = multiFilter;
        }
        // Update the dialog
        taFilterXml.setText(myMultiFilter.toXML());
        textFailLimit.setText("" + failLimit);
        cbIncludeNeighbours.setState(includeNeighbours);
        textNeighbourHeight.setText(Utils.rounded(neighbourHeightThrehsold));
        cbComputeDoublets.setState(computeDoublets);
    }
}
Also used : Checkbox(java.awt.Checkbox) FitConfiguration(gdsc.smlm.fitting.FitConfiguration) FitEngineConfiguration(gdsc.smlm.engine.FitEngineConfiguration) DirectFilter(gdsc.smlm.results.filter.DirectFilter) MultiPathFilter(gdsc.smlm.results.filter.MultiPathFilter) PeakResultPoint(gdsc.smlm.ij.plugins.ResultsMatchCalculator.PeakResultPoint) BasePoint(gdsc.core.match.BasePoint)

Example 12 with Checkbox

use of java.awt.Checkbox in project jdk8u_jdk by JetBrains.

the class DrawControls method paint.

@Override
public void paint(Graphics g) {
    Rectangle r = getBounds();
    g.setColor(Color.lightGray);
    g.draw3DRect(0, 0, r.width, r.height, false);
    int n = getComponentCount();
    for (int i = 0; i < n; i++) {
        Component comp = getComponent(i);
        if (comp instanceof Checkbox) {
            Point loc = comp.getLocation();
            Dimension d = comp.getSize();
            g.setColor(comp.getForeground());
            g.drawRect(loc.x - 1, loc.y - 1, d.width + 1, d.height + 1);
        }
    }
}
Also used : Checkbox(java.awt.Checkbox) Rectangle(java.awt.Rectangle) Point(java.awt.Point) Dimension(java.awt.Dimension) Component(java.awt.Component) Point(java.awt.Point)

Example 13 with Checkbox

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

the class Configuration method showDialog.

/**
	 * Show the current properties
	 */
@SuppressWarnings("unchecked")
public void showDialog() {
    configurationChanged = false;
    String filename = SettingsManager.getSettingsFilename();
    GlobalSettings settings = SettingsManager.loadSettings(filename);
    FitEngineConfiguration config = settings.getFitEngineConfiguration();
    FitConfiguration fitConfig = config.getFitConfiguration();
    Calibration calibration = settings.getCalibration();
    GenericDialog gd = new GenericDialog(TITLE);
    gd.addHelp(About.HELP_URL);
    gd.addMessage("Configuration settings for the single-molecule localisation microscopy plugins");
    gd.addStringField("Config_file", filename, 40);
    gd.addNumericField("Calibration (nm/px)", calibration.getNmPerPixel(), 2);
    gd.addNumericField("Gain", calibration.getGain(), 2);
    gd.addCheckbox("EM-CCD", calibration.isEmCCD());
    gd.addNumericField("Exposure_time (ms)", calibration.getExposureTime(), 2);
    gd.addMessage("--- Gaussian parameters ---");
    gd.addNumericField("Initial_StdDev0", fitConfig.getInitialPeakStdDev0(), 3);
    gd.addNumericField("Initial_StdDev1", fitConfig.getInitialPeakStdDev1(), 3);
    gd.addNumericField("Initial_Angle", fitConfig.getInitialAngle(), 3);
    gd.addMessage("--- Maxima identification ---");
    String[] filterTypes = SettingsManager.getNames((Object[]) DataFilterType.values());
    gd.addChoice("Spot_filter_type", filterTypes, filterTypes[config.getDataFilterType().ordinal()]);
    String[] filterNames = SettingsManager.getNames((Object[]) DataFilter.values());
    gd.addChoice("Spot_filter", filterNames, filterNames[config.getDataFilter(0).ordinal()]);
    gd.addSlider("Smoothing", 0, 2.5, config.getSmooth(0));
    gd.addSlider("Search_width", 0.5, 2.5, config.getSearch());
    gd.addSlider("Border", 0.5, 2.5, config.getBorder());
    gd.addSlider("Fitting_width", 2, 4.5, config.getFitting());
    gd.addMessage("--- Gaussian fitting ---");
    Component splitLabel = gd.getMessage();
    String[] solverNames = SettingsManager.getNames((Object[]) FitSolver.values());
    gd.addChoice("Fit_solver", solverNames, solverNames[fitConfig.getFitSolver().ordinal()]);
    String[] functionNames = SettingsManager.getNames((Object[]) FitFunction.values());
    gd.addChoice("Fit_function", functionNames, functionNames[fitConfig.getFitFunction().ordinal()]);
    // Parameters specific to each Fit solver are collected in a second dialog 
    gd.addNumericField("Fail_limit", config.getFailuresLimit(), 0);
    gd.addCheckbox("Include_neighbours", config.isIncludeNeighbours());
    gd.addSlider("Neighbour_height", 0.01, 1, config.getNeighbourHeightThreshold());
    gd.addSlider("Residuals_threshold", 0.01, 1, config.getResidualsThreshold());
    gd.addSlider("Duplicate_distance", 0, 1.5, fitConfig.getDuplicateDistance());
    gd.addMessage("--- Peak filtering ---\nDiscard fits that shift; are too low; or expand/contract");
    gd.addCheckbox("Smart_filter", fitConfig.isSmartFilter());
    gd.addCheckbox("Disable_simple_filter", fitConfig.isDisableSimpleFilter());
    gd.addSlider("Shift_factor", 0.01, 2, fitConfig.getCoordinateShiftFactor());
    gd.addNumericField("Signal_strength", fitConfig.getSignalStrength(), 2);
    gd.addNumericField("Min_photons", fitConfig.getMinPhotons(), 0);
    gd.addSlider("Min_width_factor", 0, 0.99, fitConfig.getMinWidthFactor());
    gd.addSlider("Width_factor", 1.01, 5, fitConfig.getWidthFactor());
    gd.addNumericField("Precision_threshold", fitConfig.getPrecisionThreshold(), 2);
    // Add a mouse listener to the config file field
    if (Utils.isShowGenericDialog()) {
        Vector<TextField> texts = (Vector<TextField>) gd.getStringFields();
        Vector<TextField> numerics = (Vector<TextField>) gd.getNumericFields();
        Vector<Checkbox> checkboxes = (Vector<Checkbox>) gd.getCheckboxes();
        Vector<Choice> choices = (Vector<Choice>) gd.getChoices();
        int n = 0;
        int t = 0;
        int b = 0;
        int ch = 0;
        textConfigFile = texts.get(t++);
        textConfigFile.addMouseListener(this);
        textConfigFile.addTextListener(this);
        // TODO: add a value changed listener to detect when typing a new file
        textNmPerPixel = numerics.get(n++);
        textGain = numerics.get(n++);
        textEMCCD = checkboxes.get(b++);
        textExposure = numerics.get(n++);
        textInitialPeakStdDev0 = numerics.get(n++);
        textInitialPeakStdDev1 = numerics.get(n++);
        textInitialAngleD = numerics.get(n++);
        textDataFilterType = choices.get(ch++);
        textDataFilter = choices.get(ch++);
        textSmooth = numerics.get(n++);
        textSearch = numerics.get(n++);
        textBorder = numerics.get(n++);
        textFitting = numerics.get(n++);
        textFitSolver = choices.get(ch++);
        textFitFunction = choices.get(ch++);
        textFailuresLimit = numerics.get(n++);
        textIncludeNeighbours = checkboxes.get(b++);
        textNeighbourHeightThreshold = numerics.get(n++);
        textResidualsThreshold = numerics.get(n++);
        textDuplicateDistance = numerics.get(n++);
        textSmartFilter = checkboxes.get(b++);
        textDisableSimpleFilter = checkboxes.get(b++);
        textCoordinateShiftFactor = numerics.get(n++);
        textSignalStrength = numerics.get(n++);
        textMinPhotons = numerics.get(n++);
        textMinWidthFactor = numerics.get(n++);
        textWidthFactor = numerics.get(n++);
        textPrecisionThreshold = numerics.get(n++);
        updateFilterInput();
        textSmartFilter.addItemListener(this);
        textDisableSimpleFilter.addItemListener(this);
    }
    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) {
                xOffset += 2;
                yOffset -= rowCount;
            }
            // 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;
    filename = gd.getNextString();
    calibration.setNmPerPixel(gd.getNextNumber());
    calibration.setGain(gd.getNextNumber());
    calibration.setEmCCD(gd.getNextBoolean());
    calibration.setExposureTime(gd.getNextNumber());
    fitConfig.setInitialPeakStdDev0(gd.getNextNumber());
    fitConfig.setInitialPeakStdDev1(gd.getNextNumber());
    fitConfig.setInitialAngleD(gd.getNextNumber());
    config.setDataFilterType(gd.getNextChoiceIndex());
    config.setDataFilter(gd.getNextChoiceIndex(), Math.abs(gd.getNextNumber()), 0);
    config.setSearch(gd.getNextNumber());
    config.setBorder(gd.getNextNumber());
    config.setFitting(gd.getNextNumber());
    fitConfig.setFitSolver(gd.getNextChoiceIndex());
    fitConfig.setFitFunction(gd.getNextChoiceIndex());
    config.setFailuresLimit((int) gd.getNextNumber());
    config.setIncludeNeighbours(gd.getNextBoolean());
    config.setNeighbourHeightThreshold(gd.getNextNumber());
    config.setResidualsThreshold(gd.getNextNumber());
    fitConfig.setDuplicateDistance(gd.getNextNumber());
    fitConfig.setSmartFilter(gd.getNextBoolean());
    fitConfig.setDisableSimpleFilter(gd.getNextBoolean());
    fitConfig.setCoordinateShiftFactor(gd.getNextNumber());
    fitConfig.setSignalStrength(gd.getNextNumber());
    fitConfig.setMinPhotons(gd.getNextNumber());
    fitConfig.setMinWidthFactor(gd.getNextNumber());
    fitConfig.setWidthFactor(gd.getNextNumber());
    fitConfig.setPrecisionThreshold(gd.getNextNumber());
    // Check arguments
    try {
        Parameters.isAboveZero("nm per pixel", calibration.getNmPerPixel());
        Parameters.isAboveZero("Gain", calibration.getGain());
        Parameters.isAboveZero("Exposure time", calibration.getExposureTime());
        Parameters.isAboveZero("Initial SD0", fitConfig.getInitialPeakStdDev0());
        Parameters.isAboveZero("Initial SD1", fitConfig.getInitialPeakStdDev1());
        Parameters.isPositive("Initial angle", fitConfig.getInitialAngleD());
        Parameters.isAboveZero("Search_width", config.getSearch());
        Parameters.isAboveZero("Fitting_width", config.getFitting());
        Parameters.isPositive("Failures limit", config.getFailuresLimit());
        Parameters.isPositive("Neighbour height threshold", config.getNeighbourHeightThreshold());
        Parameters.isPositive("Residuals threshold", config.getResidualsThreshold());
        Parameters.isPositive("Duplicate distance", fitConfig.getDuplicateDistance());
        Parameters.isPositive("Coordinate Shift factor", fitConfig.getCoordinateShiftFactor());
        Parameters.isPositive("Signal strength", fitConfig.getSignalStrength());
        Parameters.isPositive("Min photons", fitConfig.getMinPhotons());
        Parameters.isPositive("Min width factor", fitConfig.getMinWidthFactor());
        Parameters.isPositive("Width factor", fitConfig.getWidthFactor());
        Parameters.isPositive("Precision threshold", fitConfig.getPrecisionThreshold());
    } catch (IllegalArgumentException e) {
        IJ.error(TITLE, e.getMessage());
        return;
    }
    if (gd.invalidNumber())
        return;
    configurationChanged = SettingsManager.saveSettings(settings, filename);
    if (configurationChanged)
        SettingsManager.saveSettingsFilename(filename);
    if (!PeakFit.configureSmartFilter(settings, filename))
        return;
    if (!PeakFit.configureDataFilter(settings, filename, false))
        return;
    PeakFit.configureFitSolver(settings, filename, false);
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Choice(java.awt.Choice) GridBagLayout(java.awt.GridBagLayout) FitEngineConfiguration(gdsc.smlm.engine.FitEngineConfiguration) Color(java.awt.Color) SystemColor(java.awt.SystemColor) GlobalSettings(gdsc.smlm.ij.settings.GlobalSettings) Calibration(gdsc.smlm.results.Calibration) FitConfiguration(gdsc.smlm.fitting.FitConfiguration) Checkbox(java.awt.Checkbox) GenericDialog(ij.gui.GenericDialog) TextField(java.awt.TextField) Component(java.awt.Component) Vector(java.util.Vector)

Example 14 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 15 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)

Aggregations

Checkbox (java.awt.Checkbox)24 GenericDialog (ij.gui.GenericDialog)9 TextField (java.awt.TextField)9 Choice (java.awt.Choice)8 GlobalSettings (gdsc.smlm.ij.settings.GlobalSettings)7 Vector (java.util.Vector)7 Component (java.awt.Component)5 GridBagLayout (java.awt.GridBagLayout)5 BasePoint (gdsc.core.match.BasePoint)4 FitEngineConfiguration (gdsc.smlm.engine.FitEngineConfiguration)4 FitConfiguration (gdsc.smlm.fitting.FitConfiguration)4 PeakResultPoint (gdsc.smlm.ij.plugins.ResultsMatchCalculator.PeakResultPoint)4 GridBagConstraints (java.awt.GridBagConstraints)4 ExtendedGenericDialog (ij.gui.ExtendedGenericDialog)3 Color (java.awt.Color)3 Panel (java.awt.Panel)3 DirectFilter (gdsc.smlm.results.filter.DirectFilter)2 MultiPathFilter (gdsc.smlm.results.filter.MultiPathFilter)2 BorderLayout (java.awt.BorderLayout)2 Button (java.awt.Button)2