Search in sources :

Example 81 with ExtendedGenericDialog

use of uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog in project GDSC-SMLM by aherbert.

the class ClassificationMatchCalculator method showDialog.

private boolean showDialog() {
    final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
    settings = Settings.load();
    gd.addMessage("Compare the points in two results sets\nand compute the match statistics");
    ResultsManager.addInput(gd, "Results1", settings.inputOption1, InputSource.MEMORY_CLUSTERED, InputSource.MEMORY_CATEGORY);
    ResultsManager.addInput(gd, "Results2", settings.inputOption2, InputSource.MEMORY_CLUSTERED, InputSource.MEMORY_CATEGORY);
    gd.addNumericField("Match_distance", settings.matchDistance, -2, 6, "px");
    gd.addChoice("Use_id", ANALYSIS_OPTION, settings.useId.ordinal());
    gd.addChoice("Use_category", ANALYSIS_OPTION, settings.useCategory.ordinal());
    gd.addHelp(HelpUrls.getUrl("classification-match-calculator"));
    gd.showDialog();
    if (gd.wasCanceled()) {
        return false;
    }
    settings.inputOption1 = gd.getNextChoice();
    settings.inputOption2 = gd.getNextChoice();
    settings.matchDistance = gd.getNextNumber();
    settings.useId = ClassAnalysis.fromNumber(gd.getNextChoiceIndex());
    settings.useCategory = ClassAnalysis.fromNumber(gd.getNextChoiceIndex());
    settings.save();
    if (settings.useId.ordinal() + settings.useCategory.ordinal() == 0) {
        IJ.error(TITLE, "No classifications specified (id or category)");
        return false;
    }
    // Check arguments
    try {
        ParameterUtils.isPositive("Match distance", settings.matchDistance);
    } catch (final IllegalArgumentException ex) {
        IJ.error(TITLE, ex.getMessage());
        return false;
    }
    return true;
}
Also used : ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)

Example 82 with ExtendedGenericDialog

use of uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog in project GDSC-SMLM by aherbert.

the class AstigmatismModelManager method saveModel.

private boolean saveModel() {
    final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
    gd.addMessage("Save the model");
    gd.addCheckbox("Save_model", pluginSettings.getSaveModel());
    gd.addStringField("Model_name", pluginSettings.getModelName());
    gd.addMessage("Save the model width to this plugin's settings, e.g. to use\n" + "on another selected PSF when creating a model.");
    gd.addCheckbox("Save_fit_width", pluginSettings.getSaveFitWidth());
    gd.addHelp(HelpUrls.getUrl("astigmatism-model-manager-create"));
    gd.showDialog();
    if (gd.wasCanceled()) {
        return false;
    }
    pluginSettings.setSaveModel(gd.getNextBoolean());
    final String name = gd.getNextString();
    pluginSettings.setSaveFitWidth(gd.getNextBoolean());
    if (pluginSettings.getSaveFitWidth()) {
        // Save the widths in the fit configuration
        fitConfig.setInitialPeakStdDev0(parameters[P_S0X]);
        fitConfig.setInitialPeakStdDev1(parameters[P_S0Y]);
        pluginSettings.setPsf(fitConfig.getPsf());
    }
    writeAstigmatismModelManagerSettings(pluginSettings);
    if (pluginSettings.getSaveModel()) {
        final AstigmatismModel.Builder model = AstigmatismModel.newBuilder();
        model.setGamma(parameters[P_GAMMA]);
        model.setD(parameters[P_D]);
        model.setS0X(parameters[P_S0X]);
        model.setAx(parameters[P_AX]);
        model.setBx(parameters[P_BX]);
        model.setS0Y(parameters[P_S0Y]);
        model.setAy(parameters[P_AY]);
        model.setBy(parameters[P_BY]);
        model.setZDistanceUnit(DistanceUnit.UM);
        model.setSDistanceUnit(DistanceUnit.PIXEL);
        model.setNmPerPixel(fitConfig.getCalibrationReader().getNmPerPixel());
        model.setZ0(parameters[P_Z0]);
        return save(name, model);
    }
    return true;
}
Also used : AstigmatismModel(uk.ac.sussex.gdsc.smlm.data.config.PSFProtos.AstigmatismModel) NonBlockingExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.NonBlockingExtendedGenericDialog) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)

Example 83 with ExtendedGenericDialog

use of uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog in project GDSC-SMLM by aherbert.

the class PeakResultTableModelFrame method doResultsSave.

private void doResultsSave() {
    final PeakResultTableModel model = getModel();
    if (model == null || model.getRowCount() == 0) {
        return;
    }
    final ExtendedGenericDialog gd = new ExtendedGenericDialog("Save Results", this);
    if (TextUtils.isNullOrEmpty(saveName)) {
        saveName = getTitle();
    }
    gd.addStringField("Results_set_name", saveName, 30);
    gd.showDialog();
    if (gd.wasCanceled()) {
        return;
    }
    saveName = gd.getNextString();
    if (TextUtils.isNullOrEmpty(saveName)) {
        IJ.error("No results set name");
        return;
    }
    final MemoryPeakResults results = model.toMemoryPeakResults();
    results.setName(saveName);
    MemoryPeakResults.addResults(results);
}
Also used : MemoryPeakResults(uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)

Example 84 with ExtendedGenericDialog

use of uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog in project GDSC-SMLM by aherbert.

the class TcPalmAnalysis method showAnalysisSettingsDialog.

/**
 * Show a dialog to change the analysis settings.
 *
 * @param event the event
 */
private void showAnalysisSettingsDialog(ActionEvent event) {
    final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
    gd.addCheckbox("Disable_overlap_check", settings.getDisableOverlapCheck());
    gd.addCheckbox("Show_size_histogram", settings.getShowSizeHistogram());
    gd.addCheckbox("Show_duration_histogram", settings.getShowDurationHistogram());
    gd.addCheckbox("Show_area_histogram", settings.getShowAreaHistogram());
    gd.addCheckbox("Show_density_histogram", settings.getShowDensityHistogram());
    gd.addHelp(HelpUrls.getUrl("tc-palm-analysis"));
    gd.showDialog();
    if (gd.wasCanceled()) {
        return;
    }
    settings.setDisableOverlapCheck(gd.getNextBoolean());
    settings.setShowSizeHistogram(gd.getNextBoolean());
    settings.setShowDurationHistogram(gd.getNextBoolean());
    settings.setShowAreaHistogram(gd.getNextBoolean());
    settings.setShowDensityHistogram(gd.getNextBoolean());
}
Also used : NonBlockingExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.NonBlockingExtendedGenericDialog) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)

Example 85 with ExtendedGenericDialog

use of uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog in project GDSC-SMLM by aherbert.

the class TcPalmAnalysis method showDialog.

/**
 * Show dialog.
 *
 * @return true, if successful
 */
private boolean showDialog() {
    settings = SettingsManager.readTcPalmAnalysisSettings(0).toBuilder();
    final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
    gd.addMessage("Analyse the time-correlated activation of traced data");
    ResultsManager.addInput(gd, "Input", settings.getInputOption(), InputSource.MEMORY);
    // Require results settings to use the standard ResultsManager image options
    final ResultsSettings.Builder tmp = ResultsSettings.newBuilder();
    tmp.setResultsImageSettings(settings.getResultsImageSettingsBuilder());
    final int flags = ResultsManager.FLAG_NO_SECTION_HEADER | ResultsManager.FLAG_IMAGE_REMOVE_NONE;
    ResultsManager.addImageResultsOptions(gd, tmp, flags);
    gd.addHelp(HelpUrls.getUrl("tc-palm-analysis"));
    gd.showDialog();
    if (gd.wasCanceled()) {
        return false;
    }
    settings.setInputOption(ResultsManager.getInputSource(gd));
    final ResultsImageSettings.Builder newImgSettings = tmp.getResultsImageSettingsBuilder();
    // Note: The initial none option was removed
    newImgSettings.setImageTypeValue(gd.getNextChoiceIndex() + 1);
    settings.setResultsImageSettings(newImgSettings);
    SettingsManager.writeSettings(settings);
    return true;
}
Also used : NonBlockingExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.NonBlockingExtendedGenericDialog) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog) ResultsSettings(uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsSettings) ResultsImageSettings(uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsImageSettings) Point(java.awt.Point)

Aggregations

ExtendedGenericDialog (uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)151 NonBlockingExtendedGenericDialog (uk.ac.sussex.gdsc.core.ij.gui.NonBlockingExtendedGenericDialog)38 CalibrationWriter (uk.ac.sussex.gdsc.smlm.data.config.CalibrationWriter)21 MemoryPeakResults (uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults)14 Checkbox (java.awt.Checkbox)13 ImagePlus (ij.ImagePlus)12 File (java.io.File)11 Rectangle (java.awt.Rectangle)10 TextField (java.awt.TextField)10 ResultsImageSettings (uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsImageSettings)10 FitConfiguration (uk.ac.sussex.gdsc.smlm.engine.FitConfiguration)10 Choice (java.awt.Choice)9 ArrayList (java.util.ArrayList)9 DistanceUnit (uk.ac.sussex.gdsc.smlm.data.config.UnitProtos.DistanceUnit)9 LocalList (uk.ac.sussex.gdsc.core.utils.LocalList)8 CalibrationReader (uk.ac.sussex.gdsc.smlm.data.config.CalibrationReader)7 ResultsSettings (uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsSettings)7 ResultsTableSettings (uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsTableSettings)7 IJ (ij.IJ)6 GenericDialog (ij.gui.GenericDialog)5