Class DetectorUtils

java.lang.Object
sc.fiji.snt.analysis.detection.DetectorUtils

public final class DetectorUtils extends Object
Shared utilities for path-based detectors (PeripathDetector, AlongPathDetector).
Author:
Tiago Ferreira
  • Method Summary

    Modifier and Type
    Method
    Description
    static List<Detection>
    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.
    static List<Detection>
    deduplicate(List<Detection> detections, double mergingDistance)
    Deduplicates detections using greedy non-maximum suppression by intensity.
    static double
    interpolateRadius(double[] radii, int idx, double fallback)
    Simple linear interpolation for a missing radius value at idx, using the nearest valid neighbors.
    static double[]
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • prepareRadii

      public static double[] prepareRadii(Path path)
      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 at idx, using the nearest valid neighbors.
      Parameters:
      radii - the radius array
      idx - index of the missing value
      fallback - value to use if no valid neighbors exist
      Returns:
      interpolated radius
    • deduplicate

      public static List<Detection> deduplicate(List<Detection> detections, double mergingDistance)
      Deduplicates detections using greedy non-maximum suppression by intensity.
      Parameters:
      detections - the raw detections
      mergingDistance - 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 reassign
      allPaths - 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) image
      labelVal - the label value to compute the EDT for
      spacing - pixel spacing per dimension (used for calibrated EDT). If null, spacing is resolved from the image via ImgUtils.resolveSpacing(RandomAccessibleInterval, double[]).
      Returns:
      the EDT as a float image, or null if labelRAI is 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 sample
      edt - 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 sample
      edt - the distance transform image
      Returns:
      list of double[] entries, each {nodeIndex, distance}