Search in sources :

Example 6 with ImageJImagePeakResults

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

the class Fire method createPeakResultsImage.

/**
 * Creates the peak results image.
 *
 * @param bounds the bounds
 * @param builder the builder
 * @param title the title
 * @return the peak results image
 */
private static ImageJImagePeakResults createPeakResultsImage(final Rectangle bounds, final ResultsImageSettings.Builder builder, String title) {
    final ImageJImagePeakResults image1 = ImagePeakResultsFactory.createPeakResultsImage(builder, title, bounds, 1);
    image1.setDisplayImage(false);
    image1.setUncalibrated(true);
    image1.begin();
    return image1;
}
Also used : ImageJImagePeakResults(uk.ac.sussex.gdsc.smlm.ij.results.ImageJImagePeakResults)

Example 7 with ImageJImagePeakResults

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

the class DriftCalculator method newImage.

private static ImageJImagePeakResults newImage(Rectangle bounds, float imageScale) {
    final ResultsImageSettings.Builder builder = ResultsImageSettings.newBuilder().setImageType(ResultsImageType.DRAW_INTENSITY).setImageMode(ResultsImageMode.IMAGE_ADD).setWeighted(true).setImageSizeMode(ResultsImageSizeMode.SCALED).setScale(imageScale);
    final ImageJImagePeakResults image = ImagePeakResultsFactory.createPeakResultsImage(builder, "", bounds, 1);
    image.setDisplayImage(false);
    image.setUncalibrated(true);
    image.begin();
    return image;
}
Also used : ResultsImageSettings(uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsImageSettings) ImageJImagePeakResults(uk.ac.sussex.gdsc.smlm.ij.results.ImageJImagePeakResults)

Example 8 with ImageJImagePeakResults

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

the class DensityImage method plotResults.

/**
 * Draw an image of the density for each localisation. Optionally filter results below a
 * threshold.
 *
 * @param results the results
 * @param density the density
 * @param scoreCalculator the score calculator
 * @return the number of localisations drawn
 */
private int plotResults(MemoryPeakResults results, float[] density, ScoreCalculator scoreCalculator) {
    // Filter results using 5x higher than average density of the sample in a 150nm radius:
    // Annibale, et al (2011). Identification of clustering artifacts in photoactivated localization
    // microscopy.
    // Nature Methods, 8, pp527-528
    MemoryPeakResults newResults = null;
    // No filtering
    float densityThreshold = Float.NEGATIVE_INFINITY;
    if (settings.filterLocalisations) {
        densityThreshold = scoreCalculator.getThreshold();
        newResults = new MemoryPeakResults();
        newResults.copySettings(results);
        newResults.setName(results.getName() + " Density Filter");
    }
    // Draw an image - Use error so that a floating point value can be used on a single pixel
    final ImageJImagePeakResults image = ImagePeakResultsFactory.createPeakResultsImage(ResultsImageType.DRAW_INTENSITY, false, false, results.getName() + " Density", results.getBounds(), results.getNmPerPixel(), settings.imageScale, 0, (settings.cumulativeImage) ? ResultsImageMode.IMAGE_ADD : ResultsImageMode.IMAGE_MAX);
    image.setDisplayFlags(image.getDisplayFlags() | ImageJImagePeakResults.DISPLAY_NEGATIVES);
    image.setLutName("grays");
    image.setLiveImage(false);
    image.begin();
    final StandardResultProcedure sp = new StandardResultProcedure(newResults, DistanceUnit.PIXEL);
    sp.getXyr();
    for (int i = 0; i < density.length; i++) {
        if (density[i] < densityThreshold) {
            continue;
        }
        image.add(sp.x[i], sp.y[i], density[i]);
        if (newResults != null) {
            newResults.add(sp.peakResults[i]);
        }
    }
    image.end();
    // Add to memory
    if (newResults != null && newResults.size() > 0) {
        MemoryPeakResults.addResults(newResults);
    }
    return image.size();
}
Also used : MemoryPeakResults(uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults) StandardResultProcedure(uk.ac.sussex.gdsc.smlm.results.procedures.StandardResultProcedure) ImageJImagePeakResults(uk.ac.sussex.gdsc.smlm.ij.results.ImageJImagePeakResults)

Example 9 with ImageJImagePeakResults

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

the class ResultsManager method addImageResults.

/**
 * Adds the image results.
 *
 * <p>Note: This always uses {@link ResultsImageMode#IMAGE_ADD}.
 *
 * @param resultsList the results list
 * @param resultsSettings the results settings
 * @param bounds the bounds
 * @param flags the flags
 */
public static void addImageResults(PeakResultsList resultsList, ResultsImageSettings resultsSettings, Rectangle bounds, int flags) {
    if (resultsSettings.getImageTypeValue() > 0) {
        final ResultsImageSettings.Builder builder = resultsSettings.toBuilder();
        builder.setImageMode(ResultsImageMode.IMAGE_ADD);
        final ImageJImagePeakResults image = ImagePeakResultsFactory.createPeakResultsImage(builder, resultsList.getName(), bounds, resultsList.getNmPerPixel());
        // Rolling window size is set by the factory method. Unset it if not using extra options.
        if (!BitFlagUtils.anySet(flags, FLAG_EXTRA_OPTIONS)) {
            image.setRollingWindowSize(0);
        }
        image.setRepaintDelay(2000);
        resultsList.addOutput(image);
    }
}
Also used : ResultsImageSettings(uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsImageSettings) ImageJImagePeakResults(uk.ac.sussex.gdsc.smlm.ij.results.ImageJImagePeakResults)

Example 10 with ImageJImagePeakResults

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

the class PeakFit method initialiseFitting.

/**
 * Set-up the fitting using all the configured properties. Prepare the output results.
 *
 * @return true, if successful
 */
public boolean initialiseFitting() {
    if (source == null) {
        return false;
    }
    // Do this to ensure the serialised configuration is correct
    updateFitConfiguration(config);
    results.setSource(source);
    String name = source.getName();
    if (!TextUtils.isNullOrEmpty(resultsSuffix)) {
        name += " " + resultsSuffix;
    }
    if (maximaIdentification) {
        name += " (Maxima)";
    } else if (fitMaxima) {
        name += " (" + getSolverName() + " Fit Maxima)";
    } else {
        name += " (" + getSolverName() + ")";
    }
    results.setName(name);
    results.setBounds(bounds);
    // Calibration cal = calibration.clone();
    // Account for the frame integration
    // TODO - Should we change this so that if integrate frames is used then the data
    // are converted to ExtendedPeakResult with a start and end frame
    // cal.exposureTime *= integrateFrames;
    // if (interlacedData)
    // {
    // cal.exposureTime *= ((double)dataBlock / (dataBlock + dataSkip));
    // }
    final CalibrationWriter cal = fitConfig.getCalibrationWriter();
    cal.setTimeUnit(TimeUnit.FRAME);
    results.setCalibration(cal.getCalibration());
    results.setPsf(fitConfig.getPsf());
    results.setConfiguration(SettingsManager.toJson(config.getFitEngineSettings()));
    // This is added first as it cannot be closed. If the table is closed then the
    // number of results at the end is reported incorrectly.
    addMemoryResults(results, false);
    addTableResults(results);
    ResultsManager.addImageResults(results, resultsSettings.getResultsImageSettings(), bounds, (extraOptions) ? ResultsManager.FLAG_EXTRA_OPTIONS : 0);
    addFileResults(results);
    addDefaultResults(results);
    results.begin();
    if (simpleFit && settings.showImage) {
        for (final PeakResults r : results.toArray()) {
            if (r instanceof ImageJImagePeakResults) {
                final ImagePlus i = ((ImageJImagePeakResults) r).getImagePlus();
                ImageJUtils.log("Super-resolution image title = " + i.getTitle());
                WindowManager.toFront(i.getWindow());
            }
        }
    }
    return true;
}
Also used : MemoryPeakResults(uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults) FilePeakResults(uk.ac.sussex.gdsc.smlm.results.FilePeakResults) ImageJTablePeakResults(uk.ac.sussex.gdsc.smlm.ij.results.ImageJTablePeakResults) ImageJImagePeakResults(uk.ac.sussex.gdsc.smlm.ij.results.ImageJImagePeakResults) PeakResults(uk.ac.sussex.gdsc.smlm.results.PeakResults) CalibrationWriter(uk.ac.sussex.gdsc.smlm.data.config.CalibrationWriter) ImageJImagePeakResults(uk.ac.sussex.gdsc.smlm.ij.results.ImageJImagePeakResults) ImagePlus(ij.ImagePlus)

Aggregations

ImageJImagePeakResults (uk.ac.sussex.gdsc.smlm.ij.results.ImageJImagePeakResults)12 ResultsImageSettings (uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsImageSettings)5 MemoryPeakResults (uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults)5 ImageProcessor (ij.process.ImageProcessor)4 Rectangle (java.awt.Rectangle)4 UniformRandomProvider (org.apache.commons.rng.UniformRandomProvider)3 ImagePlus (ij.ImagePlus)2 FloatProcessor (ij.process.FloatProcessor)2 SharedStateContinuousSampler (org.apache.commons.rng.sampling.distribution.SharedStateContinuousSampler)2 PeakResult (uk.ac.sussex.gdsc.smlm.results.PeakResult)2 PeakResults (uk.ac.sussex.gdsc.smlm.results.PeakResults)2 SeededTest (uk.ac.sussex.gdsc.test.junit5.SeededTest)2 AtomicDouble (com.google.common.util.concurrent.AtomicDouble)1 TDoubleArrayList (gnu.trove.list.array.TDoubleArrayList)1 IJ (ij.IJ)1 Macro (ij.Macro)1 Prefs (ij.Prefs)1 WindowManager (ij.WindowManager)1 DialogListener (ij.gui.DialogListener)1 GenericDialog (ij.gui.GenericDialog)1