Search in sources :

Example 1 with TIntObjectProcedure

use of gnu.trove.procedure.TIntObjectProcedure in project GDSC-SMLM by aherbert.

the class BenchmarkSpotFilter method histogramFailures.

/**
 * Histogram the number of negatives preceding each positive.
 *
 * @param benchmarkFilterResult the filter result
 * @return the cumulative histogram
 */
private static double[][] histogramFailures(BenchmarkSpotFilterResult benchmarkFilterResult) {
    final StoredData data = new StoredData();
    benchmarkFilterResult.filterResults.forEachEntry((TIntObjectProcedure<FilterResult>) (peak, filterResult) -> {
        for (final ScoredSpot spot : filterResult.spots) {
            if (spot.match) {
                data.add(spot.fails);
            }
        }
        return true;
    });
    final double[][] h = MathUtils.cumulativeHistogram(data.getValues(), true);
    benchmarkFilterResult.cumul = h;
    benchmarkFilterResult.stats = data;
    return h;
}
Also used : Color(java.awt.Color) PsfSpot(uk.ac.sussex.gdsc.smlm.ij.plugins.PsfSpot) PeakResultPoint(uk.ac.sussex.gdsc.smlm.results.PeakResultPoint) TIntObjectHashMap(gnu.trove.map.hash.TIntObjectHashMap) Arrays(java.util.Arrays) HistogramPlotBuilder(uk.ac.sussex.gdsc.core.ij.HistogramPlot.HistogramPlotBuilder) ConfigurationException(uk.ac.sussex.gdsc.smlm.data.config.ConfigurationException) TextWindow(ij.text.TextWindow) Spot(uk.ac.sussex.gdsc.smlm.filters.Spot) DataFilterType(uk.ac.sussex.gdsc.smlm.data.config.FitProtos.DataFilterType) HelpUrls(uk.ac.sussex.gdsc.smlm.ij.plugins.HelpUrls) Pair(org.apache.commons.lang3.tuple.Pair) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MemoryPeakResults(uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults) AssignmentComparator(uk.ac.sussex.gdsc.core.match.AssignmentComparator) PsfCalculator(uk.ac.sussex.gdsc.smlm.ij.plugins.PsfCalculator) ImageJImageConverter(uk.ac.sussex.gdsc.smlm.ij.utils.ImageJImageConverter) MathUtils(uk.ac.sussex.gdsc.core.utils.MathUtils) TIntObjectProcedure(gnu.trove.procedure.TIntObjectProcedure) SettingsManager(uk.ac.sussex.gdsc.smlm.ij.settings.SettingsManager) BasePoint(uk.ac.sussex.gdsc.core.match.BasePoint) AucCalculator(uk.ac.sussex.gdsc.core.match.AucCalculator) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog) FitEngineConfiguration(uk.ac.sussex.gdsc.smlm.engine.FitEngineConfiguration) BlockingQueue(java.util.concurrent.BlockingQueue) DistanceUnit(uk.ac.sussex.gdsc.smlm.data.config.UnitProtos.DistanceUnit) SpotFinderPreview(uk.ac.sussex.gdsc.smlm.ij.plugins.SpotFinderPreview) Coordinate(uk.ac.sussex.gdsc.core.match.Coordinate) Gaussian2DPeakResultHelper(uk.ac.sussex.gdsc.smlm.results.Gaussian2DPeakResultHelper) FractionalAssignment(uk.ac.sussex.gdsc.core.match.FractionalAssignment) ConcurrencyUtils(uk.ac.sussex.gdsc.core.utils.concurrent.ConcurrencyUtils) Gaussian2DFunction(uk.ac.sussex.gdsc.smlm.function.gaussian.Gaussian2DFunction) Plot(ij.gui.Plot) PeakFit(uk.ac.sussex.gdsc.smlm.ij.plugins.PeakFit) ImagePlus(ij.ImagePlus) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) SettingsList(uk.ac.sussex.gdsc.core.utils.SettingsList) List(java.util.List) GaussianFunctionFactory(uk.ac.sussex.gdsc.smlm.function.gaussian.GaussianFunctionFactory) SimpleArrayUtils(uk.ac.sussex.gdsc.core.utils.SimpleArrayUtils) PlugIn(ij.plugin.PlugIn) Rectangle(java.awt.Rectangle) FastCorrelator(uk.ac.sussex.gdsc.core.utils.FastCorrelator) ImmutableFractionalAssignment(uk.ac.sussex.gdsc.core.match.ImmutableFractionalAssignment) Prefs(ij.Prefs) StoredData(uk.ac.sussex.gdsc.core.utils.StoredData) PSF(uk.ac.sussex.gdsc.smlm.data.config.PSFProtos.PSF) WindowOrganiser(uk.ac.sussex.gdsc.core.ij.plugin.WindowOrganiser) IntensityUnit(uk.ac.sussex.gdsc.smlm.data.config.UnitProtos.IntensityUnit) AtomicReference(java.util.concurrent.atomic.AtomicReference) ArrayList(java.util.ArrayList) DataFilterMethod(uk.ac.sussex.gdsc.smlm.data.config.FitProtos.DataFilterMethod) LinkedList(java.util.LinkedList) Overlay(ij.gui.Overlay) Statistics(uk.ac.sussex.gdsc.core.utils.Statistics) ConcurrentRuntimeException(org.apache.commons.lang3.concurrent.ConcurrentRuntimeException) RampedScore(uk.ac.sussex.gdsc.core.utils.RampedScore) GaussianOverlapAnalysis(uk.ac.sussex.gdsc.smlm.function.gaussian.GaussianOverlapAnalysis) RelativeParameter(uk.ac.sussex.gdsc.smlm.data.config.FitProtos.RelativeParameter) Ticker(uk.ac.sussex.gdsc.core.logging.Ticker) FractionClassificationResult(uk.ac.sussex.gdsc.core.match.FractionClassificationResult) ResultsMatchCalculator(uk.ac.sussex.gdsc.smlm.ij.plugins.ResultsMatchCalculator) Gaussian2DPeakResultCalculator(uk.ac.sussex.gdsc.smlm.results.Gaussian2DPeakResultCalculator) SimpleRegression(org.apache.commons.math3.stat.regression.SimpleRegression) ImageJUtils(uk.ac.sussex.gdsc.core.ij.ImageJUtils) IJ(ij.IJ) ImageStack(ij.ImageStack) MaximaSpotFilter(uk.ac.sussex.gdsc.smlm.filters.MaximaSpotFilter) SmlmUsageTracker(uk.ac.sussex.gdsc.smlm.ij.plugins.SmlmUsageTracker) CameraModel(uk.ac.sussex.gdsc.smlm.model.camera.CameraModel) PsfHelper(uk.ac.sussex.gdsc.smlm.data.config.PsfHelper) Collections(java.util.Collections) LocalList(uk.ac.sussex.gdsc.core.utils.LocalList) StandardResultProcedure(uk.ac.sussex.gdsc.smlm.results.procedures.StandardResultProcedure) StoredData(uk.ac.sussex.gdsc.core.utils.StoredData)

Example 2 with TIntObjectProcedure

use of gnu.trove.procedure.TIntObjectProcedure in project GDSC-SMLM by aherbert.

the class BenchmarkSpotFilter method addSpotsToMemory.

/**
 * Add all the true-positives to memory as a new results set.
 *
 * @param filterResults the filter results
 */
private static void addSpotsToMemory(TIntObjectHashMap<FilterResult> filterResults) {
    final MemoryPeakResults results = new MemoryPeakResults();
    results.setName(TITLE + " TP " + truePositivesResultsSetId.getAndIncrement());
    filterResults.forEachEntry((TIntObjectProcedure<FilterResult>) (peak, filterResult) -> {
        for (final ScoredSpot spot : filterResult.spots) {
            if (spot.match) {
                final float[] params = new float[] { 0, spot.getIntensity(), 0, spot.spot.x, spot.spot.y, 0, 0 };
                results.add(peak, spot.spot.x, spot.spot.y, spot.getIntensity(), 0d, 0f, 0f, params, null);
            }
        }
        return true;
    });
    MemoryPeakResults.addResults(results);
}
Also used : Color(java.awt.Color) PsfSpot(uk.ac.sussex.gdsc.smlm.ij.plugins.PsfSpot) PeakResultPoint(uk.ac.sussex.gdsc.smlm.results.PeakResultPoint) TIntObjectHashMap(gnu.trove.map.hash.TIntObjectHashMap) Arrays(java.util.Arrays) HistogramPlotBuilder(uk.ac.sussex.gdsc.core.ij.HistogramPlot.HistogramPlotBuilder) ConfigurationException(uk.ac.sussex.gdsc.smlm.data.config.ConfigurationException) TextWindow(ij.text.TextWindow) Spot(uk.ac.sussex.gdsc.smlm.filters.Spot) DataFilterType(uk.ac.sussex.gdsc.smlm.data.config.FitProtos.DataFilterType) HelpUrls(uk.ac.sussex.gdsc.smlm.ij.plugins.HelpUrls) Pair(org.apache.commons.lang3.tuple.Pair) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MemoryPeakResults(uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults) AssignmentComparator(uk.ac.sussex.gdsc.core.match.AssignmentComparator) PsfCalculator(uk.ac.sussex.gdsc.smlm.ij.plugins.PsfCalculator) ImageJImageConverter(uk.ac.sussex.gdsc.smlm.ij.utils.ImageJImageConverter) MathUtils(uk.ac.sussex.gdsc.core.utils.MathUtils) TIntObjectProcedure(gnu.trove.procedure.TIntObjectProcedure) SettingsManager(uk.ac.sussex.gdsc.smlm.ij.settings.SettingsManager) BasePoint(uk.ac.sussex.gdsc.core.match.BasePoint) AucCalculator(uk.ac.sussex.gdsc.core.match.AucCalculator) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog) FitEngineConfiguration(uk.ac.sussex.gdsc.smlm.engine.FitEngineConfiguration) BlockingQueue(java.util.concurrent.BlockingQueue) DistanceUnit(uk.ac.sussex.gdsc.smlm.data.config.UnitProtos.DistanceUnit) SpotFinderPreview(uk.ac.sussex.gdsc.smlm.ij.plugins.SpotFinderPreview) Coordinate(uk.ac.sussex.gdsc.core.match.Coordinate) Gaussian2DPeakResultHelper(uk.ac.sussex.gdsc.smlm.results.Gaussian2DPeakResultHelper) FractionalAssignment(uk.ac.sussex.gdsc.core.match.FractionalAssignment) ConcurrencyUtils(uk.ac.sussex.gdsc.core.utils.concurrent.ConcurrencyUtils) Gaussian2DFunction(uk.ac.sussex.gdsc.smlm.function.gaussian.Gaussian2DFunction) Plot(ij.gui.Plot) PeakFit(uk.ac.sussex.gdsc.smlm.ij.plugins.PeakFit) ImagePlus(ij.ImagePlus) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) SettingsList(uk.ac.sussex.gdsc.core.utils.SettingsList) List(java.util.List) GaussianFunctionFactory(uk.ac.sussex.gdsc.smlm.function.gaussian.GaussianFunctionFactory) SimpleArrayUtils(uk.ac.sussex.gdsc.core.utils.SimpleArrayUtils) PlugIn(ij.plugin.PlugIn) Rectangle(java.awt.Rectangle) FastCorrelator(uk.ac.sussex.gdsc.core.utils.FastCorrelator) ImmutableFractionalAssignment(uk.ac.sussex.gdsc.core.match.ImmutableFractionalAssignment) Prefs(ij.Prefs) StoredData(uk.ac.sussex.gdsc.core.utils.StoredData) PSF(uk.ac.sussex.gdsc.smlm.data.config.PSFProtos.PSF) WindowOrganiser(uk.ac.sussex.gdsc.core.ij.plugin.WindowOrganiser) IntensityUnit(uk.ac.sussex.gdsc.smlm.data.config.UnitProtos.IntensityUnit) AtomicReference(java.util.concurrent.atomic.AtomicReference) ArrayList(java.util.ArrayList) DataFilterMethod(uk.ac.sussex.gdsc.smlm.data.config.FitProtos.DataFilterMethod) LinkedList(java.util.LinkedList) Overlay(ij.gui.Overlay) Statistics(uk.ac.sussex.gdsc.core.utils.Statistics) ConcurrentRuntimeException(org.apache.commons.lang3.concurrent.ConcurrentRuntimeException) RampedScore(uk.ac.sussex.gdsc.core.utils.RampedScore) GaussianOverlapAnalysis(uk.ac.sussex.gdsc.smlm.function.gaussian.GaussianOverlapAnalysis) RelativeParameter(uk.ac.sussex.gdsc.smlm.data.config.FitProtos.RelativeParameter) Ticker(uk.ac.sussex.gdsc.core.logging.Ticker) FractionClassificationResult(uk.ac.sussex.gdsc.core.match.FractionClassificationResult) ResultsMatchCalculator(uk.ac.sussex.gdsc.smlm.ij.plugins.ResultsMatchCalculator) Gaussian2DPeakResultCalculator(uk.ac.sussex.gdsc.smlm.results.Gaussian2DPeakResultCalculator) SimpleRegression(org.apache.commons.math3.stat.regression.SimpleRegression) ImageJUtils(uk.ac.sussex.gdsc.core.ij.ImageJUtils) IJ(ij.IJ) ImageStack(ij.ImageStack) MaximaSpotFilter(uk.ac.sussex.gdsc.smlm.filters.MaximaSpotFilter) SmlmUsageTracker(uk.ac.sussex.gdsc.smlm.ij.plugins.SmlmUsageTracker) CameraModel(uk.ac.sussex.gdsc.smlm.model.camera.CameraModel) PsfHelper(uk.ac.sussex.gdsc.smlm.data.config.PsfHelper) Collections(java.util.Collections) LocalList(uk.ac.sussex.gdsc.core.utils.LocalList) StandardResultProcedure(uk.ac.sussex.gdsc.smlm.results.procedures.StandardResultProcedure) MemoryPeakResults(uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults)

Aggregations

TIntObjectHashMap (gnu.trove.map.hash.TIntObjectHashMap)2 TIntObjectProcedure (gnu.trove.procedure.TIntObjectProcedure)2 IJ (ij.IJ)2 ImagePlus (ij.ImagePlus)2 ImageStack (ij.ImageStack)2 Prefs (ij.Prefs)2 Overlay (ij.gui.Overlay)2 Plot (ij.gui.Plot)2 PlugIn (ij.plugin.PlugIn)2 TextWindow (ij.text.TextWindow)2 Color (java.awt.Color)2 Rectangle (java.awt.Rectangle)2 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 Collections (java.util.Collections)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)2 BlockingQueue (java.util.concurrent.BlockingQueue)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2