Class ComponentReconnector<T extends net.imglib2.type.numeric.RealType<T>>

java.lang.Object
sc.fiji.snt.tracing.auto.ComponentReconnector<T>
Type Parameters:
T - pixel type

public class ComponentReconnector<T extends net.imglib2.type.numeric.RealType<T>> extends Object
Bridges gaps between disconnected components of an auto-traced neuron tree.

After auto-tracing (e.g., via GWDTTracer), neurites with dim or fragmented signal may produce disconnected components. Rather than discarding them, this class attempts to reconnect each orphan component to the main tree by running A* searches between nearby endpoints and validating the resulting paths.

Validation criteria (all configurable):

  • Tortuosity: bridge contraction must exceed a minimum (rejects meandering paths through noise)
  • Direction compatibility: the bridge must approach existing branches at a compatible angle
  • Mean intensity: the bridge must pass through sufficiently bright signal
  • Length: the bridge must not exceed the maximum gap distance

Adapted from NeuTube's chain connection logic (Locseg_Chain_Connection_Test).

Author:
Tiago Ferreira
  • Constructor Summary

    Constructors
    Constructor
    Description
    ComponentReconnector(net.imglib2.RandomAccessibleInterval<T> source, double[] spacing)
    Creates a new ComponentReconnector.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    extendTips(DirectedWeightedGraph graph, SWCPoint root, double backgroundThreshold)
    Extends leaf tips of the tree across multi-voxel gaps by scanning for bright signal in each leaf's tangent direction and A*-bridging to it.
    int
    reconnect(DirectedWeightedGraph graph, SWCPoint root, double backgroundThreshold)
    Attempts to reconnect disconnected components in the graph back to the main tree (the component containing the root).
    void
    Sets the cost function for A* searches.
    void
    Sets the heuristic for A* searches.
    void
    setMaxAngleDeg(double degrees)
    Sets the maximum angle (in degrees) between the bridge tangent and the existing branch direction at connection points.
    void
    Sets the maximum Euclidean distance (in voxels) between candidate endpoints.
    void
    setMinContraction(double contraction)
    Sets the minimum contraction (Euclidean distance / path length) for accepting a bridge.
    void
    setMinMeanIntensity(double intensity)
    Sets the minimum mean intensity along the bridge path.
    void
    setTimeoutPerSearch(int seconds)
    Sets the A* search timeout per candidate pair, in seconds.
    void
    setVerbose(boolean verbose)
    Enables or disables verbose logging.

    Methods inherited from class java.lang.Object

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

    • ComponentReconnector

      public ComponentReconnector(net.imglib2.RandomAccessibleInterval<T> source, double[] spacing)
      Creates a new ComponentReconnector.
      Parameters:
      source - the grayscale image used for tracing
      spacing - voxel dimensions [x, y, z] in physical units
  • Method Details

    • setMaxBridgeDistVoxels

      public void setMaxBridgeDistVoxels(double dist)
      Sets the maximum Euclidean distance (in voxels) between candidate endpoints. Pairs farther apart are not considered. Default: 20.
    • setMinContraction

      public void setMinContraction(double contraction)
      Sets the minimum contraction (Euclidean distance / path length) for accepting a bridge. Values close to 1.0 require near-straight bridges; lower values tolerate more tortuous paths. Default: 0.6.
    • setMaxAngleDeg

      public void setMaxAngleDeg(double degrees)
      Sets the maximum angle (in degrees) between the bridge tangent and the existing branch direction at connection points. Default: 60.
    • setMinMeanIntensity

      public void setMinMeanIntensity(double intensity)
      Sets the minimum mean intensity along the bridge path. Set to Double.NaN to use the auto-traced threshold. Default: NaN.
    • setTimeoutPerSearch

      public void setTimeoutPerSearch(int seconds)
      Sets the A* search timeout per candidate pair, in seconds. Default: 5.
    • setCostFunction

      public void setCostFunction(Cost cost)
      Sets the cost function for A* searches. If not set, defaults to Reciprocal using the source image intensity range.
    • setHeuristic

      public void setHeuristic(Heuristic h)
      Sets the heuristic for A* searches. If not set, defaults to Euclidean.
    • setVerbose

      public void setVerbose(boolean verbose)
      Enables or disables verbose logging.
    • reconnect

      public int reconnect(DirectedWeightedGraph graph, SWCPoint root, double backgroundThreshold)
      Attempts to reconnect disconnected components in the graph back to the main tree (the component containing the root).
      Parameters:
      graph - the directed weighted graph to modify in place
      root - the root node of the main tree
      backgroundThreshold - intensity threshold used during tracing (used as fallback for minMeanIntensity if not set)
      Returns:
      the number of components successfully reconnected
    • extendTips

      public int extendTips(DirectedWeightedGraph graph, SWCPoint root, double backgroundThreshold)
      Extends leaf tips of the tree across multi-voxel gaps by scanning for bright signal in each leaf's tangent direction and A*-bridging to it.

      Unlike reconnect(sc.fiji.snt.analysis.graph.DirectedWeightedGraph, sc.fiji.snt.util.SWCPoint, double), which bridges disconnected components already present in the graph, this method discovers unreached foreground signal beyond the Fast Marching frontier (which stops at multi-voxel gaps) and traces through the gap to reach it.

      Parameters:
      graph - the directed weighted graph to modify in place
      root - the root node of the main tree
      backgroundThreshold - intensity threshold used during tracing
      Returns:
      the number of tips successfully extended