Search in sources :

Example 1 with MinMaxResultProcedure

use of uk.ac.sussex.gdsc.smlm.results.procedures.MinMaxResultProcedure in project GDSC-SMLM by aherbert.

the class CropResults method run.

@Override
public void run(String arg) {
    SmlmUsageTracker.recordPlugin(this.getClass(), arg);
    if (MemoryPeakResults.isMemoryEmpty()) {
        IJ.error(TITLE, "There are no fitting results in memory");
        return;
    }
    // Build a list of all images with a region ROI
    titles = new LocalList<>(WindowManager.getWindowCount());
    for (final int imageId : ImageJUtils.getIdList()) {
        final ImagePlus imp = WindowManager.getImage(imageId);
        if (imp != null && imp.getRoi() != null && imp.getRoi().isArea()) {
            titles.add(imp.getTitle());
        }
    }
    final boolean roiMode = "roi".equals(arg);
    if (roiMode && titles.isEmpty()) {
        IJ.error(TITLE, "No images with an ROI");
        return;
    }
    settings = SettingsManager.readCropResultsSettings(0).toBuilder();
    // Show a dialog allowing the results set to be filtered
    final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
    gd.addMessage("Select a dataset to crop");
    ResultsManager.addInput(gd, settings.getInputOption(), InputSource.MEMORY);
    gd.showDialog();
    if (gd.wasCanceled()) {
        return;
    }
    settings.setInputOption(ResultsManager.getInputSource(gd));
    results = ResultsManager.loadInputResults(settings.getInputOption(), false, null, null);
    if (MemoryPeakResults.isEmpty(results)) {
        IJ.error(TITLE, "No results could be loaded");
        IJ.showStatus("");
        return;
    }
    // Allow z-filtering
    if (results.is3D()) {
        minMax = new MinMaxResultProcedure(results, new PeakResultValueParameter(PeakResult.Z));
    }
    if (roiMode) {
        runRoiCrop();
    } else {
        runCrop();
    }
    SettingsManager.writeSettings(settings);
}
Also used : PeakResultValueParameter(uk.ac.sussex.gdsc.smlm.results.PeakResultValueParameter) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog) ImagePlus(ij.ImagePlus) MinMaxResultProcedure(uk.ac.sussex.gdsc.smlm.results.procedures.MinMaxResultProcedure)

Aggregations

ImagePlus (ij.ImagePlus)1 ExtendedGenericDialog (uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)1 PeakResultValueParameter (uk.ac.sussex.gdsc.smlm.results.PeakResultValueParameter)1 MinMaxResultProcedure (uk.ac.sussex.gdsc.smlm.results.procedures.MinMaxResultProcedure)1