Search in sources :

Example 1 with ResultsSettings

use of uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsSettings in project GDSC-SMLM by aherbert.

the class ResultsManager method showInteractiveTable.

/**
 * Show interactive table.
 *
 * @param results the results
 * @param resultsTableSettings the results table settings
 */
public static void showInteractiveTable(MemoryPeakResults results, ResultsTableSettings resultsTableSettings) {
    final PeakResultTableModel model = new PeakResultTableModel(results, true, resultsTableSettings);
    final PeakResultTableModelFrame frame = new PeakResultTableModelFrame(model);
    frame.setTitle(results.getName());
    frame.setVisible(true);
    // Save changes to the interactive table settings
    model.addSettingsUpdatedAction(s -> {
        // Load the latest settings and save the table options
        final ResultsSettings.Builder resultsSettings = SettingsManager.readResultsSettings(0).toBuilder();
        resultsSettings.setResultsTableSettings(s);
        SettingsManager.writeSettings(resultsSettings.build());
    });
}
Also used : Builder(uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsSettings.Builder) PeakResultTableModelFrame(uk.ac.sussex.gdsc.smlm.ij.gui.PeakResultTableModelFrame) ResultsSettings(uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsSettings) PeakResultTableModel(uk.ac.sussex.gdsc.smlm.ij.gui.PeakResultTableModel)

Example 2 with ResultsSettings

use of uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsSettings in project GDSC-SMLM by aherbert.

the class ResultsManager method showDialog.

private boolean showDialog() {
    final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
    gd.addHelp(HelpUrls.getUrl("results-manager"));
    settings = Settings.load();
    resultsSettings = SettingsManager.readResultsSettings(0).toBuilder();
    gd.addMessage("Read the Peak Results and output to a new format");
    gd.addMessage("Select the Peak Results");
    addInput(gd, INPUT_NAME, settings.inputOption, new FilenameLoadOption[] { new FilenameLoadOption(settings.inputFilename) }, InputSource.MEMORY, InputSource.FILE);
    final Choice inputChoice = gd.getLastChoice();
    addTableResultsOptions(gd, resultsSettings, FLAG_TABLE_FORMAT);
    addImageResultsOptions(gd, resultsSettings);
    addFileResultsOptions(gd, resultsSettings, 0);
    addInMemoryResultsOptions(gd, resultsSettings);
    final Label messageLabel = (Label) gd.getMessage();
    final Checkbox saveCheckbox = gd.getLastCheckbox();
    // Hide the in-memory settings if the input is not a file
    if (ImageJUtils.isShowGenericDialog()) {
        final Label saveLabel = gd.getLastLabel();
        final ItemListener listener = event -> {
            final boolean enable = INPUT_FILE.equals(inputChoice.getSelectedItem());
            if (enable != messageLabel.isVisible()) {
                messageLabel.setVisible(enable);
                saveCheckbox.setVisible(enable);
                saveLabel.setVisible(enable);
                gd.pack();
            }
        };
        // Run once to set up
        listener.itemStateChanged(null);
        inputChoice.addItemListener(listener);
    }
    gd.showDialog();
    if (gd.wasCanceled()) {
        return false;
    }
    settings.inputOption = ResultsManager.getInputSource(gd);
    settings.inputFilename = gd.getNextString();
    resultsSettings.getResultsTableSettingsBuilder().setResultsTableFormatValue(gd.getNextChoiceIndex());
    resultsSettings.getResultsImageSettingsBuilder().setImageTypeValue(gd.getNextChoiceIndex());
    resultsSettings.getResultsFileSettingsBuilder().setFileFormatValue(gd.getNextChoiceIndex());
    resultsSettings.getResultsFileSettingsBuilder().setResultsFilename(gd.getNextString());
    resultsSettings.getResultsInMemorySettingsBuilder().setInMemory(gd.getNextBoolean());
    gd.collectOptions();
    // Check arguments
    try {
        final ResultsImageSettings.Builder imageSettings = resultsSettings.getResultsImageSettingsBuilder();
        if (imageSettings.getImageType() == ResultsImageType.DRAW_INTENSITY_AVERAGE_PRECISION || imageSettings.getImageType() == ResultsImageType.DRAW_LOCALISATIONS_AVERAGE_PRECISION) {
            ParameterUtils.isAboveZero("Image precision", imageSettings.getAveragePrecision());
        }
        ParameterUtils.isAboveZero("Image scale", imageSettings.getScale());
        if (extraOptions) {
            ParameterUtils.isPositive("Image rolling window", imageSettings.getRollingWindowSize());
        }
    } catch (final IllegalArgumentException ex) {
        IJ.error(TITLE, ex.getMessage());
        return false;
    }
    settings.save();
    SettingsManager.writeSettings(resultsSettings.build());
    return true;
}
Also used : Choice(java.awt.Choice) Java2(ij.util.Java2) Arrays(java.util.Arrays) Rectangle2D(java.awt.geom.Rectangle2D) ItemListener(java.awt.event.ItemListener) StringUtils(org.apache.commons.lang3.StringUtils) ResultsImageSettings(uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsImageSettings) ResultsSettings(uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsSettings) Panel(java.awt.Panel) ImageJPluginLoggerHelper(uk.ac.sussex.gdsc.core.ij.ImageJPluginLoggerHelper) YesNoCancelDialog(ij.gui.YesNoCancelDialog) MemoryPeakResults(uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults) ResultOption(uk.ac.sussex.gdsc.smlm.results.ResultOption) Map(java.util.Map) ImageJImagePeakResults(uk.ac.sussex.gdsc.smlm.ij.results.ImageJImagePeakResults) PeakResults(uk.ac.sussex.gdsc.smlm.results.PeakResults) JFileChooser(javax.swing.JFileChooser) MathUtils(uk.ac.sussex.gdsc.core.utils.MathUtils) CalibrationWriter(uk.ac.sussex.gdsc.smlm.data.config.CalibrationWriter) EnumSet(java.util.EnumSet) LutHelper(uk.ac.sussex.gdsc.core.ij.process.LutHelper) SettingsManager(uk.ac.sussex.gdsc.smlm.ij.settings.SettingsManager) CameraType(uk.ac.sussex.gdsc.smlm.data.config.CalibrationProtos.CameraType) Predicate(java.util.function.Predicate) Collection(java.util.Collection) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog) ResultsInMemorySettings(uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsInMemorySettings) PeakResultsList(uk.ac.sussex.gdsc.smlm.results.PeakResultsList) Set(java.util.Set) ResultsImageType(uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsImageType) DistanceUnit(uk.ac.sussex.gdsc.smlm.data.config.UnitProtos.DistanceUnit) Logger(java.util.logging.Logger) TextUtils(uk.ac.sussex.gdsc.core.utils.TextUtils) BitFlagUtils(uk.ac.sussex.gdsc.core.utils.BitFlagUtils) List(java.util.List) Builder(uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsSettings.Builder) PeakResultTableModelFrame(uk.ac.sussex.gdsc.smlm.ij.gui.PeakResultTableModelFrame) BinaryFilePeakResults(uk.ac.sussex.gdsc.smlm.results.BinaryFilePeakResults) FileUtils(uk.ac.sussex.gdsc.core.utils.FileUtils) PlugIn(ij.plugin.PlugIn) Rectangle(java.awt.Rectangle) PeakResultProcedureX(uk.ac.sussex.gdsc.smlm.results.procedures.PeakResultProcedureX) Prefs(ij.Prefs) ValidationUtils(uk.ac.sussex.gdsc.core.utils.ValidationUtils) HashMap(java.util.HashMap) IntensityUnit(uk.ac.sussex.gdsc.smlm.data.config.UnitProtos.IntensityUnit) FixedPeakResultList(uk.ac.sussex.gdsc.smlm.results.FixedPeakResultList) ResultsFileSettings(uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsFileSettings) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) OptionListener(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog.OptionListener) OpenDialog(ij.io.OpenDialog) ArrayList(java.util.ArrayList) IJImageSource(uk.ac.sussex.gdsc.smlm.ij.IJImageSource) MultiDialog(uk.ac.sussex.gdsc.core.ij.gui.MultiDialog) ResultsProtosHelper(uk.ac.sussex.gdsc.smlm.data.config.ResultsProtosHelper) ResultsFileFormat(uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsFileFormat) ImagePeakResultsFactory(uk.ac.sussex.gdsc.smlm.ij.results.ImagePeakResultsFactory) GenericDialog(ij.gui.GenericDialog) PeakResultTableModel(uk.ac.sussex.gdsc.smlm.ij.gui.PeakResultTableModel) MalkFilePeakResults(uk.ac.sussex.gdsc.smlm.results.MalkFilePeakResults) PeakResultsReader(uk.ac.sussex.gdsc.smlm.results.PeakResultsReader) LinkedHashSet(java.util.LinkedHashSet) TsfPeakResultsWriter(uk.ac.sussex.gdsc.smlm.results.TsfPeakResultsWriter) EventQueue(java.awt.EventQueue) ResultsTableFormat(uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsTableFormat) SimpleImageJTrackProgress(uk.ac.sussex.gdsc.core.ij.SimpleImageJTrackProgress) Checkbox(java.awt.Checkbox) Label(java.awt.Label) IOException(java.io.IOException) ResultsImageMode(uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsImageMode) Recorder(ij.plugin.frame.Recorder) File(java.io.File) Constants(uk.ac.sussex.gdsc.smlm.ij.settings.Constants) ImageJTablePeakResults(uk.ac.sussex.gdsc.smlm.ij.results.ImageJTablePeakResults) Counter(uk.ac.sussex.gdsc.smlm.results.count.Counter) ImageJUtils(uk.ac.sussex.gdsc.core.ij.ImageJUtils) TextFilePeakResults(uk.ac.sussex.gdsc.smlm.results.TextFilePeakResults) IJ(ij.IJ) ExtendedPeakResult(uk.ac.sussex.gdsc.smlm.results.ExtendedPeakResult) ResultsTableSettings(uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsTableSettings) LocalList(uk.ac.sussex.gdsc.core.utils.LocalList) Choice(java.awt.Choice) Checkbox(java.awt.Checkbox) Label(java.awt.Label) ItemListener(java.awt.event.ItemListener) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog) ResultsImageSettings(uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsImageSettings)

Aggregations

ResultsSettings (uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsSettings)2 Builder (uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsSettings.Builder)2 PeakResultTableModel (uk.ac.sussex.gdsc.smlm.ij.gui.PeakResultTableModel)2 PeakResultTableModelFrame (uk.ac.sussex.gdsc.smlm.ij.gui.PeakResultTableModelFrame)2 IJ (ij.IJ)1 Prefs (ij.Prefs)1 GenericDialog (ij.gui.GenericDialog)1 YesNoCancelDialog (ij.gui.YesNoCancelDialog)1 OpenDialog (ij.io.OpenDialog)1 PlugIn (ij.plugin.PlugIn)1 Recorder (ij.plugin.frame.Recorder)1 Java2 (ij.util.Java2)1 Checkbox (java.awt.Checkbox)1 Choice (java.awt.Choice)1 EventQueue (java.awt.EventQueue)1 Label (java.awt.Label)1 Panel (java.awt.Panel)1 Rectangle (java.awt.Rectangle)1 ItemListener (java.awt.event.ItemListener)1 Rectangle2D (java.awt.geom.Rectangle2D)1