Class Path
- All Implemented Interfaces:
Cloneable,Comparable<Path>
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classEnhanced PointInImage that stores all node-specific properties. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected PointInCanvasprotected static final intprotected Pathprotected Pathprotected static final intDeprecated.protected Pathprotected Stringstatic final intSWC type flag specifying "apical dendrite"static final StringString representation ofSWC_APICAL_DENDRITEstatic final intSWC type flag specifying "axon"static final StringString representation ofSWC_AXONstatic final intSWC type flag specifying "custom"static final StringString representation ofSWC_CUSTOMstatic final intSWC type flag specifying "custom (2)"static final StringString representation ofSWC_CUSTOM2static final intSWC type flag specifying "(basal) dendrite"static final StringString representation ofSWC_DENDRITEstatic final intDeprecated.static final intDeprecated.static final intSWC type flag specifying "glia process"static final StringString representation ofSWC_GLIA_PROCESSstatic final intSWC type flag specifying "soma"static final StringString representation ofSWC_SOMAstatic final intSWC type flag specifying "undefined"static final StringString representation ofSWC_UNDEFINEDstatic final intSWC type flag specifying "unspecified neurite"static final StringString representation ofSWC_UNSPECIFIEDprotected doubleprotected doubleprotected double -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidij3d.ContentaddAsLinesTo3DViewer(ij3d.Image3DUniverse univ, Color c, ij.ImagePlus colorImage) Deprecated.protected ij3d.ContentaddAsLinesTo3DViewer(ij3d.Image3DUniverse univ, org.jogamp.vecmath.Color3f c, ij.ImagePlus colorImage) Deprecated.protected voidaddChangeListener(sc.fiji.snt.PathChangeListener listener) ij3d.ContentaddDiscsTo3DViewer(ij3d.Image3DUniverse univ, Color c, ij.ImagePlus colorImage) Deprecated.ij3d.ContentaddDiscsTo3DViewer(ij3d.Image3DUniverse univ, org.jogamp.vecmath.Color3f c, ij.ImagePlus colorImage) Deprecated.voidaddNode(PointInImage point) Appends a node to this Path.voidaddPointDouble(double x, double y, double z) voidaddTo3DViewer(ij3d.Image3DUniverse univ, Color c, ij.ImagePlus colorImage) Deprecated.This method is deprecated.voidaddTo3DViewer(ij3d.Image3DUniverse univ, org.jogamp.vecmath.Color3f c, ij.ImagePlus colorImage) Deprecated.This method is deprecated.protected voidbrushBlendRadii(int center, int radius) Smears the center node's radius to flanking nodes using cosine^2-weighted interpolation.protected voidbrushMove(int center, int radius, double dx, double dy, double dz) Applies a cosine-squared-weighted displacement to nodes around a center index.protected Stringclone()Creates a deep copy of this Path.clone(boolean includeImmediateChildren) Creates a copy of this Path with optional inclusion of immediate children.intbooleancontains(PointInImage pim) Check whether this Path contains the specified pointbooleancontains(PointInImage point, double tolerance) Checks if this path contains the specified point within the given tolerance.protected booleanvoidDeprecated.No longer needed - radii and tangents are now stored per-nodeReturns a new Path with this Path's attributes (e.g. spatial scale), but no nodes.voidDetaches this path from its parent, converting it into an independent primary path.protected voidprotected voidvoiddownsample(double internodeSpacing) Downsamples this path (in-place) by reducing the number of nodes while preserving its overall shape.protected voiddrawPathAsPoints(Graphics2D g2, TracerCanvas canvas, SNT snt) voiddrawPathAsPoints(TracerCanvas canvas, Graphics2D g2, Color c, boolean highContrast, boolean drawDiameter, int slice, int either_side) voiddrawPathAsPoints(TracerCanvas canvas, Graphics2D g, Color c, int plane, boolean highContrast, boolean drawDiameter) protected voiddrawPathAsPoints(TracerCanvas canvas, Graphics2D g, Color c, int plane, boolean drawDiameter, int slice, int either_side) 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.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.Returns the first node of this path.booleanfitRadii(ij.ImagePlus imp) Fits radii to this Path by fitting circular cross-sections to the image signal.doublegetAngle(int nodeIndex) Computes the angle between the specified node and its two flanking neighbors.doubleReturns an estimated surface area of this path, treating each inter-node segment as a frustum.doubleReturns an estimated volume of this path.Gets the branch point (junction) where this path starts, i.e., connects to its parent path.protected PointInImageReturns the branch point as it should be rendered on screen.intGets the index of the branch point in the parent path.This is a version offindJunctions()ensuring that a junction node is only retrieved once even if multiple child paths are associated with it.ij.measure.CalibrationGets the spatial calibration of this Path.Returns the translation offset used to render this Path in aTracerCanvas.intGets the hyperstack channel associated with this Path.Gets the list of child paths that branch from this path.getColor()Gets the color of this Pathorg.scijava.util.ColorRGBGets the color of this PathdoubleReturns the ratio between the "Euclidean distance" of this path and its length.intGets the position of the node tagged as 'editable', if any.doublegetExtensionAngle3D(boolean relative) Returns either the compass bearing or the relative branching angle of this path's 3D extension direction.doublegetExtensionAngle3D(org.jogamp.vecmath.Vector3d referenceVector) Returns a single angle representing the 3D extension direction.doubleReturns the angle between the path's 3D direction and the horizontal axis.doubleReturns the angle between the path's 3D direction and the vertical axis.double[]Returns the complete 3D orientation of this path's extension direction as spherical coordinates using navigation/compass convention.doubleReturns the overall extension angle of this path in the XY plane.doubleReturns the overall extension angle of this path in the XZ plane.doubleReturns the overall extension angle of this path in the ZY plane.org.jogamp.vecmath.Vector3dReturns the 3D extension direction vector of this path using linear regression.Gets the fitted version ('flavor') of this Path.doubleGets the fractal dimension of this path.intgetFrame()Gets the hyperstack frame position associated with this Path.intgetID()Gets the identifier of this Pathdouble[]getInitialDirection(int maxNodes) Returns a (non-normalized) direction vector from the first node to the node at indexmin(maxNodes, size()-1).getInterpolatedPath(double maxDistance) Returns a new Path in which nodes have been interpolated to ensure that the distance between consecutive nodes does not exceed the specified threshold.Deprecated.usegetBranchPoints()insteaddoubleGets the length of this PathdoubleGets the path mean radius.doublegetName()Gets this Path's name.getNode(int pos) Gets the node at the specified position.protected Path.PathNodegetNodeAnnotation(int pos) Returns the neuropil annotation associated with this node.getNodeColor(int pos) Gets the node color.Color[]Gets the node colors.chargetNodeHemisphereFlag(int pos) Returns the hemisphere flag associated with this node.intgetNodeIndex(PointInImage pim) Gets the first node index associated with the specified image coordinates.doublegetNodeRadius(int pos) Gets the radius of the specified node.getNodes()Gets all nodes as a list.double[]getNodeTangent(int pos) Gets the tangent vector of a specific node.doublegetNodeValue(int pos) Returns the "value" property of this node.protected Path.PathNodegetNodeWithChecks(int pos) Gets the internal PathNode at the specified position (for advanced operations).protected Path.PathNodegetNodeWithoutChecks(int pos) Gets the internal PathNode at the specified position (for advanced operations).intgetOrder()Gets the "bifurcation" (branching) order of this Path.Gets the parent path that this path branches from.List<org.jogamp.vecmath.Point3f> Deprecated.protected voidgetPointDouble(int i, double[] p) getPointInCanvas(int node) protected PointInCanvasgetPointInCanvas2D(int node, TracerCanvas canvas) protected StringgetResampledPath(double targetSpacing) Returns a new Path in which nodes have been resampled to ensure uniform spacing along the path.getSection(int startIndex, int endIndex) Gets a section between two nodes of this Path.getSmoothedPath(int windowSize) Returns a smoothed version of this path using a simple moving average filter.intGets the number of spines or varicosities associated with this path.Deprecated.usegetParentPath()insteadDeprecated.UsegetBranchPoint()instead.static ColorgetSWCcolor(int swcType) Gets the default SWC colors used by SNT.intGets the SWC type.static StringgetSWCtypeName(int type, boolean capitalized) Gets the SWC type label associated with the specified type flag.Gets the list of string representations of SWC typesGets the list of SWC types.voidgetTangent(int i, int pointsEitherSide, double[] result) intGets the identifier of theTreeassociated to this Path (if any).Gets the original (unfitted) path that this path is a fitted version of.protected List<PointInCanvas> booleanGets whether the fitted 'flavor' of this Path is in use.intgetXUnscaled(int i) Returns the unscaled X position of a node.doublegetXUnscaledDouble(int i) intgetYUnscaled(int i) Returns the unscaled Y position of a node.doublegetYUnscaledDouble(int i) intgetZUnscaled(int i) Returns the unscaled Z position of a node.doublegetZUnscaledDouble(int i) booleanAssesses whether a custom color has been assigned to this Path.booleanAssesses whether the nodes of this path have been assignedBrainAnnotations.booleanChecks whether any nodes have custom colors assigned.booleanAssesses whether the nodes of this path have been assigned hemisphere flags.booleanAssesses whether the nodes of this path have been assigned an array of valuesbooleanhasRadii()Checks whether the nodes of this path have been assigned defined thickness.booleanChecks whether any nodes have tangent vectors defined.protected intindexNearestTo(double x, double y, double z) intindexNearestTo(double x, double y, double z, double within) Gets the index of the closest node associated with the specified world coordinates.protected intindexNearestToCanvasPosition2D(double xInCanvas, double yInCanvas, double withinPixels) intindexNearestToUnscaled(double x, double y, double z) Returns the index of the node nearest to the specified position in pixel (unscaled) coordinates, searching across all nodes regardless of distance.intindexNearestToUnscaled(double x, double y, double z, double within) Returns the index of the node nearest to the specified position in pixel (unscaled) coordinates.voidinsertNode(int index, PointInImage point) Inserts a node at a specified position.voidinsertNode(int index, SNTPoint point) Inserts a node at the specified position.interpolateMissingRadii(DoublePredicate predicate, boolean apply) Deprecated.UsesanitizeRadii(DoublePredicate, boolean)insteadbooleanChecks if this version of the path is currently being used for display/analysis.protected booleanbooleanisConnectedTo(Path other) protected booleanbooleanChecks if this Path is a fitted version of another path.booleanChecks if this Path is root.booleanlastNode()Returns the last node of this path.voidmoveNode(int index, double x, double y, double z) Assigns a new location to the specified node using raw coordinates.voidmoveNode(int index, PointInImage destination) Assigns a new location to the specified node.nearestNodeTo(PointInImage node, double within) Gets the closest node associated with the specified node.protected static Stringprotected voidprotected booleanremoveChangeListener(sc.fiji.snt.PathChangeListener listener) voidremoveFrom3DViewer(ij3d.Image3DUniverse univ) Deprecated.This method is deprecated.voidremoveNode(int index) Removes the specified node if this path has at least two nodes.voidreplaceNodes(Path replacementPath) Replaces all nodes of this path with those from the replacement path, preserving hierarchical relationships (parent, children, connections).protected voidvoidResets this path color, forcing SNT to render it under default settings.voidreverse()Reverses this path so that its starting node becomes the last and vice versa.reversed()sanitizeRadii(boolean apply) Sanitizes node radii by interpolating invalid values (zero, NaN, or negative).sanitizeRadii(double minRadius, double maxRadius, boolean apply) Sanitizes node radii by enforcing bounds and interpolating outliers.sanitizeRadii(DoublePredicate predicate, boolean apply) Sanitizes node radii by interpolating values that match the given predicate.voidsetBranchFrom(Path parentPath, PointInImage branchPoint) Establishes this path as a child path originating from the specified parent path.voidsetCanvasOffset(PointInCanvas canvasOffset) Specifies a translation offset when rendering this Path in aTracerCanvas.protected voidsetChildren(Set<Path> pathsLeft) voidSets this path color.voidsetColor(org.scijava.util.ColorRGB color) Sets this path color.voidsetCTposition(int channel, int frame) Sets the hyperstack position of this PathvoidsetEditableNode(int index) Tags the specified point position as 'editable'.protected voidsetEditableNodeLocked(boolean editableNodeLocked) protected voidprotected voidsetFittedCircles(int nPoints, double[] tangents_x, double[] tangents_y, double[] tangents_z, double[] radii, double[] optimized_x, double[] optimized_y, double[] optimized_z) voidsetGuessedTangents(int pointsEitherSide) protected voidsetIDs(int pathID, int treeID) protected voidsetIsPrimary(boolean primary) voidSets this Path's name.voidsetNodeAnnotation(BrainAnnotation annotation, int pos) Assigns an annotation to an existing node.voidsetNodeColor(Color color, int pos) Sets the node color.voidsetNodeColor(org.scijava.util.ColorRGB color, int pos) Sets the node color.voidsetNodeColors(Color[] colors) Sets the node colors.voidsetNodeHemisphere(char hemisphereFlag, int pos) Assigns a hemisphere to an existing node.voidsetNodeRadius(double radius, int pos) Sets the radius of a specific node.voidsetNodeTangent(double[] tangent, int pos) Sets the tangent vector of a specific node.voidsetNodeTangent(double tx, double ty, double tz, int pos) Sets the tangent vector of a specific node.voidsetNodeValue(double value, int pos) Assigns the "value" property to this node.voidsetNodeValues(double[] values) Sets the path "values", the array containing the numeric property assigned to path nodes, typically voxel intensities.voidsetOrder(int order) voidsetRadii(double[] radii) Assigns radii to this PathvoidsetRadius(double r) Assigns a fixed radius to all the nodes of this PathvoidsetRadius(double r, int index) Assigns a radius to a specific node of this Path.voidsetSelected(boolean newSelectedStatus) voidsetSpacing(double xSpacing, double ySpacing, double zSpacing, String unit) protected voidsetSpacing(ij.measure.Calibration cal) voidsetSpineOrVaricosityCount(int newCount) Sets the number of spines or varicosities associated with this path.voidsetStartJoin(Path parentPath, PointInImage branchPoint) Deprecated.usesetBranchFrom(Path, PointInImage)insteadvoidsetSWCType(int newSWCType) Sets the SWC type.protected voidsetSWCType(int newSWCType, boolean alsoSetInFittedVersion) protected voidsetTreeLabel(String treeLabel) voidsetUseFitted(boolean useFitted) Sets whether the fitted flavor of this Path should be used.intsize()Returns the number of nodes of this pathprotected StringtoString()This toString() method shows details of the path which is actually being displayed, not necessarily this path object.transform(PathTransformer transformation, ij.ImagePlus template, ij.ImagePlus model) voidDeprecated.voidupsample(double internodeSpacing) Upsamples this path by spacing nodes at a specified distance.booleanDeprecated.UseisActiveVersion()instead
-
Field Details
-
SWC_UNDEFINED
public static final int SWC_UNDEFINEDSWC type flag specifying "undefined"- See Also:
-
SWC_SOMA
public static final int SWC_SOMASWC type flag specifying "soma"- See Also:
-
SWC_AXON
public static final int SWC_AXONSWC type flag specifying "axon"- See Also:
-
SWC_DENDRITE
public static final int SWC_DENDRITESWC type flag specifying "(basal) dendrite"- See Also:
-
SWC_APICAL_DENDRITE
public static final int SWC_APICAL_DENDRITESWC type flag specifying "apical dendrite"- See Also:
-
SWC_CUSTOM
public static final int SWC_CUSTOMSWC type flag specifying "custom"- See Also:
-
SWC_UNSPECIFIED
public static final int SWC_UNSPECIFIEDSWC type flag specifying "unspecified neurite"- See Also:
-
SWC_GLIA_PROCESS
public static final int SWC_GLIA_PROCESSSWC type flag specifying "glia process"- See Also:
-
SWC_CUSTOM2
public static final int SWC_CUSTOM2SWC type flag specifying "custom (2)"- See Also:
-
SWC_FORK_POINT
Deprecated.Deprecated. No longer part of the SWC specification- See Also:
-
SWC_END_POINT
Deprecated.Deprecated. No longer part of the SWC specification- See Also:
-
SWC_UNDEFINED_LABEL
String representation ofSWC_UNDEFINED- See Also:
-
SWC_SOMA_LABEL
String representation ofSWC_SOMA- See Also:
-
SWC_AXON_LABEL
String representation ofSWC_AXON- See Also:
-
SWC_DENDRITE_LABEL
String representation ofSWC_DENDRITE- See Also:
-
SWC_APICAL_DENDRITE_LABEL
String representation ofSWC_APICAL_DENDRITE- See Also:
-
SWC_CUSTOM_LABEL
String representation ofSWC_CUSTOM- See Also:
-
SWC_UNSPECIFIED_LABEL
String representation ofSWC_UNSPECIFIED- See Also:
-
SWC_GLIA_PROCESS_LABEL
String representation ofSWC_GLIA_PROCESS- See Also:
-
SWC_CUSTOM2_LABEL
String representation ofSWC_CUSTOM2- See Also:
-
DEFAULT_SAMPLING_INTERVAL
protected static final int DEFAULT_SAMPLING_INTERVAL- See Also:
-
noMoreThanOneEvery
Deprecated.UseDEFAULT_SAMPLING_INTERVALinstead- See Also:
-
canvasOffset
-
x_spacing
protected double x_spacing -
y_spacing
protected double y_spacing -
z_spacing
protected double z_spacing -
spacing_units
-
parentPath
-
branchPointIndex
protected int branchPointIndex -
connectedPaths
-
children
-
fitted
-
fittedVersionOf
-
-
Constructor Details
-
Path
public Path()Instantiates a new path under default settings (isotropic 1um pixel spacing) -
Path
Instantiates a new path.- Parameters:
x_spacing- Pixel width in spacing_unitsy_spacing- Pixel height in spacing_unitsz_spacing- Pixel depth in spacing_unitsspacing_units- the length unit in physical world units (typically "um").
-
-
Method Details
-
compareTo
- Specified by:
compareToin interfaceComparable<Path>
-
getID
public int getID()Gets the identifier of this Path- Returns:
- the identifier
-
getTreeID
public int getTreeID()Gets the identifier of theTreeassociated to this Path (if any).- Returns:
- the Tree identifier
-
setIDs
protected void setIDs(int pathID, int treeID) -
setTreeLabel
-
getTreeLabel
-
setCanvasOffset
Specifies a translation offset when rendering this Path in aTracerCanvas. Path coordinates remain unaltered.- Parameters:
canvasOffset- the x,y,z coordinates (pixel-based) specifying the translation offset
-
getCanvasOffset
Returns the translation offset used to render this Path in aTracerCanvas.- Returns:
- the rendering offset (in pixel coordinates)
-
getParentPath
Gets the parent path that this path branches from.Returns the path from which this path originates as a branch. For primary (root) paths, this method returns null since they don't branch from any other path. The parent-child relationship is established when a path is created as a branch using
setBranchFrom(Path, PointInImage).- Returns:
- the parent path, or null if this is a primary (root) path
- See Also:
-
getStartJoins
Deprecated.usegetParentPath()instead -
getBranchPoint
Gets the branch point (junction) where this path starts, i.e., connects to its parent path.- Returns:
- the start junction point, or null if this is a primary path
- See Also:
-
getBranchPointDisplay
Returns the branch point as it should be rendered on screen. When the parent path is displayed as its fitted version, returns the fitted node so the connection line matches the visual representation. Otherwise identical togetBranchPoint().- Returns:
- the display branch point, or null if this is a primary path
-
getBranchPointIndex
public int getBranchPointIndex()Gets the index of the branch point in the parent path.- Returns:
- the branch point index, or -1 if this is a primary path
-
getStartJoinsPoint
Deprecated.UsegetBranchPoint()instead.NB: Earlier versions of Simple Neurite Tracer allowed paths to connect at either the start point (getStartJoinsPoint()) or end-point (getStartJoinsPoint()). Useful for some applications but a huge headache to handle.
-
setName
Sets this Path's name. Set it to null or"", to reset it to the default.- Parameters:
newName- the new name.- See Also:
-
getName
Gets this Path's name.- Returns:
- the name. If no name as been set, the default name is returned.
- See Also:
-
pathsToIDListString
-
somehowJoinsAsString
-
childrenAsString
-
setChildren
-
getContraction
public double 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.- Returns:
- the Contraction of this Path, or
NaNif this Path has no length
-
getFractalDimension
public double getFractalDimension()Gets the fractal dimension of this path.- Returns:
- the fractal dimension of this path or Double.NaN if this path has less than 5 nodes
-
getLength
public double getLength()Gets the length of this Path- Returns:
- the length of this Path
-
getAngle
public double getAngle(int nodeIndex) 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.
- Returns:
- the angle in degrees (0-360 range) or Double.NaN if specified node does not have sufficient neighbors
-
getExtensionAngleXY
public double 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.- Returns:
- the overall 'extension' angle in degrees [0-360[ of this path in the XY plane.
-
getExtensionAngleXZ
public double 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.- Returns:
- the overall 'extension' angle in degrees [0-360[ in the XZ plane or NaN if path is 2D.
-
getExtensionAngleZY
public double 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.- Returns:
- the overall 'extension' angle in degrees [0-360[ in the ZY plane or NaN if path is 2D.
-
getInitialDirection
public double[] getInitialDirection(int maxNodes) Returns a (non-normalized) direction vector from the first node to the node at indexmin(maxNodes, size()-1). This is useful for measuring the initial heading of a child path near a fork point.- Parameters:
maxNodes- the maximum node index to use as the end point- Returns:
- a 3-element array
[dx, dy, dz], ornullif the path has fewer than 2 nodes or the resulting vector is zero-length
-
getExtensionDirection3D
public org.jogamp.vecmath.Vector3d 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.- Returns:
- the normalized Vector3d (length of 1) representing the extension direction, or null if path has only one point
-
getExtensionAngle3D
public double getExtensionAngle3D(boolean relative) Returns either the compass bearing or the relative branching angle of this path's 3D extension direction.- Parameters:
relative- determines the calculation mode: - false: returns compass bearing in XY plane (absolute angle) - true: returns angle relative to parent path (relative angle)- Returns:
- when relative=false: compass bearing in degrees (0-360°) using navigation convention:
0° = North (negative Y direction in image coordinates),
90° = East (positive X direction),
180° = South (positive Y direction in image coordinates),
270° = West (negative X direction).
The 3D direction vector is projected onto the XY plane for compass calculation.
When relative=true: acute angle in degrees (0-180°) between this path's 3D direction vector and its parent path's 3D direction vector. This measures the true 3D branching angle, not just the XY projection.
Returns Double.NaN if: - Path has only one point (cannot determine direction) - relative=true and path has no parent (startJoins is null) - relative=true and parent path has no direction (single point parent)
- See Also:
-
getExtensionAngles3D
public double[] 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.
- Returns:
- double array containing [azimuth, elevation] in degrees, where:
azimuth (index 0): Compass bearing in XY plane (0-360°) following navigation convention:
- 0° = North (negative Y direction in image coordinates)
- 90° = East (positive X direction)
- 180° = South (positive Y direction in image coordinates)
- 270° = West (negative X direction)
elevation (index 1): Vertical angle from XY plane (-90° to +90°):
- 0° = horizontal (parallel to XY plane)
- +90° = pointing straight up (positive Z direction)
- -90° = pointing straight down (negative Z direction)
Returns null if path has only one point or extension direction cannot be determined
- See Also:
-
getExtensionAngle3D
public double getExtensionAngle3D(org.jogamp.vecmath.Vector3d referenceVector) Returns a single angle representing the 3D extension direction. This is the angle between the path's direction vector and a reference vector.- Parameters:
referenceVector- the reference vector to measure angle from (e.g., new Vector3d(0, 0, 1) for vertical reference, or new Vector3d(1, 0, 0) for horizontal)- Returns:
- the acute angle in degrees (0-180°), or Double.NaN if path has only one point
-
getExtensionAngleFromVertical
public double getExtensionAngleFromVertical()Returns the angle between the path's 3D direction and the vertical axis.- Returns:
- angle from vertical in degrees (0° = vertical, 90° = horizontal), or Double.NaN if path has only one point, or 90° if path is 2D
-
getExtensionAngleFromHorizontal
public double getExtensionAngleFromHorizontal()Returns the angle between the path's 3D direction and the horizontal axis.- Returns:
- angle from horizontal in degrees (09° = vertical, 0° = horizontal), or Double.NaN if path has only one point.
-
getRealLengthString
-
createCircles
Deprecated.No longer needed - radii and tangents are now stored per-node -
setIsPrimary
protected void setIsPrimary(boolean primary) -
isPrimary
public boolean isPrimary()Checks if this Path is root.- Returns:
- true, if is primary (root)
-
disconnectFromAll
protected void disconnectFromAll() -
setBranchFrom
Establishes this path as a child path originating from the specified parent path.In detail:
- Sets the parent path that this path branches from
- Records the exact point where branching occurs
- Adds this path to the parent's children collection
- Updates this path's order to be parent order + 1
- Maintains bidirectional references for tree traversal
- Parameters:
parentPath- the parent path that this path branches from. Must not be null. Some operations may expect it to be an existing path in the same tree structurebranchPoint- the exact 3D coordinate where this path branches from the parent. Must not be null and should correspond to a location on or near the parent path- Throws:
IllegalArgumentException- if parentPath is nullIllegalArgumentException- if this path already has a parent (usedetachFromParent()first to detach)- See Also:
-
setStartJoin
Deprecated.usesetBranchFrom(Path, PointInImage)instead -
replaceNodesWithFittedVersion
protected void replaceNodesWithFittedVersion() -
rebuildConnectionsOfFittedVersion
protected void rebuildConnectionsOfFittedVersion() -
unsetStartJoin
Deprecated. -
detachFromParent
public void 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
- Throws:
IllegalArgumentException- if this path has no parent (i.e., is already a primary path). UsegetParentPath()to check before calling this method.- See Also:
-
getMinimumSeparation
public double getMinimumSeparation() -
size
public int size()Returns the number of nodes of this path- Returns:
- the size, i.e., number of nodes
-
getNodes
Gets all nodes as a list.- Returns:
- a new list containing all nodes
-
getPointDouble
protected void getPointDouble(int i, double[] p) -
getNode
Gets the node at the specified position.- Parameters:
pos- the position index (0-based). NB: You can use -1 to retrieve the last node in the Path- Returns:
- the node
- Throws:
IndexOutOfBoundsException- if position is out-of-range
-
getNode
-
getNodeWithoutChecks
Gets the internal PathNode at the specified position (for advanced operations). -
getNodeWithChecks
Gets the internal PathNode at the specified position (for advanced operations). -
getPointInCanvas
-
getPointInCanvas2D
-
getUnscaledNodesInViewPort
-
containsUnscaledNodesInViewPort
-
contains
Check whether this Path contains the specified point- Parameters:
pim- thePointInImagenode- Returns:
- true, if successful
-
insertNode
Inserts a node at a specified position.- Parameters:
index- the (zero-based) index of the position of the new nodepoint- the node to be inserted- Throws:
IllegalArgumentException- if index is out-of-range
-
insertNode
Inserts a node at the specified position.- Parameters:
index- the position at which the node is to be insertedpoint- the node to be inserted- Throws:
IllegalArgumentException- if index is out-of-range
-
removeNode
public void removeNode(int index) Removes the specified node if this path has at least two nodes. Does nothing if this is a single point path.- Parameters:
index- the zero-based index of the node to be removed- Throws:
IllegalArgumentException- if index is out-of-range
-
moveNode
Assigns a new location to the specified node.- Parameters:
index- the zero-based index of the node to be modifieddestination- the new node location- Throws:
IllegalArgumentException- if index is out-of-range
-
moveNode
public void moveNode(int index, double x, double y, double z) Assigns a new location to the specified node using raw coordinates. This is a performance-optimized version ofmoveNode(int, PointInImage)that avoids object allocation.- Parameters:
index- the index of the node to movex- the new x coordinatey- the new y coordinatez- the new z coordinate- Throws:
IndexOutOfBoundsException- if the index is out of range
-
brushMove
protected void brushMove(int center, int radius, double dx, double dy, double dz) Applies a cosine-squared-weighted displacement to nodes around a center index. Used by paint-mode brush editing for efficient batch node movement.- Parameters:
center- the index of the node under the cursorradius- how many flanking nodes on each side to affectdx- displacement in x (calibrated units)dy- displacement in ydz- displacement in z
-
brushBlendRadii
protected void brushBlendRadii(int center, int radius) Smears the center node's radius to flanking nodes using cosine^2-weighted interpolation. Each affected node's radius is pulled toward the center node's radius proportionally to the brush weight.- Parameters:
center- the index of the center node (source radius)radius- the brush radius in node indices
-
getNodeIndex
Gets the first node index associated with the specified image coordinates. Returns -1 if no such node was found.- Parameters:
pim- the image position (calibrated coordinates)- Returns:
- the index of the first node occurrence or -1 if there is no such occurrence
-
nearestNodeTo
Gets the closest node associated with the specified node.- Parameters:
node- location to be searched forwithin- sets the search sensitivity. E.g., Setting it to Double.MAX_VALUE (or the image's largest dimension) will always return a valid node.- Returns:
- the closest node to the specified one or null if no such node was found.
-
indexNearestTo
public int indexNearestTo(double x, double y, double z, double within) Gets the index of the closest node associated with the specified world coordinates.- Parameters:
x- the x-coordinates (spatially calibrated image units)y- the y-coordinates (spatially calibrated image units)z- the z-coordinates (spatially calibrated image units)within- sets the search sensitivity. E.g., Setting it to Double.MAX_VALUE (or the image's largest dimension) will always return a valid index.- Returns:
- the index of the closest node to the specified coordinates. Returns -1 if no such node was found.
-
indexNearestToCanvasPosition2D
protected int indexNearestToCanvasPosition2D(double xInCanvas, double yInCanvas, double withinPixels) -
indexNearestTo
protected int indexNearestTo(double x, double y, double z) -
indexNearestToUnscaled
public int indexNearestToUnscaled(double x, double y, double z, double within) Returns the index of the node nearest to the specified position in pixel (unscaled) coordinates. This is useful when matching ROI positions (which are always in pixel coordinates) to path nodes. Canvas offsets are handled automatically.- Parameters:
x- the x-coordinate in pixel unitsy- the y-coordinate in pixel unitsz- the z-coordinate in pixel units (0-based slice index)within- the search radius in pixel units. Only nodes within this distance are considered. UseDouble.MAX_VALUEto always return the closest node regardless of distance.- Returns:
- the index of the closest node, or -1 if no node was found within the specified radius
- See Also:
-
indexNearestToUnscaled
public int indexNearestToUnscaled(double x, double y, double z) Returns the index of the node nearest to the specified position in pixel (unscaled) coordinates, searching across all nodes regardless of distance.- Parameters:
x- the x-coordinate in pixel unitsy- the y-coordinate in pixel unitsz- the z-coordinate in pixel units (0-based slice index)- Returns:
- the index of the closest node
- See Also:
-
getEditableNodeIndex
public int getEditableNodeIndex()Gets the position of the node tagged as 'editable', if any.- Returns:
- the index of the point currently tagged as editable, or -1 if no such point exists
-
setEditableNode
public void setEditableNode(int index) Tags the specified point position as 'editable'.- Parameters:
index- the index of the point to be tagged. Set it to -1 to for no tagging
-
isBeingEdited
protected boolean isBeingEdited() -
isEditableNodeLocked
protected boolean isEditableNodeLocked() -
setEditableNodeLocked
protected void setEditableNodeLocked(boolean editableNodeLocked) -
getXUnscaled
public int getXUnscaled(int i) Returns the unscaled X position of a node.- Parameters:
i- the index of the path node- Returns:
- the 0-based index of the X-position of the node.
-
getYUnscaled
public int getYUnscaled(int i) Returns the unscaled Y position of a node.- Parameters:
i- the index of the path node- Returns:
- the 0-based index of the Y-position of the node.
-
getZUnscaled
public int getZUnscaled(int i) Returns the unscaled Z position of a node.- Parameters:
i- the index of the path node- Returns:
- the 0-based index of the Z-position of the node. Note that Z-indices in ImagePlus are 1-based,
i.e., outside SNT the proper Z-slice for this position in an ImagePlus is
getZUnscaled(i) + 1
-
getXUnscaledDouble
public double getXUnscaledDouble(int i) -
getYUnscaledDouble
public double getYUnscaledDouble(int i) -
getZUnscaledDouble
public double getZUnscaledDouble(int i) -
getUnscaledNodes
- Returns:
- the list of nodes in image space (pixel coordinates). This takes already takes into account
getCanvasOffset().
-
getSection
Gets a section between two nodes of this Path.- Parameters:
startIndex- the node index defining the first node of the sectionendIndex- the node index defining the last node of the section- Returns:
- the section. Note that the sectioned Path will share of all of this Path's properties but will not contain any information on junction points or connectivity to other Paths.
-
createPath
Returns a new Path with this Path's attributes (e.g. spatial scale), but no nodes.- Returns:
- the empty path
-
replaceNodes
Replaces all nodes of this path with those from the replacement path, preserving hierarchical relationships (parent, children, connections).This method is useful for refining path geometry (e.g., from A* tracing) while maintaining the tree structure.
- Parameters:
replacementPath- the path providing the new node geometry- Throws:
IllegalArgumentException- if replacementPath is null or empty
-
setSpacing
protected void setSpacing(ij.measure.Calibration cal) -
setSpacing
-
clone
Creates a deep copy of this Path.This method creates a complete copy of the path including all nodes, properties, and calibration settings. The cloned path will have the same spatial coordinates, node properties (radius, color, tangent), and metadata as the original, but will be completely independent. Parent-child relationships are not preserved in the clone to avoid infinite recursion and should be established separately if needed.
Fitted paths and legacy 3D viewer content are not cloned - the new path will need to be re-fitted and re-added to viewers if needed.
-
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.- Parameters:
includeImmediateChildren- if true, includes clones of immediate child paths; if false, returns a clone without children- Returns:
- a new Path that is a copy of this path, optionally including children
-
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.
- Returns:
- the List of child paths. May be empty if this path has no children, but never null.
- See Also:
-
getCalibration
public ij.measure.Calibration getCalibration()Gets the spatial calibration of this Path.- Returns:
- the calibration details associated with this Path
-
add
-
reverse
public void reverse()Reverses this path so that its starting node becomes the last and vice versa. -
reversed
- Returns:
- a reversed version of this path in which node coordinates are reversed. Note that for legacy reasons only the node coordinates are reversed. Other properties (node colors, etc.) are not included in the returned path
-
addNode
Appends a node to this Path.- Parameters:
point- the node to be inserted
-
addPointDouble
public void addPointDouble(double x, double y, double z) -
drawPathAsPoints
public void drawPathAsPoints(TracerCanvas canvas, Graphics2D g, Color c, int plane, boolean highContrast, boolean drawDiameter) -
drawPathAsPoints
protected void drawPathAsPoints(TracerCanvas canvas, Graphics2D g, Color c, int plane, boolean drawDiameter, int slice, int either_side) -
drawPathAsPoints
-
drawPathAsPoints
public void drawPathAsPoints(TracerCanvas canvas, Graphics2D g2, Color c, boolean highContrast, boolean drawDiameter, int slice, int either_side) -
setNodeColors
Sets the node colors.- Parameters:
colors- the colors used to render the nodes of this. If null (the default) all nodes are rendered using the Path color.
-
getNodeColors
Gets the node colors.- Returns:
- the colors used to render the nodes of this path, or null if nodes are rendered using the Path color
-
getNodeColor
Gets the node color.- Parameters:
pos- the node position- Returns:
- the node color, or null if no color nodes have been assigned to this path
-
setNodeColor
Sets the node color.- Parameters:
color- the node colorpos- the node position
-
setNodeColor
public void setNodeColor(org.scijava.util.ColorRGB color, int pos) Sets the node color.- Parameters:
color- the node colorpos- the node position
-
setNodeValue
public void setNodeValue(double value, int pos) Assigns the "value" property to this node.- Parameters:
value- the node valuepos- the node position- See Also:
-
setNodeAnnotation
Assigns an annotation to an existing node.- Parameters:
annotation- the node annotationpos- the node position
-
setNodeHemisphere
public void setNodeHemisphere(char hemisphereFlag, int pos) Assigns a hemisphere to an existing node.- Parameters:
hemisphereFlag- the node hemisphere flag.pos- the node position
-
getNodeValue
public double getNodeValue(int pos) Returns the "value" property of this node.- Parameters:
pos- the node position- Returns:
- the value property of this node
- See Also:
-
getNodeAnnotation
Returns the neuropil annotation associated with this node.- Parameters:
pos- the node position- Returns:
- the annotation of this node,
- See Also:
-
getNodeHemisphereFlag
public char getNodeHemisphereFlag(int pos) Returns the hemisphere flag associated with this node.- Parameters:
pos- the node position- Returns:
- the flag associated with this node, either
BrainAnnotation.LEFT_HEMISPHERE,BrainAnnotation.RIGHT_HEMISPHERE, orBrainAnnotation.ANY_HEMISPHERE - See Also:
-
setNodeValues
public void setNodeValues(double[] values) Sets the path "values", the array containing the numeric property assigned to path nodes, typically voxel intensities.- Parameters:
values- the new node values- See Also:
-
hasNodeValues
public boolean hasNodeValues()Assesses whether the nodes of this path have been assigned an array of values- Returns:
- true, if successful
- See Also:
-
hasNodeAnnotations
public boolean hasNodeAnnotations()Assesses whether the nodes of this path have been assignedBrainAnnotations.- Returns:
- true, if successful
- See Also:
-
hasNodeHemisphereFlags
public boolean hasNodeHemisphereFlags()Assesses whether the nodes of this path have been assigned hemisphere flags.- Returns:
- true, if successful
- See Also:
-
getColor
Gets the color of this Path- Returns:
- the color, or null if no color has been assigned to this Path
- See Also:
-
getColorRGB
public org.scijava.util.ColorRGB getColorRGB()Gets the color of this Path- Returns:
- the color, or null if no color has been assigned to this Path
- See Also:
-
setColor
Sets this path color.- Parameters:
color- the path color. Set it to null, to have SNT render this Path using default settings. You may need to cast the null reference toColorto avoid ambiguous method overload
-
setColor
public void setColor(org.scijava.util.ColorRGB color) Sets this path color.- Parameters:
color- the path color. Set it to null, to have SNT render this Path using default settings. You may need to cast the null reference toColorRGBto avoid ambiguous method overload
-
resetColor
public void resetColor()Resets this path color, forcing SNT to render it under default settings. -
hasCustomColor
public boolean hasCustomColor()Assesses whether a custom color has been assigned to this Path.- Returns:
- true, if successful
- See Also:
-
getSWCcolor
Gets the default SWC colors used by SNT.- Parameters:
swcType- the SEC type (e.g.,SWC_AXON,SWC_DENDRITE, etc.)- Returns:
- the SWC color
-
isFittedVersionOfAnotherPath
public boolean isFittedVersionOfAnotherPath()Checks if this Path is a fitted version of another path.- Returns:
- true, if it is a fitted version of another path
-
getUnfitted
Gets the original (unfitted) path that this path is a fitted version of.- Returns:
- the unfitted original, or
nullif this is not a fitted path - See Also:
-
setFitted
-
setUseFitted
Sets whether the fitted flavor of this Path should be used.- Parameters:
useFitted- the new use fitted- Throws:
IllegalArgumentException- if this Path has not been fitted
-
discardFit
protected void discardFit() -
getUseFitted
public boolean getUseFitted()Gets whether the fitted 'flavor' of this Path is in use.- Returns:
- true, if the fitted version of this Path is in use, otherwise false
-
getSpineOrVaricosityCount
public int getSpineOrVaricosityCount()Gets the number of spines or varicosities associated with this path.- Returns:
- the number of spines or varicosities. Returns 0 if no features have been annotated.
- See Also:
-
setSpineOrVaricosityCount
public void setSpineOrVaricosityCount(int newCount) Sets the number of spines or varicosities associated with this path.- Parameters:
newCount- the new count of spines or varicosities. Should be non-negative.- See Also:
-
getChannel
public int getChannel()Gets the hyperstack channel associated with this Path.- Returns:
- the channel position of this path (1-based index). Note that if the channel associated with a path is not known, it is assumed to be 1;
-
getFrame
public int getFrame()Gets the hyperstack frame position associated with this Path.- Returns:
- the frame position of this path (1-based index). Note that if the frame associated with a path is not known, it is assumed to be 1;
-
setCTposition
public void setCTposition(int channel, int frame) Sets the hyperstack position of this Path- Parameters:
channel- the channel (one-based index)frame- the frame (one-based index)
-
getFitted
Gets the fitted version ('flavor') of this Path.- Returns:
- the fitted version, or null if this Path has not been fitted
-
setGuessedTangents
public void setGuessedTangents(int pointsEitherSide) -
getTangent
public void getTangent(int i, int pointsEitherSide, double[] result) -
getSWCtypeNames
Gets the list of string representations of SWC types- Returns:
- the list of SWC type names
-
getSWCtypes
Gets the list of SWC types.- Returns:
- the list of SWC type flags
-
getSWCtypeName
Gets the SWC type label associated with the specified type flag. SNT follows the specification detailed at swc-specification.readthedocs.io- Parameters:
type- the SWC type flagcapitalized- whether output String should be capitalized- Returns:
- the respective label, or
SWC_UNDEFINED_LABELif flag was not recognized
-
getMeanRadius
public double getMeanRadius()Gets the path mean radius.- Returns:
- the average radius of the path, or zero if path has no defined thickness
- See Also:
-
getNodeRadius
public double getNodeRadius(int pos) Gets the radius of the specified node.- Parameters:
pos- the node position- Returns:
- the radius at the specified position, or zero if path has no defined thickness
-
setNodeRadius
public void setNodeRadius(double radius, int pos) Sets the radius of a specific node.- Parameters:
radius- the radius valuepos- the node position
-
hasRadii
public boolean hasRadii()Checks whether the nodes of this path have been assigned defined thickness.- Returns:
- true, if the points defining with this path are associated with a list of radii
-
hasNodeColors
public boolean hasNodeColors()Checks whether any nodes have custom colors assigned.- Returns:
- true if any nodes have custom colors
- See Also:
-
getNodeTangent
public double[] getNodeTangent(int pos) Gets the tangent vector of a specific node.- Parameters:
pos- the node position- Returns:
- the tangent vector [x, y, z] or null if not defined
-
setNodeTangent
public void setNodeTangent(double[] tangent, int pos) Sets the tangent vector of a specific node.- Parameters:
tangent- the tangent vector [x, y, z]pos- the node position
-
setNodeTangent
public void setNodeTangent(double tx, double ty, double tz, int pos) Sets the tangent vector of a specific node.- Parameters:
tx- the X component of the tangentty- the Y component of the tangenttz- the Z component of the tangentpos- the node position
-
hasTangents
public boolean hasTangents()Checks whether any nodes have tangent vectors defined.- Returns:
- true if any nodes have tangents
-
firstNode
Returns the first node of this path.- Returns:
- the root node, or null if path is empty
-
lastNode
Returns the last node of this path.- Returns:
- the terminal node, or null if path is empty
-
contains
Checks if this path contains the specified point within the given tolerance.- Parameters:
point- the point to checktolerance- the distance tolerance- Returns:
- true if the path contains the point within tolerance
-
getInterpolatedPath
Returns a new Path in which nodes have been interpolated to ensure that the distance between consecutive nodes does not exceed the specified threshold.- Parameters:
maxDistance- the maximum distance allowed between consecutive nodes- Returns:
- the interpolated path
-
getResampledPath
Returns a new Path in which nodes have been resampled to ensure uniform spacing along the path.- Parameters:
targetSpacing- the desired spacing between consecutive nodes- Returns:
- the resampled path
-
getSmoothedPath
Returns a smoothed version of this path using a simple moving average filter.- Parameters:
windowSize- the size of the smoothing window (must be odd and >= 3)- Returns:
- the smoothed path
-
interpolateMissingRadii
@Deprecated public Map<Integer,Double> interpolateMissingRadii(DoublePredicate predicate, boolean apply) Deprecated.UsesanitizeRadii(DoublePredicate, boolean)instead -
sanitizeRadii
Sanitizes node radii by interpolating invalid values (zero, NaN, or negative).Convenience method equivalent to calling
sanitizeRadii((r) -> r <= 0 || Double.isNaN(r), apply).- Parameters:
apply- iftrue, corrected values are immediately applied- Returns:
- map of corrected
(node index, radius)pairs, ornullif path has no radii or fewer than 2 nodes - See Also:
-
sanitizeRadii
Sanitizes node radii by interpolating values that match the given predicate.Collects nodes with invalid radii (as defined by predicate) and assigns new values using linear interpolation based on remaining valid nodes. Interpolated values are clamped to the observed range of valid radii to prevent extrapolation artifacts.
If fewer than two valid radii exist, interpolation is not possible and an empty map is returned. For automatic fallback handling, use
sanitizeRadii(double, double, boolean)instead.- Parameters:
predicate- function returningtruefor invalid radiiapply- iftrue, corrected values are immediately applied- Returns:
- map of corrected
(node index, radius)pairs, ornullif path has no radii or fewer than 2 nodes. Empty map if no invalid radii found or interpolation not possible. - See Also:
-
sanitizeRadii
Sanitizes node radii by enforcing bounds and interpolating outliers.Identifies nodes with radii outside
If fewer than two nodes have valid radii, a context-appropriate fallback is used:[minRadius, maxRadius]and assigns new values using linear interpolation based on remaining valid nodes. Interpolated values are clamped to the specified range to prevent extrapolation artifacts.- All radii above range →
maxRadius - All radii below range →
minRadius - Mixed or NaN values → midpoint of range
- Parameters:
minRadius- minimum valid radius (inclusive)maxRadius- maximum valid radius (inclusive)apply- iftrue, corrected values are immediately applied- Returns:
- map of corrected
(node index, radius)pairs, ornullif path has no radii or fewer than 2 nodes. Empty map if all radii are already within range. - Throws:
IllegalArgumentException- if bounds are negative orminRadius > maxRadius- See Also:
- All radii above range →
-
setFittedCircles
protected void setFittedCircles(int nPoints, double[] tangents_x, double[] tangents_y, double[] tangents_z, double[] radii, double[] optimized_x, double[] optimized_y, double[] optimized_z) -
toString
This toString() method shows details of the path which is actually being displayed, not necessarily this path object. -
setSWCType
public void setSWCType(int newSWCType) Sets the SWC type.- Parameters:
newSWCType- the new SWC type
-
setSWCType
protected void setSWCType(int newSWCType, boolean alsoSetInFittedVersion) -
getSWCType
public int getSWCType()Gets the SWC type.- Returns:
- the SWC type
-
getOrder
public int getOrder()Gets the "bifurcation" (branching) order of this Path. If registered in the GUI, this would correspond to the level of this Path inPathManagerUI's JTree: E.g., a Path connected to a primary Path (order 1) will be assigned order 2, etc. N.B.: Albeit related to reverse Horton-Strahler classification, Path ordering is formally distinct, as it classifies Paths instead of branches.- Returns:
- the order of this path. A primary path is always of order 1.
- See Also:
-
setOrder
public void setOrder(int order) -
removeFrom3DViewer
Deprecated.This method is deprecated. Use newer 3D visualization methods instead.Removes this path from the specified 3D viewer universe.- Parameters:
univ- the Image3DUniverse from which to remove this path's 3D representation. Must not be null.
-
getPoint3fList
Deprecated. -
addAsLinesTo3DViewer
@Deprecated public ij3d.Content addAsLinesTo3DViewer(ij3d.Image3DUniverse univ, Color c, ij.ImagePlus colorImage) Deprecated. -
addAsLinesTo3DViewer
@Deprecated protected ij3d.Content addAsLinesTo3DViewer(ij3d.Image3DUniverse univ, org.jogamp.vecmath.Color3f c, ij.ImagePlus colorImage) Deprecated. -
addDiscsTo3DViewer
@Deprecated public ij3d.Content addDiscsTo3DViewer(ij3d.Image3DUniverse univ, Color c, ij.ImagePlus colorImage) Deprecated. -
addDiscsTo3DViewer
@Deprecated public ij3d.Content addDiscsTo3DViewer(ij3d.Image3DUniverse univ, org.jogamp.vecmath.Color3f c, ij.ImagePlus colorImage) Deprecated. -
addTo3DViewer
Deprecated.This method is deprecated. Use newer 3D visualization methods instead.Adds this path to the specified 3D viewer universe with the given color.- Parameters:
univ- the Image3DUniverse to add this path toc- the color to use for rendering this pathcolorImage- the color image for texture mapping (can be null)
-
addTo3DViewer
@Deprecated public void addTo3DViewer(ij3d.Image3DUniverse univ, org.jogamp.vecmath.Color3f c, ij.ImagePlus colorImage) Deprecated.This method is deprecated. Use newer 3D visualization methods instead.Adds this path to the specified 3D viewer universe with the given Color3f.- Parameters:
univ- the Image3DUniverse to add this path toc- the Color3f to use for rendering this path. Must not be null.colorImage- the color image for texture mapping (can be null)
-
setSelected
public void setSelected(boolean newSelectedStatus) -
isSelected
public boolean isSelected() -
isActiveVersion
public boolean isActiveVersion()Checks if this version of the path is currently being used for display/analysis.- Returns:
- true if this version is active, false otherwise
-
versionInUse
Deprecated.UseisActiveVersion()instead -
getApproximatedVolume
public double 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.
- Returns:
- the approximate fitted volume (in physical units), or NaN if this Path has no radii
- See Also:
-
getApproximatedSurface
public double getApproximatedSurface()Returns an estimated surface area of this path, treating each inter-node segment as a frustum.- Returns:
- the approximate surface area (in physical units), or 0 if this Path has no radii
- See Also:
-
transform
-
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.- Returns:
- the list of nodes as
PointInImageobjects - See Also:
-
getBranchPoints
This is a version offindJunctions()ensuring that a junction node is only retrieved once even if multiple child paths are associated with it.- Returns:
- the junction nodes
- See Also:
-
getJunctionNodes
Deprecated.usegetBranchPoints()instead -
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.- Returns:
- the indices of junction nodes, naturally sorted
- See Also:
-
downsample
public void downsample(double internodeSpacing) 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.
- Parameters:
internodeSpacing- the target spacing between nodes after downsampling. This parameter controls the aggressiveness of the downsampling - smaller values preserve more detail, larger values result in more aggressive simplification. Must be greater than zero.- Throws:
IllegalArgumentException- if internodeSpacing is less than or equal to zero- See Also:
-
upsample
public void upsample(double internodeSpacing) Upsamples this path by spacing nodes at a specified distance.The original nodes are preserved and additional interpolated nodes are placed at regular intervals between them. The spacing between adjacent nodes will thus be approximately equal to the specified distance. If the distance between two adjacent original nodes is less than the specified pacing, no additional nodes are added between them.
NB:Some assigned properties (node colors, node values, etc.) will be lost.
Thread Safety: This method is synchronized to prevent concurrent modification of the path structure during the upsampling operation.
- Parameters:
internodeSpacing- the desired distance between adjacent nodes- Throws:
IllegalArgumentException- if spacing is less than or equal to zero
-
setRadius
public void setRadius(double r) Assigns a fixed radius to all the nodes of this Path- Parameters:
r- the radius to be assigned. Setting it to 0 or Double.NaN removes the radius attribute from the Path
-
setRadius
public void setRadius(double r, int index) Assigns a radius to a specific node of this Path.Sets the radius for the node at the specified index. If this is the first radius being set for the path and no tangents exist, this method will also compute guessed tangents to support proper 3D rendering.
- Parameters:
r- the radius to be assigned to the node. NaN values are ignored.index- the 0-based index of the node to modify- Throws:
IndexOutOfBoundsException- if index is out of range- See Also:
-
setRadii
public void setRadii(double[] radii) Assigns radii to this Path- Parameters:
radii- the radii array. Setting it null removes the radius attribute from the Path- See Also:
-
fitRadii
public boolean fitRadii(ij.ImagePlus imp) Fits radii to this Path by fitting circular cross-sections to the image signal. This is the scripting equivalent of the UI's "Fit Path" action. Node positions are not modified; only radii and tangent vectors are computed.- Parameters:
imp- the image containing the signal to fit against- Returns:
- true if the fit succeeded
- Throws:
IllegalArgumentException- if this path is already a fitted version of another path, or if the image is null- See Also:
-
isConnectedTo
-
addChangeListener
protected void addChangeListener(sc.fiji.snt.PathChangeListener listener) -
removeChangeListener
protected boolean removeChangeListener(sc.fiji.snt.PathChangeListener listener)
-
DEFAULT_SAMPLING_INTERVALinstead