Package sc.fiji.snt.analysis.detection
Class DetectorUtils
java.lang.Object
sc.fiji.snt.analysis.detection.DetectorUtils
Shared utilities for path-based detectors (
PeripathDetector,
AlongPathDetector).- Author:
- Tiago Ferreira
-
Method Summary
Modifier and TypeMethodDescriptionassignToNearestPaths(List<Detection> detections, Collection<Path> allPaths) Reassigns each detection to the nearest path (by minimum node distance).static net.imglib2.img.Img<net.imglib2.type.numeric.real.FloatType> computeEDT(net.imglib2.RandomAccessibleInterval<? extends net.imglib2.type.numeric.RealType<?>> labelRAI, int labelVal, double[] spacing) Computes a calibrated Euclidean Distance Transform for a single label value in a label image.deduplicate(List<Detection> detections, double mergingDistance) Deduplicates detections using greedy non-maximum suppression by intensity.static doubleinterpolateRadius(double[] radii, int idx, double fallback) Simple linear interpolation for a missing radius value atidx, using the nearest valid neighbors.static double[]prepareRadii(Path path) Prepares a sanitized radius array for the given path.static double[]sampleDistances(Collection<Path> paths, net.imglib2.img.Img<net.imglib2.type.numeric.real.FloatType> edt) Samples the EDT at every node position of the given paths.static List<double[]> sampleDistancesWithIndices(Path path, net.imglib2.img.Img<net.imglib2.type.numeric.real.FloatType> edt) Samples the EDT at each node of a single path, returning the distance value and node index for each in-bounds node.
-
Method Details
-
prepareRadii
Prepares a sanitized radius array for the given path. If the path has no radii, returns an array filled with 2× minimum separation as fallback.- Parameters:
path- the path- Returns:
- sanitized radius array (one entry per node)
-
interpolateRadius
public static double interpolateRadius(double[] radii, int idx, double fallback) Simple linear interpolation for a missing radius value atidx, using the nearest valid neighbors.- Parameters:
radii- the radius arrayidx- index of the missing valuefallback- value to use if no valid neighbors exist- Returns:
- interpolated radius
-
deduplicate
Deduplicates detections using greedy non-maximum suppression by intensity.- Parameters:
detections- the raw detectionsmergingDistance- suppression radius in physical units- Returns:
- deduplicated list
-
assignToNearestPaths
public static List<Detection> assignToNearestPaths(List<Detection> detections, Collection<Path> allPaths) Reassigns each detection to the nearest path (by minimum node distance).- Parameters:
detections- the detections to reassignallPaths- candidate paths- Returns:
- reassigned detections
-
computeEDT
public static net.imglib2.img.Img<net.imglib2.type.numeric.real.FloatType> computeEDT(net.imglib2.RandomAccessibleInterval<? extends net.imglib2.type.numeric.RealType<?>> labelRAI, int labelVal, double[] spacing) Computes a calibrated Euclidean Distance Transform for a single label value in a label image. The EDT gives the distance from every voxel to the nearest boundary of the specified label.- Parameters:
labelRAI- the label (segmentation) imagelabelVal- the label value to compute the EDT forspacing- pixel spacing per dimension (used for calibrated EDT). Ifnull, spacing is resolved from the image viaImgUtils.resolveSpacing(RandomAccessibleInterval, double[]).- Returns:
- the EDT as a float image, or
nulliflabelRAIis null
-
sampleDistances
public static double[] sampleDistances(Collection<Path> paths, net.imglib2.img.Img<net.imglib2.type.numeric.real.FloatType> edt) Samples the EDT at every node position of the given paths. Out-of-bounds nodes are silently skipped.- Parameters:
paths- the paths to sampleedt- the distance transform image- Returns:
- array of sampled distance values (may be shorter than total node count if some nodes were out of bounds)
-
sampleDistancesWithIndices
public static List<double[]> sampleDistancesWithIndices(Path path, net.imglib2.img.Img<net.imglib2.type.numeric.real.FloatType> edt) Samples the EDT at each node of a single path, returning the distance value and node index for each in-bounds node.- Parameters:
path- the path to sampleedt- the distance transform image- Returns:
- list of
double[]entries, each{nodeIndex, distance}
-