Search in sources :

Example 1 with GlobalSettings

use of gdsc.smlm.ij.settings.GlobalSettings in project GDSC-SMLM by aherbert.

the class PSFCreator method loadConfiguration.

private void loadConfiguration() {
    final String filename = SettingsManager.getSettingsFilename();
    GlobalSettings settings = SettingsManager.loadSettings(filename);
    nmPerPixel = settings.getCalibration().getNmPerPixel();
    config = settings.getFitEngineConfiguration();
    fitConfig = config.getFitConfiguration();
    if (radius < 5 * FastMath.max(fitConfig.getInitialPeakStdDev0(), fitConfig.getInitialPeakStdDev1())) {
        radius = 5 * FastMath.max(fitConfig.getInitialPeakStdDev0(), fitConfig.getInitialPeakStdDev1());
        Utils.log("Radius is less than 5 * PSF standard deviation, increasing to %s", Utils.rounded(radius));
    }
    boxRadius = (int) Math.ceil(radius);
}
Also used : GlobalSettings(gdsc.smlm.ij.settings.GlobalSettings)

Example 2 with GlobalSettings

use of gdsc.smlm.ij.settings.GlobalSettings in project GDSC-SMLM by aherbert.

the class PSFCalculator method run.

public void run(String arg) {
    SMLMUsageTracker.recordPlugin(this.getClass(), arg);
    GlobalSettings globalSettings = SettingsManager.loadSettings();
    settings = globalSettings.getPsfCalculatorSettings();
    double sd = calculate(settings, false);
    if (sd < 0)
        return;
    globalSettings.getFitEngineConfiguration().getFitConfiguration().setInitialPeakStdDev((float) sd);
    globalSettings.getFitEngineConfiguration().getFitConfiguration().setInitialAngle(0);
    globalSettings.getCalibration().setNmPerPixel(getPixelPitch());
    SettingsManager.saveSettings(globalSettings);
}
Also used : GlobalSettings(gdsc.smlm.ij.settings.GlobalSettings)

Example 3 with GlobalSettings

use of gdsc.smlm.ij.settings.GlobalSettings in project GDSC-SMLM by aherbert.

the class FilterResults method showDialog.

private boolean showDialog() {
    ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
    gd.addHelp(About.HELP_URL);
    GlobalSettings gs = SettingsManager.loadSettings();
    filterSettings = gs.getFilterSettings();
    checkLimits();
    gd.addSlider("Max_drift", minDrift, maxDrift, filterSettings.maxDrift);
    gd.addSlider("Min_Signal", minSignal, maxSignal, filterSettings.minSignal);
    gd.addSlider("Min_SNR", minSNR, maxSNR, filterSettings.minSNR);
    gd.addSlider("Min_Precision", minPrecision, maxPrecision, filterSettings.maxPrecision);
    // TODO - If calibrated present the widths in nm
    gd.addMessage("Average Width = " + IJ.d2s(averageWidth, 3));
    gd.addSlider("Min_Width", minWidth, maxWidth, filterSettings.minWidth);
    gd.addSlider("Max_Width", minWidth, maxWidth, filterSettings.maxWidth);
    // Get a list of potential mask images
    String[] items = getImageList();
    gd.addChoice("Mask", items, filterSettings.maskTitle);
    gd.showDialog();
    if (gd.wasCanceled())
        return false;
    filterSettings.maxDrift = (float) gd.getNextNumber();
    filterSettings.minSignal = (float) gd.getNextNumber();
    filterSettings.minSNR = (float) gd.getNextNumber();
    filterSettings.maxPrecision = (float) gd.getNextNumber();
    filterSettings.minWidth = (float) gd.getNextNumber();
    filterSettings.maxWidth = (float) gd.getNextNumber();
    filterSettings.maskTitle = gd.getNextChoice();
    return SettingsManager.saveSettings(gs);
}
Also used : GlobalSettings(gdsc.smlm.ij.settings.GlobalSettings) ExtendedGenericDialog(ij.gui.ExtendedGenericDialog)

Example 4 with GlobalSettings

use of gdsc.smlm.ij.settings.GlobalSettings in project GDSC-SMLM by aherbert.

the class FilterAnalysis method readFilterSets.

@SuppressWarnings("unchecked")
private List<FilterSet> readFilterSets() {
    GlobalSettings gs = SettingsManager.loadSettings();
    FilterSettings filterSettings = gs.getFilterSettings();
    String[] path = Utils.decodePath(filterSettings.filterSetFilename);
    OpenDialog chooser = new OpenDialog("Filter_File", path[0], path[1]);
    if (chooser.getFileName() != null) {
        IJ.showStatus("Reading filters ...");
        filterSettings.filterSetFilename = chooser.getDirectory() + chooser.getFileName();
        BufferedReader input = null;
        try {
            FileInputStream fis = new FileInputStream(filterSettings.filterSetFilename);
            input = new BufferedReader(new UnicodeReader(fis, null));
            Object o = XStreamWrapper.getInstance().fromXML(input);
            if (o != null && o instanceof List<?>) {
                SettingsManager.saveSettings(gs);
                return (List<FilterSet>) o;
            }
            IJ.log("No filter sets defined in the specified file: " + filterSettings.filterSetFilename);
        } catch (Exception e) {
            IJ.log("Unable to load the filter sets from file: " + e.getMessage());
        } finally {
            if (input != null) {
                try {
                    input.close();
                } catch (IOException e) {
                // Ignore
                }
            }
            IJ.showStatus("");
        }
    }
    return null;
}
Also used : GlobalSettings(gdsc.smlm.ij.settings.GlobalSettings) UnicodeReader(gdsc.core.utils.UnicodeReader) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) OpenDialog(ij.io.OpenDialog) BufferedReader(java.io.BufferedReader) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) FilterSettings(gdsc.smlm.ij.settings.FilterSettings)

Example 5 with GlobalSettings

use of gdsc.smlm.ij.settings.GlobalSettings in project GDSC-SMLM by aherbert.

the class DoubletAnalysis method itemStateChanged.

/*
	 * (non-Javadoc)
	 * 
	 * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
	 */
public void itemStateChanged(ItemEvent e) {
    if (e.getSource() instanceof Choice) {
        // Update the settings from the template
        Choice choice = (Choice) e.getSource();
        String templateName = choice.getSelectedItem();
        // Get the configuration template
        GlobalSettings template = ConfigurationTemplate.getTemplate(templateName);
        if (textCoordinateShiftFactor != null) {
            if (template != null) {
                if (template.isFitEngineConfiguration()) {
                    FitConfiguration fitConfig = template.getFitEngineConfiguration().getFitConfiguration();
                    cbSmartFilter.setState(fitConfig.isSmartFilter());
                    textCoordinateShiftFactor.setText("" + fitConfig.getCoordinateShiftFactor());
                    textSignalStrength.setText("" + fitConfig.getSignalStrength());
                    textMinPhotons.setText("" + fitConfig.getMinPhotons());
                    textMinWidthFactor.setText("" + fitConfig.getMinWidthFactor());
                    textWidthFactor.setText("" + fitConfig.getWidthFactor());
                    textPrecisionThreshold.setText("" + fitConfig.getPrecisionThreshold());
                    cbLocalBackground.setState(fitConfig.isPrecisionUsingBackground());
                }
            } else {
                // Reset 
                cbSmartFilter.setState(false);
                textCoordinateShiftFactor.setText("0");
                textSignalStrength.setText("0");
                textMinPhotons.setText("0");
                textMinWidthFactor.setText("0");
                textWidthFactor.setText("0");
                textPrecisionThreshold.setText("0");
                cbLocalBackground.setState(false);
            }
        } else {
            if (template != null) {
                if (template.isFitEngineConfiguration()) {
                    boolean custom = ConfigurationTemplate.isCustomTemplate(templateName);
                    FitEngineConfiguration config2 = template.getFitEngineConfiguration();
                    FitConfiguration fitConfig2 = config2.getFitConfiguration();
                    if (custom && fitConfig2.getInitialPeakStdDev0() > 0)
                        textInitialPeakStdDev0.setText("" + fitConfig2.getInitialPeakStdDev0());
                    textDataFilterType.select(config2.getDataFilterType().ordinal());
                    textDataFilter.select(config2.getDataFilter(0).ordinal());
                    textSmooth.setText("" + config2.getSmooth(0));
                    textSearch.setText("" + config2.getSearch());
                    textBorder.setText("" + config2.getBorder());
                    textFitting.setText("" + config2.getFitting());
                    textFitSolver.select(fitConfig2.getFitSolver().ordinal());
                    textFitFunction.select(fitConfig2.getFitFunction().ordinal());
                    // Copy settings not in the dialog for the fit solver
                    fitConfig.setMaxIterations(fitConfig2.getMaxIterations());
                    fitConfig.setMaxFunctionEvaluations(fitConfig2.getMaxFunctionEvaluations());
                    // MLE settings
                    fitConfig.setModelCamera(fitConfig2.isModelCamera());
                    fitConfig.setSearchMethod(fitConfig2.getSearchMethod());
                    fitConfig.setRelativeThreshold(fitConfig2.getRelativeThreshold());
                    fitConfig.setAbsoluteThreshold(fitConfig2.getAbsoluteThreshold());
                    fitConfig.setGradientLineMinimisation(fitConfig2.isGradientLineMinimisation());
                    // LSE settings
                    fitConfig.setFitCriteria(fitConfig2.getFitCriteria());
                    fitConfig.setSignificantDigits(fitConfig2.getSignificantDigits());
                    fitConfig.setDelta(fitConfig2.getDelta());
                    fitConfig.setLambda(fitConfig2.getLambda());
                }
            } else {
            // Ignore
            }
        }
    } else if (e.getSource() instanceof Checkbox) {
        Checkbox checkbox = (Checkbox) e.getSource();
        if (!checkbox.getState())
            return;
        if (textCoordinateShiftFactor != null) {
            if (!updateFilterConfiguration(filterFitConfig))
                return;
            cbSmartFilter.setState(filterFitConfig.isSmartFilter());
            textCoordinateShiftFactor.setText("" + filterFitConfig.getCoordinateShiftFactor());
            textSignalStrength.setText("" + filterFitConfig.getSignalStrength());
            textMinPhotons.setText("" + filterFitConfig.getMinPhotons());
            textMinWidthFactor.setText("" + filterFitConfig.getMinWidthFactor());
            textWidthFactor.setText("" + filterFitConfig.getWidthFactor());
            textPrecisionThreshold.setText("" + filterFitConfig.getPrecisionThreshold());
            cbLocalBackground.setState(filterFitConfig.isPrecisionUsingBackground());
        } else {
            if (!updateFitConfiguration(config))
                return;
            textInitialPeakStdDev0.setText("" + fitConfig.getInitialPeakStdDev0());
            textDataFilterType.select(config.getDataFilterType().ordinal());
            textDataFilter.select(config.getDataFilter(0).ordinal());
            textSmooth.setText("" + config.getSmooth(0));
            textSearch.setText("" + config.getSearch());
            textBorder.setText("" + config.getBorder());
            textFitting.setText("" + config.getFitting());
            textFitSolver.select(fitConfig.getFitSolver().ordinal());
            textFitFunction.select(fitConfig.getFitFunction().ordinal());
            textMatchDistance.setText("" + matchDistance);
            textLowerDistance.setText("" + lowerDistance);
            textSignalFactor.setText("" + signalFactor);
            textLowerFactor.setText("" + lowerSignalFactor);
        }
    }
}
Also used : Choice(java.awt.Choice) FitConfiguration(gdsc.smlm.fitting.FitConfiguration) FitEngineConfiguration(gdsc.smlm.engine.FitEngineConfiguration) Checkbox(java.awt.Checkbox) GlobalSettings(gdsc.smlm.ij.settings.GlobalSettings)

Aggregations

GlobalSettings (gdsc.smlm.ij.settings.GlobalSettings)34 FitEngineConfiguration (gdsc.smlm.engine.FitEngineConfiguration)9 GenericDialog (ij.gui.GenericDialog)9 FitConfiguration (gdsc.smlm.fitting.FitConfiguration)8 Checkbox (java.awt.Checkbox)7 ExtendedGenericDialog (ij.gui.ExtendedGenericDialog)6 Choice (java.awt.Choice)6 BasePoint (gdsc.core.match.BasePoint)5 FilterSettings (gdsc.smlm.ij.settings.FilterSettings)5 PeakResultPoint (gdsc.smlm.ij.plugins.ResultsMatchCalculator.PeakResultPoint)4 Calibration (gdsc.smlm.results.Calibration)4 Point (java.awt.Point)4 TextField (java.awt.TextField)4 Vector (java.util.Vector)4 MemoryPeakResults (gdsc.smlm.results.MemoryPeakResults)3 DirectFilter (gdsc.smlm.results.filter.DirectFilter)3 MultiPathFilter (gdsc.smlm.results.filter.MultiPathFilter)3 ImagePlus (ij.ImagePlus)3 OpenDialog (ij.io.OpenDialog)3 File (java.io.File)3