Search in sources :

Example 11 with PeakResultProcedure

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

the class ImageJ3DResultsViewer method createRankById.

private static float[] createRankById(MemoryPeakResults results) {
    if (results.hasId()) {
        final TFloatArrayList list = new TFloatArrayList(results.size());
        results.forEach((PeakResultProcedure) r -> list.add(r.getId()));
        return list.toArray();
    }
    return null;
}
Also used : Color(java.awt.Color) Arrays(java.util.Arrays) PickInfo(org.scijava.java3d.PickInfo) IndexedGeometryArray(org.scijava.java3d.IndexedGeometryArray) ItemGroup(uk.ac.sussex.gdsc.smlm.ij.ij3d.ItemGroup) GUI(ij.gui.GUI) DefaultListSelectionModel(javax.swing.DefaultListSelectionModel) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) ResultsSettings(uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsSettings) TransparentItemShape(uk.ac.sussex.gdsc.smlm.ij.ij3d.TransparentItemShape) Future(java.util.concurrent.Future) Pair(org.apache.commons.lang3.tuple.Pair) MemoryPeakResults(uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults) Map(java.util.Map) FitProtosHelper(uk.ac.sussex.gdsc.smlm.data.config.FitProtosHelper) ImageWindow3D(ij3d.ImageWindow3D) Triple(org.apache.commons.lang3.tuple.Triple) LutHelper(uk.ac.sussex.gdsc.core.ij.process.LutHelper) KeyStroke(javax.swing.KeyStroke) Appearance(org.scijava.java3d.Appearance) CustomMesh(customnode.CustomMesh) ImageCanvas3D(ij3d.ImageCanvas3D) Rendering(uk.ac.sussex.gdsc.smlm.ij.ij3d.Shape3DHelper.Rendering) InputSource(uk.ac.sussex.gdsc.smlm.ij.plugins.ResultsManager.InputSource) TObjectIntHashMap(gnu.trove.map.hash.TObjectIntHashMap) ImageJ3DResultsViewerSettings(uk.ac.sussex.gdsc.smlm.ij.settings.GUIProtos.ImageJ3DResultsViewerSettings) UniverseSettings(ij3d.UniverseSettings) NamedObject(uk.ac.sussex.gdsc.smlm.data.NamedObject) DistanceUnit(uk.ac.sussex.gdsc.smlm.data.config.UnitProtos.DistanceUnit) ItemGeometryGroup(uk.ac.sussex.gdsc.smlm.ij.ij3d.ItemGeometryGroup) StopWatch(org.apache.commons.lang3.time.StopWatch) RawResultProcedure(uk.ac.sussex.gdsc.smlm.results.procedures.RawResultProcedure) KeyEvent(java.awt.event.KeyEvent) WindowAdapter(java.awt.event.WindowAdapter) TextUtils(uk.ac.sussex.gdsc.core.utils.TextUtils) Executors(java.util.concurrent.Executors) ImagePlus(ij.ImagePlus) PlugIn(ij.plugin.PlugIn) WindowConstants(javax.swing.WindowConstants) Color3f(org.scijava.vecmath.Color3f) ListSelectionModel(javax.swing.ListSelectionModel) TransformGroup(org.scijava.java3d.TransformGroup) PeakResultProcedureX(uk.ac.sussex.gdsc.smlm.results.procedures.PeakResultProcedureX) XyzResultProcedure(uk.ac.sussex.gdsc.smlm.results.procedures.XyzResultProcedure) WindowManager(ij.WindowManager) PeakResult(uk.ac.sussex.gdsc.smlm.results.PeakResult) Point3f(org.scijava.vecmath.Point3f) Point3d(org.scijava.vecmath.Point3d) ContentNode(ij3d.ContentNode) SortUtils(uk.ac.sussex.gdsc.core.utils.SortUtils) CustomPointMesh(customnode.CustomPointMesh) RounderUtils(uk.ac.sussex.gdsc.core.data.utils.RounderUtils) PeakResultTableModel(uk.ac.sussex.gdsc.smlm.ij.gui.PeakResultTableModel) PeakResultProcedure(uk.ac.sussex.gdsc.smlm.results.procedures.PeakResultProcedure) CustomLineMesh(customnode.CustomLineMesh) ItemPointMesh(uk.ac.sussex.gdsc.smlm.ij.ij3d.ItemPointMesh) GeometryArray(org.scijava.java3d.GeometryArray) Field(java.lang.reflect.Field) IntersectionInfo(org.scijava.java3d.PickInfo.IntersectionInfo) Point2d(org.scijava.vecmath.Point2d) MouseEvent(java.awt.event.MouseEvent) ExecutionException(java.util.concurrent.ExecutionException) ReferenceItemMesh(uk.ac.sussex.gdsc.smlm.ij.ij3d.ReferenceItemMesh) Canvas3D(org.scijava.java3d.Canvas3D) MouseMotionListener(java.awt.event.MouseMotionListener) LineAttributes(org.scijava.java3d.LineAttributes) ItemTriangleMesh(uk.ac.sussex.gdsc.smlm.ij.ij3d.ItemTriangleMesh) ResultsTableSettings(uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsTableSettings) ListSelectionListener(javax.swing.event.ListSelectionListener) UniverseListener(ij3d.UniverseListener) TransparentItemTriangleMesh(uk.ac.sussex.gdsc.smlm.ij.ij3d.TransparentItemTriangleMesh) Builder(uk.ac.sussex.gdsc.smlm.ij.settings.GUIProtos.ImageJ3DResultsViewerSettings.Builder) StandardResultProcedure(uk.ac.sussex.gdsc.smlm.results.procedures.StandardResultProcedure) TriangleArray(org.scijava.java3d.TriangleArray) Transform3D(org.scijava.java3d.Transform3D) CustomContentHelper(uk.ac.sussex.gdsc.smlm.ij.ij3d.CustomContentHelper) PointAttributes(org.scijava.java3d.PointAttributes) SplitMix(uk.ac.sussex.gdsc.core.utils.rng.SplitMix) ItemGroupNode(uk.ac.sussex.gdsc.smlm.ij.ij3d.ItemGroupNode) Content(ij3d.Content) PickCanvas(org.scijava.java3d.utils.pickfast.PickCanvas) ItemShape(uk.ac.sussex.gdsc.smlm.ij.ij3d.ItemShape) TransparentItemPointMesh(uk.ac.sussex.gdsc.smlm.ij.ij3d.TransparentItemPointMesh) CoordinatePredicateUtils(uk.ac.sussex.gdsc.core.ij.roi.CoordinatePredicateUtils) XyResultProcedure(uk.ac.sussex.gdsc.smlm.results.procedures.XyResultProcedure) CustomContent(uk.ac.sussex.gdsc.smlm.ij.ij3d.CustomContent) Image3DUniverse(ij3d.Image3DUniverse) Locale(java.util.Locale) ListSelectionModelHelper(uk.ac.sussex.gdsc.smlm.ij.gui.ListSelectionModelHelper) MouseAdapter(java.awt.event.MouseAdapter) DataException(uk.ac.sussex.gdsc.core.data.DataException) ColoringAttributes(org.scijava.java3d.ColoringAttributes) MacroRunner(ij.macro.MacroRunner) MathUtils(uk.ac.sussex.gdsc.core.utils.MathUtils) ListSelectionEvent(javax.swing.event.ListSelectionEvent) UpdateableItemShape(uk.ac.sussex.gdsc.smlm.ij.ij3d.UpdateableItemShape) MouseListener(java.awt.event.MouseListener) SettingsManager(uk.ac.sussex.gdsc.smlm.ij.settings.SettingsManager) JMenuBar(javax.swing.JMenuBar) CoordinatePredicate(uk.ac.sussex.gdsc.core.ij.roi.CoordinatePredicate) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) JMenu(javax.swing.JMenu) WindowEvent(java.awt.event.WindowEvent) List(java.util.List) PeakResultTableModelFrame(uk.ac.sussex.gdsc.smlm.ij.gui.PeakResultTableModelFrame) OrderedItemGeometryGroup(uk.ac.sussex.gdsc.smlm.ij.ij3d.OrderedItemGeometryGroup) Modifier(java.lang.reflect.Modifier) SimpleArrayUtils(uk.ac.sussex.gdsc.core.utils.SimpleArrayUtils) Shape3DHelper(uk.ac.sussex.gdsc.smlm.ij.ij3d.Shape3DHelper) TransparencyAttributes(org.scijava.java3d.TransparencyAttributes) LUT(ij.process.LUT) SceneGraphPath(org.scijava.java3d.SceneGraphPath) TypeConverter(uk.ac.sussex.gdsc.core.data.utils.TypeConverter) Roi(ij.gui.Roi) PolygonAttributes(org.scijava.java3d.PolygonAttributes) PrecisionResultProcedure(uk.ac.sussex.gdsc.smlm.results.procedures.PrecisionResultProcedure) PrecisionMethod(uk.ac.sussex.gdsc.smlm.data.config.FitProtos.PrecisionMethod) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) AtomicReference(java.util.concurrent.atomic.AtomicReference) TextField(java.awt.TextField) OptionListener(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog.OptionListener) ItemMesh(uk.ac.sussex.gdsc.smlm.ij.ij3d.ItemMesh) JMenuItem(javax.swing.JMenuItem) ImageJTrackProgress(uk.ac.sussex.gdsc.core.ij.ImageJTrackProgress) CustomMeshNode(customnode.CustomMeshNode) View(org.scijava.java3d.View) ExecutorService(java.util.concurrent.ExecutorService) Shape3D(org.scijava.java3d.Shape3D) DefaultUniverse(ij3d.DefaultUniverse) TFloatArrayList(gnu.trove.list.array.TFloatArrayList) Vector3d(org.scijava.vecmath.Vector3d) PeakResultsDigest(uk.ac.sussex.gdsc.smlm.results.PeakResultsDigest) Iterator(java.util.Iterator) BranchGroup(org.scijava.java3d.BranchGroup) AxisAngle4d(org.scijava.vecmath.AxisAngle4d) Image3DMenubar(ij3d.Image3DMenubar) LutColour(uk.ac.sussex.gdsc.core.ij.process.LutHelper.LutColour) Ticker(uk.ac.sussex.gdsc.core.logging.Ticker) ActionEvent(java.awt.event.ActionEvent) ContentInstant(ij3d.ContentInstant) Rounder(uk.ac.sussex.gdsc.core.data.utils.Rounder) TimeUnit(java.util.concurrent.TimeUnit) CustomContentInstant(uk.ac.sussex.gdsc.smlm.ij.ij3d.CustomContentInstant) ImageJUtils(uk.ac.sussex.gdsc.core.ij.ImageJUtils) IJ(ij.IJ) Nullable(uk.ac.sussex.gdsc.core.annotation.Nullable) ImageJ3DResultsViewerSettingsOrBuilder(uk.ac.sussex.gdsc.smlm.ij.settings.GUIProtos.ImageJ3DResultsViewerSettingsOrBuilder) LocalList(uk.ac.sussex.gdsc.core.utils.LocalList) TFloatArrayList(gnu.trove.list.array.TFloatArrayList)

Example 12 with PeakResultProcedure

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

the class PeakResultsReader method simplifyTwoAxis.

/**
 * Simplify two axis Gaussian 2D data.
 *
 * @param results the results
 * @param removeTheta the remove theta flag
 */
private void simplifyTwoAxis(MemoryPeakResults results, boolean removeTheta) {
    final int[] indices = PsfHelper.getGaussian2DWxWyIndices(psf);
    final int isx = indices[0];
    final int isy = indices[1];
    // Columns to remove
    int remove = (removeTheta) ? 1 : 0;
    // New PSF type
    PSFType psfType;
    // Determine if sy is redundant
    if (results.forEach((PeakResultProcedureX) peakResult -> peakResult.getParameter(isx) != peakResult.getParameter(isy))) {
        if (!removeTheta) {
            // Already a TwoAxis Gaussian
            return;
        }
        // Otherwise this was a TwoAxisAndTheta with 1 column to remove
        // so it should be simplified
        psfType = PSFType.TWO_AXIS_GAUSSIAN_2D;
    } else {
        // sy is redundant so remove another column
        psfType = PSFType.ONE_AXIS_GAUSSIAN_2D;
        remove++;
    }
    // Update the PSF
    final PSF.Builder builder = psf.toBuilder();
    builder.setPsfType(psfType);
    psf = builder.build();
    results.setPsf(psf);
    // Update the results.
    // We can directly manipulate the params array
    final int newLength = results.getf(0).getNumberOfParameters() - remove;
    if (deviations) {
        results.forEach((PeakResultProcedure) peakResult -> {
            peakResult.resizeParameters(newLength);
            peakResult.resizeParameterDeviations(newLength);
        });
    } else {
        results.forEach((PeakResultProcedure) peakResult -> peakResult.resizeParameters(newLength));
    }
}
Also used : Rectangle(java.awt.Rectangle) DataInputStream(java.io.DataInputStream) AngleUnit(uk.ac.sussex.gdsc.smlm.data.config.UnitProtos.AngleUnit) Calibration(uk.ac.sussex.gdsc.smlm.data.config.CalibrationProtos.Calibration) PeakResultProcedureX(uk.ac.sussex.gdsc.smlm.results.procedures.PeakResultProcedureX) Scanner(java.util.Scanner) PSF(uk.ac.sussex.gdsc.smlm.data.config.PSFProtos.PSF) IntensityUnit(uk.ac.sussex.gdsc.smlm.data.config.UnitProtos.IntensityUnit) PSFType(uk.ac.sussex.gdsc.smlm.data.config.PSFProtos.PSFType) TrackProgress(uk.ac.sussex.gdsc.core.logging.TrackProgress) Level(java.util.logging.Level) Matcher(java.util.regex.Matcher) NotNull(uk.ac.sussex.gdsc.core.annotation.NotNull) Locale(java.util.Locale) XStreamUtils(uk.ac.sussex.gdsc.smlm.utils.XStreamUtils) UnicodeReader(uk.ac.sussex.gdsc.core.utils.UnicodeReader) PeakResultProcedure(uk.ac.sussex.gdsc.smlm.results.procedures.PeakResultProcedure) CalibrationWriter(uk.ac.sussex.gdsc.smlm.data.config.CalibrationWriter) NoSuchElementException(java.util.NoSuchElementException) Statistics(uk.ac.sussex.gdsc.core.utils.Statistics) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) CameraType(uk.ac.sussex.gdsc.smlm.data.config.CalibrationProtos.CameraType) IOException(java.io.IOException) DistanceUnit(uk.ac.sussex.gdsc.smlm.data.config.UnitProtos.DistanceUnit) FileInputStream(java.io.FileInputStream) Logger(java.util.logging.Logger) EOFException(java.io.EOFException) TextUtils(uk.ac.sussex.gdsc.core.utils.TextUtils) TimeUnit(uk.ac.sussex.gdsc.smlm.data.config.UnitProtos.TimeUnit) Objects(java.util.Objects) BitFlagUtils(uk.ac.sussex.gdsc.core.utils.BitFlagUtils) JsonFormat(com.google.protobuf.util.JsonFormat) Nullable(uk.ac.sussex.gdsc.core.annotation.Nullable) FileUtils(uk.ac.sussex.gdsc.core.utils.FileUtils) PsfHelper(uk.ac.sussex.gdsc.smlm.data.config.PsfHelper) BufferedReader(java.io.BufferedReader) Pattern(java.util.regex.Pattern) FileChannel(java.nio.channels.FileChannel) PSF(uk.ac.sussex.gdsc.smlm.data.config.PSFProtos.PSF) PSFType(uk.ac.sussex.gdsc.smlm.data.config.PSFProtos.PSFType)

Example 13 with PeakResultProcedure

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

the class BenchmarkFilterAnalysis method getCoordinates.

private static TIntObjectHashMap<UniqueIdPeakResult[]> getCoordinates(MemoryPeakResults results) {
    final TIntObjectHashMap<UniqueIdPeakResult[]> coords = new TIntObjectHashMap<>();
    if (results.size() > 0) {
        // Do not use HashMap directly to build the coords object since there
        // will be many calls to getEntry(). Instead sort the results and use
        // a new list for each time point
        results.sort();
        final Counter uniqueId = new Counter();
        final FrameCounter counter = new FrameCounter();
        final LocalList<PeakResult> tmp = new LocalList<>();
        // Add the results to the lists
        results.forEach((PeakResultProcedure) result -> {
            if (counter.advanceAndReset(result.getFrame()) && !tmp.isEmpty()) {
                coords.put(counter.previousFrame(), tmp.toArray(new UniqueIdPeakResult[0]));
                tmp.clear();
            }
            tmp.add(new UniqueIdPeakResult(tmp.size(), uniqueId.getAndIncrement(), result));
        });
        if (!tmp.isEmpty()) {
            coords.put(counter.currentFrame(), tmp.toArray(new UniqueIdPeakResult[0]));
        }
    }
    return coords;
}
Also used : Color(java.awt.Color) Arrays(java.util.Arrays) CoordinateStoreFactory(uk.ac.sussex.gdsc.smlm.results.filter.CoordinateStoreFactory) Macro(ij.Macro) ConvergenceChecker(uk.ac.sussex.gdsc.smlm.search.ConvergenceChecker) BasePreprocessedPeakResult(uk.ac.sussex.gdsc.smlm.results.filter.BasePreprocessedPeakResult) MultiPathFitResults(uk.ac.sussex.gdsc.smlm.results.filter.MultiPathFitResults) Filter(uk.ac.sussex.gdsc.smlm.results.filter.Filter) SearchResult(uk.ac.sussex.gdsc.smlm.search.SearchResult) HelpUrls(uk.ac.sussex.gdsc.smlm.ij.plugins.HelpUrls) Vector(java.util.Vector) SearchSpace(uk.ac.sussex.gdsc.smlm.search.SearchSpace) Pair(org.apache.commons.lang3.tuple.Pair) MemoryPeakResults(uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults) Map(java.util.Map) IDirectFilter(uk.ac.sussex.gdsc.smlm.results.filter.IDirectFilter) UnicodeReader(uk.ac.sussex.gdsc.core.utils.UnicodeReader) Triple(org.apache.commons.lang3.tuple.Triple) Chromosome(uk.ac.sussex.gdsc.smlm.ga.Chromosome) FilterScore(uk.ac.sussex.gdsc.smlm.results.filter.FilterScore) LinearInterpolator(org.apache.commons.math3.analysis.interpolation.LinearInterpolator) LoessInterpolator(org.apache.commons.math3.analysis.interpolation.LoessInterpolator) BlockingQueue(java.util.concurrent.BlockingQueue) StopWatch(org.apache.commons.lang3.time.StopWatch) ConcurrencyUtils(uk.ac.sussex.gdsc.core.utils.concurrent.ConcurrencyUtils) MultiPathFitResult(uk.ac.sussex.gdsc.smlm.results.filter.MultiPathFitResult) TextUtils(uk.ac.sussex.gdsc.core.utils.TextUtils) Gaussian2DFunction(uk.ac.sussex.gdsc.smlm.function.gaussian.Gaussian2DFunction) Plot(ij.gui.Plot) PeakFit(uk.ac.sussex.gdsc.smlm.ij.plugins.PeakFit) TIntHashSet(gnu.trove.set.hash.TIntHashSet) ImagePlus(ij.ImagePlus) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) TextArea(java.awt.TextArea) PeakFractionalAssignment(uk.ac.sussex.gdsc.smlm.results.filter.PeakFractionalAssignment) RampedSelectionStrategy(uk.ac.sussex.gdsc.smlm.ga.RampedSelectionStrategy) FileUtils(uk.ac.sussex.gdsc.core.utils.FileUtils) ConvergenceToleranceChecker(uk.ac.sussex.gdsc.smlm.search.ConvergenceToleranceChecker) FitnessFunction(uk.ac.sussex.gdsc.smlm.ga.FitnessFunction) PlugIn(ij.plugin.PlugIn) MultiPathFilter(uk.ac.sussex.gdsc.smlm.results.filter.MultiPathFilter) PolynomialSplineFunction(org.apache.commons.math3.analysis.polynomials.PolynomialSplineFunction) Prefs(ij.Prefs) StoredData(uk.ac.sussex.gdsc.core.utils.StoredData) FrameCounter(uk.ac.sussex.gdsc.smlm.results.count.FrameCounter) SimpleDateFormat(java.text.SimpleDateFormat) PeakResult(uk.ac.sussex.gdsc.smlm.results.PeakResult) MatchResult(uk.ac.sussex.gdsc.core.match.MatchResult) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) ToleranceChecker(uk.ac.sussex.gdsc.smlm.ga.ToleranceChecker) GenericDialog(ij.gui.GenericDialog) PeakResultProcedure(uk.ac.sussex.gdsc.smlm.results.procedures.PeakResultProcedure) FitConfiguration(uk.ac.sussex.gdsc.smlm.engine.FitConfiguration) Overlay(ij.gui.Overlay) Population(uk.ac.sussex.gdsc.smlm.ga.Population) BenchmarkSpotFilterResult(uk.ac.sussex.gdsc.smlm.ij.plugins.benchmark.BenchmarkSpotFilter.BenchmarkSpotFilterResult) CombinatoricsUtils(org.apache.commons.math3.util.CombinatoricsUtils) FileOutputStream(java.io.FileOutputStream) FractionClassificationResult(uk.ac.sussex.gdsc.core.match.FractionClassificationResult) File(java.io.File) DirectFilter(uk.ac.sussex.gdsc.smlm.results.filter.DirectFilter) ResultsMatchCalculator(uk.ac.sussex.gdsc.smlm.ij.plugins.ResultsMatchCalculator) PreprocessedPeakResult(uk.ac.sussex.gdsc.smlm.results.filter.PreprocessedPeakResult) SimpleSelectionStrategy(uk.ac.sussex.gdsc.smlm.ga.SimpleSelectionStrategy) MaximaSpotFilter(uk.ac.sussex.gdsc.smlm.filters.MaximaSpotFilter) BufferedReader(java.io.BufferedReader) DoubleEquality(uk.ac.sussex.gdsc.core.utils.DoubleEquality) FractionScoreStore(uk.ac.sussex.gdsc.smlm.results.filter.MultiPathFilter.FractionScoreStore) NonBlockingGenericDialog(ij.gui.NonBlockingGenericDialog) SimpleRecombiner(uk.ac.sussex.gdsc.smlm.ga.SimpleRecombiner) TIntObjectHashMap(gnu.trove.map.hash.TIntObjectHashMap) Date(java.util.Date) FilterCandidates(uk.ac.sussex.gdsc.smlm.ij.plugins.benchmark.BenchmarkSpotFit.FilterCandidates) TextWindow(ij.text.TextWindow) BenchmarkSpotFitResult(uk.ac.sussex.gdsc.smlm.ij.plugins.benchmark.BenchmarkSpotFit.BenchmarkSpotFitResult) ParameterType(uk.ac.sussex.gdsc.smlm.results.filter.ParameterType) StoredDataStatistics(uk.ac.sussex.gdsc.core.utils.StoredDataStatistics) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ResultAssignment(uk.ac.sussex.gdsc.smlm.results.filter.ResultAssignment) PlotWindow(ij.gui.PlotWindow) MathUtils(uk.ac.sussex.gdsc.core.utils.MathUtils) TIntObjectProcedure(gnu.trove.procedure.TIntObjectProcedure) SettingsManager(uk.ac.sussex.gdsc.smlm.ij.settings.SettingsManager) Recombiner(uk.ac.sussex.gdsc.smlm.ga.Recombiner) SimpleMutator(uk.ac.sussex.gdsc.smlm.ga.SimpleMutator) BufferedTextWindow(uk.ac.sussex.gdsc.core.ij.BufferedTextWindow) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) FitEngineConfiguration(uk.ac.sussex.gdsc.smlm.engine.FitEngineConfiguration) 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) Logger(java.util.logging.Logger) FractionalAssignment(uk.ac.sussex.gdsc.core.match.FractionalAssignment) ResultAssignmentDistanceComparator(uk.ac.sussex.gdsc.smlm.results.filter.ResultAssignmentDistanceComparator) FilterXStreamUtils(uk.ac.sussex.gdsc.smlm.results.filter.FilterXStreamUtils) SettingsList(uk.ac.sussex.gdsc.core.utils.SettingsList) List(java.util.List) SearchDimension(uk.ac.sussex.gdsc.smlm.search.SearchDimension) FullScoreFunction(uk.ac.sussex.gdsc.smlm.search.FullScoreFunction) ResultsImageSampler(uk.ac.sussex.gdsc.smlm.ij.results.ResultsImageSampler) Rectangle(java.awt.Rectangle) PeakResultGridManager(uk.ac.sussex.gdsc.smlm.results.PeakResultGridManager) ConsecutiveFailCounter(uk.ac.sussex.gdsc.smlm.results.count.ConsecutiveFailCounter) GridCoordinateStore(uk.ac.sussex.gdsc.smlm.results.filter.GridCoordinateStore) PrecisionMethod(uk.ac.sussex.gdsc.smlm.data.config.FitProtos.PrecisionMethod) FixedDimension(uk.ac.sussex.gdsc.smlm.search.FixedDimension) WindowOrganiser(uk.ac.sussex.gdsc.core.ij.plugin.WindowOrganiser) AtomicReference(java.util.concurrent.atomic.AtomicReference) TrackProgress(uk.ac.sussex.gdsc.core.logging.TrackProgress) TextField(java.awt.TextField) Level(java.util.logging.Level) ParameterUtils(uk.ac.sussex.gdsc.smlm.ij.plugins.ParameterUtils) ImageListener(ij.ImageListener) TemplateSettings(uk.ac.sussex.gdsc.smlm.data.config.TemplateProtos.TemplateSettings) OutputStreamWriter(java.io.OutputStreamWriter) LinkedList(java.util.LinkedList) ScoreFunctionHelper(uk.ac.sussex.gdsc.smlm.search.ScoreFunctionHelper) ConcurrentRuntimeException(org.apache.commons.lang3.concurrent.ConcurrentRuntimeException) GUIFilterSettings(uk.ac.sussex.gdsc.smlm.ij.settings.GUIProtos.GUIFilterSettings) UniformRandomProvider(org.apache.commons.rng.UniformRandomProvider) Iterator(java.util.Iterator) RampedScore(uk.ac.sussex.gdsc.core.utils.RampedScore) CoordinateStore(uk.ac.sussex.gdsc.smlm.results.filter.CoordinateStore) Checkbox(java.awt.Checkbox) FilterType(uk.ac.sussex.gdsc.smlm.results.filter.FilterType) ConfigurationTemplate(uk.ac.sussex.gdsc.smlm.ij.plugins.ConfigurationTemplate) FilterSet(uk.ac.sussex.gdsc.smlm.results.filter.FilterSet) ClassificationResult(uk.ac.sussex.gdsc.core.match.ClassificationResult) FileInputStream(java.io.FileInputStream) Recorder(ij.plugin.frame.Recorder) Ticker(uk.ac.sussex.gdsc.core.logging.Ticker) SelectionStrategy(uk.ac.sussex.gdsc.smlm.ga.SelectionStrategy) Consumer(java.util.function.Consumer) ImageWindow(ij.gui.ImageWindow) Counter(uk.ac.sussex.gdsc.smlm.results.count.Counter) SimpleRegression(org.apache.commons.math3.stat.regression.SimpleRegression) HistogramPlot(uk.ac.sussex.gdsc.core.ij.HistogramPlot) ImageJUtils(uk.ac.sussex.gdsc.core.ij.ImageJUtils) IJ(ij.IJ) SmlmUsageTracker(uk.ac.sussex.gdsc.smlm.ij.plugins.SmlmUsageTracker) Nullable(uk.ac.sussex.gdsc.core.annotation.Nullable) Comparator(java.util.Comparator) Collections(java.util.Collections) LocalList(uk.ac.sussex.gdsc.core.utils.LocalList) UniformRandomProviders(uk.ac.sussex.gdsc.core.utils.rng.UniformRandomProviders) LocalList(uk.ac.sussex.gdsc.core.utils.LocalList) FrameCounter(uk.ac.sussex.gdsc.smlm.results.count.FrameCounter) ConsecutiveFailCounter(uk.ac.sussex.gdsc.smlm.results.count.ConsecutiveFailCounter) Counter(uk.ac.sussex.gdsc.smlm.results.count.Counter) TIntObjectHashMap(gnu.trove.map.hash.TIntObjectHashMap) FrameCounter(uk.ac.sussex.gdsc.smlm.results.count.FrameCounter) BasePreprocessedPeakResult(uk.ac.sussex.gdsc.smlm.results.filter.BasePreprocessedPeakResult) PeakResult(uk.ac.sussex.gdsc.smlm.results.PeakResult) PreprocessedPeakResult(uk.ac.sussex.gdsc.smlm.results.filter.PreprocessedPeakResult)

Example 14 with PeakResultProcedure

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

the class TranslateResults 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;
    }
    final TranslateResultsSettings.Builder settings = SettingsManager.readTranslateResultsSettings(0).toBuilder();
    // Show a dialog allowing the results set to be filtered
    final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
    gd.addMessage("Select a dataset to translate");
    ResultsManager.addInput(gd, settings.getInputOption(), InputSource.MEMORY);
    gd.addNumericField("x", settings.getDx(), 3);
    gd.addNumericField("y", settings.getDy(), 3);
    gd.addNumericField("z", settings.getDz(), 3);
    gd.addChoice("Distance_unit", SettingsManager.getDistanceUnitNames(), settings.getDistanceUnitValue());
    gd.addHelp(HelpUrls.getUrl("translate-results"));
    gd.showDialog();
    if (gd.wasCanceled()) {
        return;
    }
    settings.setInputOption(ResultsManager.getInputSource(gd));
    settings.setDx(gd.getNextNumber());
    settings.setDy(gd.getNextNumber());
    settings.setDz(gd.getNextNumber());
    settings.setDistanceUnitValue(gd.getNextChoiceIndex());
    SettingsManager.writeSettings(settings);
    final MemoryPeakResults results = ResultsManager.loadInputResults(settings.getInputOption(), false, null, null);
    if (MemoryPeakResults.isEmpty(results)) {
        IJ.error(TITLE, "No results could be loaded");
        return;
    }
    TypeConverter<DistanceUnit> converter;
    try {
        converter = results.getDistanceConverter(settings.getDistanceUnit());
    } catch (final DataException ex) {
        IJ.error(TITLE, "Unit conversion error: " + ex.getMessage());
        return;
    }
    final float x = (float) converter.convertBack(settings.getDx());
    final float y = (float) converter.convertBack(settings.getDy());
    final float z = (float) converter.convertBack(settings.getDz());
    // Reset the 2D bounds
    if (x != 0 || y != 0) {
        results.setBounds(null);
    }
    results.forEach((PeakResultProcedure) peakResult -> {
        final float[] params = peakResult.getParameters();
        params[PeakResult.X] += x;
        params[PeakResult.Y] += y;
        params[PeakResult.Z] += z;
    });
}
Also used : MemoryPeakResults(uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults) IJ(ij.IJ) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog) InputSource(uk.ac.sussex.gdsc.smlm.ij.plugins.ResultsManager.InputSource) TranslateResultsSettings(uk.ac.sussex.gdsc.smlm.ij.settings.GUIProtos.TranslateResultsSettings) DataException(uk.ac.sussex.gdsc.core.data.DataException) DistanceUnit(uk.ac.sussex.gdsc.smlm.data.config.UnitProtos.DistanceUnit) PeakResult(uk.ac.sussex.gdsc.smlm.results.PeakResult) PeakResultProcedure(uk.ac.sussex.gdsc.smlm.results.procedures.PeakResultProcedure) PlugIn(ij.plugin.PlugIn) TypeConverter(uk.ac.sussex.gdsc.core.data.utils.TypeConverter) SettingsManager(uk.ac.sussex.gdsc.smlm.ij.settings.SettingsManager) DataException(uk.ac.sussex.gdsc.core.data.DataException) TranslateResultsSettings(uk.ac.sussex.gdsc.smlm.ij.settings.GUIProtos.TranslateResultsSettings) MemoryPeakResults(uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog) DistanceUnit(uk.ac.sussex.gdsc.smlm.data.config.UnitProtos.DistanceUnit)

Example 15 with PeakResultProcedure

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

the class TraceMolecules method convertToClusterPoints.

/**
 * Convert a list of peak results into points for the clustering engine.
 *
 * @param results the results
 * @return the list of clusters
 */
public static List<ClusterPoint> convertToClusterPoints(MemoryPeakResults results) {
    final ArrayList<ClusterPoint> points = new ArrayList<>(results.size());
    final Counter counter = new Counter();
    results.forEach((PeakResultProcedure) result -> points.add(ClusterPoint.newTimeClusterPoint(counter.getAndIncrement(), result.getXPosition(), result.getYPosition(), result.getIntensity(), result.getFrame(), result.getEndFrame())));
    return points;
}
Also used : Arrays(java.util.Arrays) ClusteringEngine(uk.ac.sussex.gdsc.core.clustering.ClusteringEngine) UnitConverterUtils(uk.ac.sussex.gdsc.smlm.data.config.UnitConverterUtils) HistogramPlotBuilder(uk.ac.sussex.gdsc.core.ij.HistogramPlot.HistogramPlotBuilder) TextWindow(ij.text.TextWindow) CalibrationOrBuilder(uk.ac.sussex.gdsc.smlm.data.config.CalibrationProtos.CalibrationOrBuilder) StoredDataStatistics(uk.ac.sussex.gdsc.core.utils.StoredDataStatistics) MemoryPeakResults(uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults) ClusteringAlgorithm(uk.ac.sussex.gdsc.core.clustering.ClusteringAlgorithm) MathUtils(uk.ac.sussex.gdsc.core.utils.MathUtils) SettingsManager(uk.ac.sussex.gdsc.smlm.ij.settings.SettingsManager) ClusteringSettings(uk.ac.sussex.gdsc.smlm.ij.settings.GUIProtos.ClusteringSettings) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog) InputSource(uk.ac.sussex.gdsc.smlm.ij.plugins.ResultsManager.InputSource) DistanceUnit(uk.ac.sussex.gdsc.smlm.data.config.UnitProtos.DistanceUnit) TraceMode(uk.ac.sussex.gdsc.smlm.results.TraceManager.TraceMode) Logger(java.util.logging.Logger) TIntHashSet(gnu.trove.set.hash.TIntHashSet) CalibrationHelper(uk.ac.sussex.gdsc.smlm.data.config.CalibrationHelper) ImagePlus(ij.ImagePlus) LutLoader(ij.plugin.LutLoader) List(java.util.List) Converter(uk.ac.sussex.gdsc.core.data.utils.Converter) SimpleArrayUtils(uk.ac.sussex.gdsc.core.utils.SimpleArrayUtils) FileUtils(uk.ac.sussex.gdsc.core.utils.FileUtils) PlugIn(ij.plugin.PlugIn) TypeConverter(uk.ac.sussex.gdsc.core.data.utils.TypeConverter) Roi(ij.gui.Roi) PrecisionResultProcedure(uk.ac.sussex.gdsc.smlm.results.procedures.PrecisionResultProcedure) SplineInterpolator(org.apache.commons.math3.analysis.interpolation.SplineInterpolator) TraceManager(uk.ac.sussex.gdsc.smlm.results.TraceManager) PolygonRoi(ij.gui.PolygonRoi) PolynomialSplineFunction(org.apache.commons.math3.analysis.polynomials.PolynomialSplineFunction) Prefs(ij.Prefs) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) WindowManager(ij.WindowManager) WindowOrganiser(uk.ac.sussex.gdsc.core.ij.plugin.WindowOrganiser) ClusterPoint(uk.ac.sussex.gdsc.core.clustering.ClusterPoint) DmttConfiguration(uk.ac.sussex.gdsc.smlm.results.DynamicMultipleTargetTracing.DmttConfiguration) AtomicReference(java.util.concurrent.atomic.AtomicReference) TextField(java.awt.TextField) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) Trace(uk.ac.sussex.gdsc.smlm.results.Trace) PeakResultProcedure(uk.ac.sussex.gdsc.smlm.results.procedures.PeakResultProcedure) Statistics(uk.ac.sussex.gdsc.core.utils.Statistics) SimpleImageJTrackProgress(uk.ac.sussex.gdsc.core.ij.SimpleImageJTrackProgress) Files(java.nio.file.Files) Calibration(ij.measure.Calibration) Checkbox(java.awt.Checkbox) BufferedWriter(java.io.BufferedWriter) DynamicMultipleTargetTracing(uk.ac.sussex.gdsc.smlm.results.DynamicMultipleTargetTracing) TimeUnit(uk.ac.sussex.gdsc.smlm.data.config.UnitProtos.TimeUnit) Consumer(java.util.function.Consumer) SummaryStatistics(org.apache.commons.math3.stat.descriptive.SummaryStatistics) FloatProcessor(ij.process.FloatProcessor) Counter(uk.ac.sussex.gdsc.smlm.results.count.Counter) Paths(java.nio.file.Paths) Cluster(uk.ac.sussex.gdsc.core.clustering.Cluster) ImageJUtils(uk.ac.sussex.gdsc.core.ij.ImageJUtils) TextFilePeakResults(uk.ac.sussex.gdsc.smlm.results.TextFilePeakResults) IJ(ij.IJ) Collections(java.util.Collections) Counter(uk.ac.sussex.gdsc.smlm.results.count.Counter) ArrayList(java.util.ArrayList) ClusterPoint(uk.ac.sussex.gdsc.core.clustering.ClusterPoint)

Aggregations

PeakResultProcedure (uk.ac.sussex.gdsc.smlm.results.procedures.PeakResultProcedure)40 MemoryPeakResults (uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults)35 PeakResult (uk.ac.sussex.gdsc.smlm.results.PeakResult)33 List (java.util.List)29 Counter (uk.ac.sussex.gdsc.smlm.results.count.Counter)26 SimpleArrayUtils (uk.ac.sussex.gdsc.core.utils.SimpleArrayUtils)24 FrameCounter (uk.ac.sussex.gdsc.smlm.results.count.FrameCounter)20 IJ (ij.IJ)19 Nullable (uk.ac.sussex.gdsc.core.annotation.Nullable)19 PlugIn (ij.plugin.PlugIn)18 AtomicReference (java.util.concurrent.atomic.AtomicReference)18 ImageJUtils (uk.ac.sussex.gdsc.core.ij.ImageJUtils)18 ExtendedGenericDialog (uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)18 DistanceUnit (uk.ac.sussex.gdsc.smlm.data.config.UnitProtos.DistanceUnit)16 ClassificationResult (uk.ac.sussex.gdsc.core.match.ClassificationResult)15 MathUtils (uk.ac.sussex.gdsc.core.utils.MathUtils)15 TextUtils (uk.ac.sussex.gdsc.core.utils.TextUtils)15 Chromosome (uk.ac.sussex.gdsc.smlm.ga.Chromosome)15 XStreamOmitField (com.thoughtworks.xstream.annotations.XStreamOmitField)14 ArrayList (java.util.ArrayList)14