Search in sources :

Example 1 with ImageMode

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

the class OPTICS method showDialog.

private boolean showDialog(boolean isDBSCAN) {
    logReferences(isDBSCAN);
    NonBlockingExtendedGenericDialog gd = new NonBlockingExtendedGenericDialog(TITLE);
    gd.addHelp(About.HELP_URL);
    ResultsManager.addInput(gd, inputSettings.inputOption, InputSource.MEMORY);
    //globalSettings = SettingsManager.loadSettings();
    //settings = globalSettings.getClusteringSettings();
    gd.addMessage("--- " + TITLE + " ---");
    gd.addNumericField("Min_points", inputSettings.minPoints, 0);
    if (isDBSCAN) {
        // Add fields to auto-compute the clustering distance from the K-nearest neighbour distance profile
        gd.addSlider("Noise (%)", 0, 50, inputSettings.fractionNoise * 100);
        gd.addNumericField("Samples", inputSettings.samples, 0);
        gd.addSlider("Sample_fraction (%)", 0, 15, inputSettings.sampleFraction * 100);
        gd.addNumericField("Clustering_distance", inputSettings.clusteringDistance, 2, 6, "nm");
    } else {
        String[] opticsModes = SettingsManager.getNames((Object[]) OPTICSMode.values());
        gd.addChoice("OPTICS_mode", opticsModes, inputSettings.getOPTICSMode().toString());
        gd.addNumericField("Number_of_splits", inputSettings.numberOfSplitSets, 0);
        if (extraOptions) {
            gd.addCheckbox("Random_vectors", inputSettings.useRandomVectors);
            gd.addCheckbox("Approx_sets", inputSettings.saveApproximateSets);
            String[] sampleModes = SettingsManager.getNames((Object[]) SampleMode.values());
            gd.addChoice("Sample_mode", sampleModes, inputSettings.getSampleMode().toString());
        }
        gd.addNumericField("Generating_distance", inputSettings.generatingDistance, 2, 6, "nm");
    }
    gd.addMessage("--- Clustering ---");
    if (isDBSCAN) {
        gd.addCheckbox("Core_points", inputSettings.core);
    } else {
        String[] clusteringModes = SettingsManager.getNames((Object[]) ClusteringMode.values());
        gd.addChoice("Clustering_mode", clusteringModes, inputSettings.getClusteringMode().toString());
        gd.addMessage(ClusteringMode.XI.toString() + " options:\n" + ClusteringMode.XI.toString() + " controls the change in reachability (profile steepness) to define a cluster");
        gd.addNumericField("Xi", inputSettings.xi, 4);
        gd.addCheckbox("Top_clusters", inputSettings.topLevel);
        gd.addNumericField("Upper_limit", inputSettings.upperLimit, 4);
        gd.addNumericField("Lower_limit", inputSettings.lowerLimit, 4);
        gd.addMessage(ClusteringMode.DBSCAN.toString() + " options:");
        gd.addNumericField("Clustering_distance", inputSettings.clusteringDistance, 4);
        gd.addCheckbox("Core_points", inputSettings.core);
    }
    gd.addMessage("--- Image ---");
    gd.addSlider("Image_scale", 0, 15, inputSettings.imageScale);
    TreeSet<ImageMode> imageModeSet = new TreeSet<ImageMode>();
    imageModeSet.addAll(Arrays.asList(ImageMode.values()));
    if (isDBSCAN) {
        imageModeSet.remove(ImageMode.CLUSTER_DEPTH);
        imageModeSet.remove(ImageMode.CLUSTER_ORDER);
    }
    imageModeArray = imageModeSet.toArray();
    String[] imageModes = SettingsManager.getNames(imageModeArray);
    gd.addChoice("Image_mode", imageModes, inputSettings.getImageMode().toString());
    gd.addCheckboxGroup(1, 2, new String[] { "Weighted", "Equalised" }, new boolean[] { inputSettings.weighted, inputSettings.equalised }, new String[] { "Image" });
    if (extraOptions) {
        gd.addNumericField("LoOP_lambda", inputSettings.lambda, 4);
    }
    TreeSet<OutlineMode> outlineModeSet = new TreeSet<OutlineMode>();
    outlineModeSet.addAll(Arrays.asList(OutlineMode.values()));
    if (isDBSCAN) {
        outlineModeSet.remove(OutlineMode.COLOURED_BY_DEPTH);
    }
    outlineModeArray = outlineModeSet.toArray();
    String[] outlineModes = SettingsManager.getNames(outlineModeArray);
    gd.addChoice("Outline", outlineModes, inputSettings.getOutlineMode().toString());
    if (!isDBSCAN) {
        String[] spanningTreeModes = SettingsManager.getNames((Object[]) SpanningTreeMode.values());
        gd.addChoice("Spanning_tree", spanningTreeModes, spanningTreeModes[inputSettings.getSpanningTreeModeOridinal()]);
        gd.addMessage("--- Reachability Plot ---");
        String[] plotModes = SettingsManager.getNames((Object[]) PlotMode.values());
        gd.addChoice("Plot_mode", plotModes, plotModes[inputSettings.getPlotModeOridinal()]);
    }
    // Start disabled so the user can choose settings to update
    gd.addCheckbox("Preview", false);
    if (extraOptions)
        gd.addCheckbox("Debug", false);
    // Everything is done within the dialog listener
    if (isDBSCAN)
        gd.addDialogListener(new DBSCANDialogListener());
    else
        gd.addDialogListener(new OPTICSDialogListener());
    gd.showDialog();
    if (gd.wasCanceled())
        return false;
    // The dialog was OK'd so run if work was staged in the workflow.
    if (workflow.isStaged())
        workflow.runStaged();
    // Record the options for macros since the NonBlocking dialog does not
    if (Recorder.record) {
        Recorder.recordOption("Min_points", Integer.toString(inputSettings.minPoints));
        if (isDBSCAN) {
            // Add fields to auto-compute the clustering distance from the K-nearest neighbour distance profile
            Recorder.recordOption("Noise", Double.toString(inputSettings.fractionNoise * 100));
            Recorder.recordOption("Samples", Double.toString(inputSettings.samples));
            Recorder.recordOption("Sample_fraction", Double.toString(inputSettings.sampleFraction * 100));
            Recorder.recordOption("Clustering_distance", Double.toString(inputSettings.clusteringDistance));
        } else {
            Recorder.recordOption("OPTICS_mode", inputSettings.getOPTICSMode().toString());
            Recorder.recordOption("Number_of_splits", Integer.toString(inputSettings.numberOfSplitSets));
            if (extraOptions) {
                if (inputSettings.useRandomVectors)
                    Recorder.recordOption("Random_vectors");
                if (inputSettings.saveApproximateSets)
                    Recorder.recordOption("Approx_sets");
                Recorder.recordOption("Sample_mode", inputSettings.getSampleMode().toString());
            }
            Recorder.recordOption("Generating_distance", Double.toString(inputSettings.generatingDistance));
        }
        if (isDBSCAN) {
            if (inputSettings.core)
                Recorder.recordOption("Core_points");
        } else {
            Recorder.recordOption("Clustering_mode", inputSettings.getClusteringMode().toString());
            Recorder.recordOption("Xi", Double.toString(inputSettings.xi));
            if (inputSettings.topLevel)
                Recorder.recordOption("Top_clusters");
            Recorder.recordOption("Upper_limit", Double.toString(inputSettings.upperLimit));
            Recorder.recordOption("Lower_limit", Double.toString(inputSettings.lowerLimit));
            Recorder.recordOption("Clustering_distance", Double.toString(inputSettings.clusteringDistance));
            if (inputSettings.core)
                Recorder.recordOption("Core_points");
        }
        gd.addMessage("--- Image ---");
        Recorder.recordOption("Image_scale", Double.toString(inputSettings.imageScale));
        Recorder.recordOption("Image_mode", inputSettings.getImageMode().toString());
        if (inputSettings.weighted)
            Recorder.recordOption("Weighted");
        if (inputSettings.equalised)
            Recorder.recordOption("Equalised");
        if (extraOptions) {
            Recorder.recordOption("LoOP_lambda", Double.toString(inputSettings.lambda));
        }
        Recorder.recordOption("Outline", inputSettings.getOutlineMode().toString());
        if (!isDBSCAN) {
            Recorder.recordOption("Spanning_tree", inputSettings.getSpanningTreeMode().toString());
            Recorder.recordOption("Plot_mode", inputSettings.getPlotMode().toString());
        }
        if (debug)
            Recorder.recordOption("Debug");
    }
    return true;
}
Also used : TreeSet(java.util.TreeSet) NonBlockingExtendedGenericDialog(ij.gui.NonBlockingExtendedGenericDialog) ImageMode(gdsc.smlm.ij.settings.OPTICSSettings.ImageMode) OutlineMode(gdsc.smlm.ij.settings.OPTICSSettings.OutlineMode)

Aggregations

ImageMode (gdsc.smlm.ij.settings.OPTICSSettings.ImageMode)1 OutlineMode (gdsc.smlm.ij.settings.OPTICSSettings.OutlineMode)1 NonBlockingExtendedGenericDialog (ij.gui.NonBlockingExtendedGenericDialog)1 TreeSet (java.util.TreeSet)1