Path Class Documentation#
Package: sc.fiji.snt
This class represents a traced segment (i.e., a Path) in a reconstruction. It has methods to manipulate its points (nodes) with sup-pixel accuracy, including drawing them onto threePane-style canvases, etc.
Paths are non-branching sequences of adjacent points (including diagonals) in the image. Branches and joins are supported by attributes of paths that specify that they begin on (or end on) other paths.
In SNT, a Path can exist in two versions or flavors: itself and a fitted version generated by PathFitter. Because fitting may fail around certain nodes, the fitted version may have a different number of nodes relatively to its non-fitted version
Methods#
Utilities Methods#
- clone()#
Creates a copy of this Path with optional inclusion of immediate children.
This method creates a clone of this path and optionally includes clones of its immediate child paths. When children are included, they are properly reconnected to the cloned parent path, maintaining the parent-child relationships. Note that only immediate children are cloned - grandchildren and deeper descendants are not included.
Limitations: This method only clones the immediate children and does not recursively clone the entire subtree. For complex tree structures, consider using Tree.clone() instead.
Getters Methods#
- getAngle(int)#
Computes the angle between the specified node and its two flanking neighbors.
With B being the specified node, A its previous neighbor, and C is next neighbor, computes the angle between the vectors AB, and BC.
- getApproximatedSurface()#
Returns an estimated surface area of this path, treating each inter-node segment as a frustum.
- getApproximatedVolume()#
Returns an estimated volume of this path.
The most accurate volume of each path segment would be the volume of a convex hull of two arbitrarily oriented and sized circles in space. This is tough to work out analytically, and this precision isn’t really warranted given the errors introduced in the fitting process, the tracing in the first place, etc. So, this method produces an approximate volume assuming that the volume of each of these parts is that of a truncated cone (Frustum) , with circles of the same size (i.e., as if the circles had simply been reoriented to be parallel and have a common normal vector)
For more accurate measurements of the volumes of a neuron, you should use the filling interface.
- getBranchPoint()#
Gets the branch point (junction) where this path starts, i.e., connects to its parent path.
- getBranchPointIndex()#
Gets the index of the branch point in the parent path.
- getBranchPoints()#
This is a version of findJunctions() ensuring that a junction node is only retrieved once even if multiple child paths are associated with it.
- getCalibration()#
Gets the spatial calibration of this Path.
- getCanvasOffset()#
Returns the translation offset used to render this Path in a TracerCanvas.
- getChannel()#
Gets the hyperstack channel associated with this Path.
- getChildren()#
Gets the list of child paths that branch from this path.
Returns the collection of paths that have this path as their parent. The returned list is the actual internal list, so modifications to it will affect the path’s structure.
- getColor()#
Gets the color of this Path
- getColorRGB()#
Gets the color of this Path
- getContraction()#
Returns the ratio between the “Euclidean distance” of this path and its length. The Euclidean distance of this path is defined as the distance between this Path’s start and end point.
- getEditableNodeIndex()#
Gets the position of the node tagged as ‘editable’, if any.
- getExtensionAngle3D(boolean)#
Returns a single angle representing the 3D extension direction. This is the angle between the path’s direction vector and a reference vector.
- getExtensionAngleFromHorizontal()#
Returns the angle between the path’s 3D direction and the horizontal axis.
- getExtensionAngleFromVertical()#
Returns the angle between the path’s 3D direction and the vertical axis.
- getExtensionAngleXY()#
Returns the overall extension angle of this path in the XY plane. The angle is obtained from the slope of a linear regression across all the path nodes.
- getExtensionAngleXZ()#
Returns the overall extension angle of this path in the XZ plane. The angle is obtained from the slope of a linear regression across all the path nodes.
- getExtensionAngleZY()#
Returns the overall extension angle of this path in the ZY plane. The angle is obtained from the slope of a linear regression across all the path nodes.
- getExtensionAngles3D()#
Returns the complete 3D orientation of this path’s extension direction as spherical coordinates using navigation/compass convention.
This method provides both horizontal direction (azimuth) and vertical inclination (elevation) of the path’s overall extension direction.
- getExtensionDirection3D()#
Returns the 3D extension direction vector of this path using linear regression. The vector represents the overall direction from start to end of the path, fitted through all its nodes.
- getFitted()#
Gets the fitted version (‘flavor’) of this Path.
- getFractalDimension()#
Gets the fractal dimension of this path.
- getFrame()#
Gets the hyperstack frame position associated with this Path.
Visualization Methods#
- addAsLinesTo3DViewer(Image3DUniverse, Color, ImagePlus)#
- addDiscsTo3DViewer(Image3DUniverse, Color3f, ImagePlus)#
- addTo3DViewer(Image3DUniverse, Color3f, ImagePlus)#
Adds this path to the specified 3D viewer universe with the given Color3f.
- drawPathAsPoints(TracerCanvas, Graphics2D, Color, boolean, boolean, int, int)#
Other Methods#
- add(Path)#
- addNode(PointInImage)#
Appends a node to this Path.
- addPointDouble(double, double, double)#
- compareTo(Object)#
- contains(PointInImage)#
Checks if this path contains the specified point within the given tolerance.
- createCircles()#
- createPath()#
Returns a new Path with this Path’s attributes (e.g. spatial scale), but no nodes.
- detachFromParent()#
Detaches this path from its parent, converting it into an independent primary path.
Removes the parent-child relationship established by setBranchFrom(Path, PointInImage) In
Clears the parent path reference and branch point Removes this path from the parent’s children collection Updates bidirectional references for tree traversal Resets the path order to -1 (no hierarchical position) Converts this path from a branch to a primary path
- downsample(double)#
Downsamples this path (in-place) by reducing the number of nodes while preserving its overall shape.
This method reduces the density of nodes in the path by removing redundant points expected to not significantly contribute to the path’s shape. The downsampling is performed using the Douglas-Peucker algorithm, which preserves fidelity within the specified tolerance.
The method operates on the segments flanked by anchor points (junctions, start, and end points). Each segment is downsampled independently, and the results are combined to form the final downsampled path. Node radii are averaged appropriately for retained points
Thread Safety: This method is synchronized to prevent concurrent modification of the path structure during the downsampling operation.
- findJunctionIndices()#
Returns the indices of nodes which are indicated to be a join, either in this Path object, or any other that starts or ends on it.
- findJunctions()#
Returns the nodes which are indicated to be a join (junction/branch point), either in this Path object, or any other that starts or ends on it.
- firstNode()#
Returns the first node of this path.