public class Path extends java.lang.Object implements java.lang.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 unfitted version
Modifier and Type | Field and Description |
---|---|
static int |
SWC_APICAL_DENDRITE
Flag specifying the SWC type 'apical dendrite'.
|
static java.lang.String |
SWC_APICAL_DENDRITE_LABEL
String representation of
SWC_APICAL_DENDRITE |
static int |
SWC_AXON
Flag specifying the SWC type 'axon'.
|
static java.lang.String |
SWC_AXON_LABEL
String representation of
SWC_AXON |
static int |
SWC_CUSTOM
Flag specifying the SWC type 'custom'.
|
static java.lang.String |
SWC_CUSTOM_LABEL
String representation of
SWC_CUSTOM |
static int |
SWC_DENDRITE
Flag specifying the SWC type '(basal) dendrite'.
|
static java.lang.String |
SWC_DENDRITE_LABEL
String representation of
SWC_DENDRITE |
static int |
SWC_END_POINT
Deprecated.
|
static java.lang.String |
SWC_END_POINT_LABEL
String representation of
SWC_END_POINT |
static int |
SWC_FORK_POINT
Deprecated.
|
static java.lang.String |
SWC_FORK_POINT_LABEL
String representation of
SWC_FORK_POINT |
static int |
SWC_SOMA
Flag specifying the SWC type 'soma'.
|
static java.lang.String |
SWC_SOMA_LABEL
String representation of
SWC_SOMA |
static int |
SWC_UNDEFINED
Flag specifying the SWC type 'undefined'.
|
static java.lang.String |
SWC_UNDEFINED_LABEL
String representation of
SWC_UNDEFINED |
Constructor and Description |
---|
Path(double x_spacing,
double y_spacing,
double z_spacing,
java.lang.String spacing_units)
Instantiates a new path.
|
Modifier and Type | Method and Description |
---|---|
ij3d.Content |
addAsLinesTo3DViewer(ij3d.Image3DUniverse univ,
java.awt.Color c,
ij.ImagePlus colorImage)
Deprecated.
|
ij3d.Content |
addDiscsTo3DViewer(ij3d.Image3DUniverse univ,
org.scijava.vecmath.Color3f c,
ij.ImagePlus colorImage)
Deprecated.
|
ij3d.Content |
addDiscsTo3DViewer(ij3d.Image3DUniverse univ,
java.awt.Color c,
ij.ImagePlus colorImage)
Deprecated.
|
void |
addNode(PointInImage point)
Appends a node to this Path.
|
void |
addTo3DViewer(ij3d.Image3DUniverse univ,
org.scijava.vecmath.Color3f c,
ij.ImagePlus colorImage)
Deprecated.
|
void |
addTo3DViewer(ij3d.Image3DUniverse univ,
java.awt.Color c,
ij.ImagePlus colorImage)
Deprecated.
|
Path |
clone() |
int |
compareTo(Path o) |
boolean |
contains(PointInImage pim)
Check whether this Path contains the specified point
|
void |
downsample(double maximumAllowedDeviation) |
void |
drawPathAsPoints(sc.fiji.snt.TracerCanvas canvas,
java.awt.Graphics2D g,
java.awt.Color c,
int plane,
boolean highContrast,
boolean drawDiameter) |
void |
drawPathAsPoints(sc.fiji.snt.TracerCanvas canvas,
java.awt.Graphics2D g2,
java.awt.Color c,
int plane,
boolean highContrast,
boolean drawDiameter,
int slice,
int either_side) |
java.util.TreeSet<java.lang.Integer> |
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.
|
java.util.List<PointInImage> |
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.
|
double |
getApproximatedVolume()
Returns an estimated volume of this path.
|
ij.measure.Calibration |
getCalibration()
Gets the spatial calibration of this Path.
|
PointInCanvas |
getCanvasOffset()
Returns the translation offset used to render this Path in a
TracerCanvas . |
int |
getChannel()
Gets the hyperstack channel associated with this Path.
|
java.awt.Color |
getColor()
Gets the color of this Path
|
org.scijava.util.ColorRGB |
getColorRGB()
Gets the color of this Path
|
int |
getEditableNodeIndex()
Gets the position of the node tagged as 'editable', if any.
|
Path |
getEndJoins() |
PointInImage |
getEndJoinsPoint() |
Path |
getFitted()
Gets the fitted version ('flavor') of this Path.
|
int |
getFrame()
Gets the hyperstack frame position associated with this Path.
|
int |
getID()
Gets the identifier of this Path
|
double |
getLength()
Gets the length of this Path
|
double |
getMeanRadius()
Gets the path mean radius.
|
java.lang.String |
getName()
Gets this Path's name.
|
PointInImage |
getNode(int pos)
Gets the node at the specified position.
|
BrainAnnotation |
getNodeAnnotation(int pos)
Returns the neuropil annotation associated with this node.
|
java.awt.Color |
getNodeColor(int pos)
Gets the node color.
|
java.awt.Color[] |
getNodeColors()
Gets the node colors.
|
int |
getNodeIndex(PointInImage pim)
Gets the first node index associated with the specified image coordinates.
|
double |
getNodeRadius(int pos)
Gets the radius of the specified node.
|
double |
getNodeValue(int pos)
Returns the "value" property of this node.
|
int |
getOrder()
Gets the branching order of this Path
|
java.util.List<org.scijava.vecmath.Point3f> |
getPoint3fList() |
Path |
getSection(int startIndex,
int endIndex)
Gets a section between two nodes of this Path.
|
Path |
getStartJoins() |
PointInImage |
getStartJoinsPoint() |
static java.awt.Color |
getSWCcolor(int swcType)
Gets the default SWC colors used by SNT.
|
int |
getSWCType()
Gets the SWC type.
|
static java.lang.String |
getSWCtypeName(int type,
boolean capitalized)
Gets the SWC type label associated with the specified type flag.
|
static java.util.ArrayList<java.lang.String> |
getSWCtypeNames()
Gets the list of string representations of non-redundant SWC types (i.e.,
excluding
SWC_FORK_POINT_LABEL , and
SWC_FORK_POINT_LABEL |
static java.util.ArrayList<java.lang.Integer> |
getSWCtypes()
Gets the list of non-redundant SWC types (i.e., excluding the redundant
types
SWC_FORK_POINT_LABEL , and
SWC_FORK_POINT_LABEL |
boolean |
getUseFitted()
Gets whether the fitted 'flavor' of this Path is in use.
|
int |
getXUnscaled(int i) |
double |
getXUnscaledDouble(int i) |
int |
getYUnscaled(int i) |
double |
getYUnscaledDouble(int i) |
int |
getZUnscaled(int i) |
double |
getZUnscaledDouble(int i) |
boolean |
hasCustomColor()
Assesses whether a custom color has been assigned to this Path, or its
nodes have been assigned an array of colors
|
boolean |
hasNodeAnnotations()
Assesses whether the nodes of this path have been assigned an array of
annotations
|
boolean |
hasNodeColors()
Assesses whether the nodes of this path have been assigned an array of
colors
|
boolean |
hasNodeValues()
Assesses whether the nodes of this path have been assigned an array of
values
|
boolean |
hasRadii()
Checks whether the nodes of this path have been assigned defined thickness.
|
int |
indexNearestTo(double x,
double y,
double z,
double within)
Gets the index of the closest node associated with the specified world
coordinates.
|
void |
insertNode(int index,
PointInImage point)
Inserts a node at a specified position.
|
boolean |
isFittedVersionOfAnotherPath()
Checks if this Path is a fitted version of another path.
|
boolean |
isPrimary()
Checks if this Path is root.
|
boolean |
isSelected() |
void |
moveNode(int index,
PointInImage destination)
Assigns a new location to the specified node.
|
PointInImage |
nearestNodeTo(PointInImage node,
double within)
Gets the closest node associated with the specified node.
|
java.lang.String |
realToString() |
void |
removeFrom3DViewer(ij3d.Image3DUniverse univ) |
void |
removeNode(int index)
Removes the specified node if this path has at least two nodes.
|
void |
setCanvasOffset(PointInCanvas canvasOffset)
Specifies a translation offset when rendering this Path in a
TracerCanvas . |
void |
setColor(java.awt.Color color)
Sets this path color.
|
void |
setColorRGB(org.scijava.util.ColorRGB colorRGB)
Sets this path color.
|
void |
setCTposition(int channel,
int frame)
Sets the hyperstack position of this Path
|
void |
setEditableNode(int index)
Tags the specified point position as 'editable'.
|
void |
setEndJoin(Path other,
PointInImage joinPoint) |
void |
setName(java.lang.String newName)
Sets this Path's name.
|
void |
setNodeAnnotation(BrainAnnotation annotation,
int pos)
Assigns an annotation to an existing node.
|
void |
setNodeColor(java.awt.Color color,
int pos)
Sets the node color.
|
void |
setNodeColors(java.awt.Color[] colors)
Sets the node colors.
|
void |
setNodeValue(double value,
int pos)
Assigns the "value" property to this node.
|
void |
setNodeValues(double[] values)
Sets the path "values", the array containing the numeric property assigned
to path nodes, typically voxel intensities.
|
void |
setRadii(double[] radii)
Assigns radii to this Path
|
void |
setRadius(double r)
Assigns a fixed radius to all the nodes of this Path
|
void |
setSelected(boolean newSelectedStatus) |
void |
setStartJoin(Path other,
PointInImage joinPoint) |
void |
setSWCType(int newSWCType)
Sets the SWC type.
|
void |
setUseFitted(boolean useFitted)
Sets whether the fitted flavor of this Path should be used.
|
int |
size()
Returns the number of nodes of this path
|
java.lang.String |
toString()
This toString() method shows details of the path which is actually being
displayed, not necessarily this path object.
|
Path |
transform(PathTransformer transformation,
ij.ImagePlus template,
ij.ImagePlus model) |
void |
unsetEndJoin() |
void |
unsetStartJoin() |
boolean |
versionInUse() |
public static final int SWC_UNDEFINED
public static final int SWC_SOMA
public static final int SWC_AXON
public static final int SWC_DENDRITE
public static final int SWC_APICAL_DENDRITE
@Deprecated public static final int SWC_FORK_POINT
@Deprecated public static final int SWC_END_POINT
public static final int SWC_CUSTOM
public static final java.lang.String SWC_UNDEFINED_LABEL
SWC_UNDEFINED
public static final java.lang.String SWC_SOMA_LABEL
SWC_SOMA
public static final java.lang.String SWC_AXON_LABEL
SWC_AXON
public static final java.lang.String SWC_DENDRITE_LABEL
SWC_DENDRITE
public static final java.lang.String SWC_APICAL_DENDRITE_LABEL
SWC_APICAL_DENDRITE
public static final java.lang.String SWC_FORK_POINT_LABEL
SWC_FORK_POINT
public static final java.lang.String SWC_END_POINT_LABEL
SWC_END_POINT
public static final java.lang.String SWC_CUSTOM_LABEL
SWC_CUSTOM
public Path(double x_spacing, double y_spacing, double z_spacing, java.lang.String spacing_units)
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").public int compareTo(Path o)
compareTo
in interface java.lang.Comparable<Path>
public int getID()
public void setCanvasOffset(PointInCanvas canvasOffset)
TracerCanvas
. Path coordinates remain unaltered.canvasOffset
- the x,y,z coordinates (pixel-based) specifying the
translation offsetpublic PointInCanvas getCanvasOffset()
TracerCanvas
.public Path getStartJoins()
public PointInImage getStartJoinsPoint()
public Path getEndJoins()
public PointInImage getEndJoinsPoint()
public void setName(java.lang.String newName)
""
, to reset it to the
default.newName
- the new name.getName()
public java.lang.String getName()
setName(String)
public double getLength()
public boolean isPrimary()
public void setStartJoin(Path other, PointInImage joinPoint)
public void setEndJoin(Path other, PointInImage joinPoint)
public void unsetStartJoin()
public void unsetEndJoin()
public int size()
public PointInImage getNode(int pos) throws java.lang.IndexOutOfBoundsException
pos
- the position index (0-based)java.lang.IndexOutOfBoundsException
- if position is out-of-rangepublic boolean contains(PointInImage pim)
pim
- the PointInImage
nodepublic void insertNode(int index, PointInImage point)
index
- the (zero-based) index of the position of the new nodepoint
- the node to be insertedjava.lang.IllegalArgumentException
- if index is out-of-rangepublic void removeNode(int index)
index
- the zero-based index of the node to be removedjava.lang.IllegalArgumentException
- if index is out-of-rangepublic void moveNode(int index, PointInImage destination)
index
- the zero-based index of the node to be modifieddestination
- the new node locationjava.lang.IllegalArgumentException
- if index is out-of-rangepublic int getNodeIndex(PointInImage pim)
pim
- the image position (calibrated coordinates)public PointInImage nearestNodeTo(PointInImage node, double within)
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.public int indexNearestTo(double x, double y, double z, double within)
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.public int getEditableNodeIndex()
public void setEditableNode(int index)
index
- the index of the point to be tagged. Set it to -1 to for no
taggingpublic int getXUnscaled(int i)
public int getYUnscaled(int i)
public int getZUnscaled(int i)
public double getXUnscaledDouble(int i)
public double getYUnscaledDouble(int i)
public double getZUnscaledDouble(int i)
public Path getSection(int startIndex, int endIndex)
startIndex
- the node index defining the first node of the sectionendIndex
- the node index defining the last node of the sectionpublic Path clone()
clone
in class java.lang.Object
public ij.measure.Calibration getCalibration()
public void addNode(PointInImage point)
point
- the node to be insertedpublic void drawPathAsPoints(sc.fiji.snt.TracerCanvas canvas, java.awt.Graphics2D g, java.awt.Color c, int plane, boolean highContrast, boolean drawDiameter)
public void drawPathAsPoints(sc.fiji.snt.TracerCanvas canvas, java.awt.Graphics2D g2, java.awt.Color c, int plane, boolean highContrast, boolean drawDiameter, int slice, int either_side)
public void setNodeColors(java.awt.Color[] colors)
colors
- the colors used to render the nodes of this. If null (the
default) all nodes are rendered using the Path color.public java.awt.Color[] getNodeColors()
public java.awt.Color getNodeColor(int pos)
pos
- the node positionpublic void setNodeColor(java.awt.Color color, int pos)
color
- the node colorpos
- the node positionpublic void setNodeValue(double value, int pos)
value
- the node valuepos
- the node positionPathProfiler.assignValues()
public void setNodeAnnotation(BrainAnnotation annotation, int pos)
annotation
- the node annotationpos
- the node positionpublic double getNodeValue(int pos)
pos
- the node positionPathProfiler.assignValues()
,
PointInImage.v
public BrainAnnotation getNodeAnnotation(int pos)
pos
- the node positionPointInImage.getAnnotation()
public void setNodeValues(double[] values)
values
- the new node valuesPointInImage.v
,
PathProfiler.assignValues()
public boolean hasNodeValues()
PointInImage.v
,
PathProfiler.assignValues()
public boolean hasNodeAnnotations()
PointInImage.getAnnotation()
public java.awt.Color getColor()
hasCustomColor
,
hasNodeColors()
public org.scijava.util.ColorRGB getColorRGB()
hasCustomColor
,
hasNodeColors()
public void setColor(java.awt.Color color)
color
- the path color. Set it to null, to have SNT rendered using
default settings.public void setColorRGB(org.scijava.util.ColorRGB colorRGB)
colorRGB
- the path color. Set it to null, to have SNT rendered using
default settings.public boolean hasCustomColor()
hasNodeColors()
public boolean hasNodeColors()
getNodeColors()
public static java.awt.Color getSWCcolor(int swcType)
swcType
- the SEC type (e.g., SWC_AXON
,
SWC_DENDRITE
, etc.)public boolean isFittedVersionOfAnotherPath()
public void setUseFitted(boolean useFitted) throws java.lang.IllegalArgumentException
useFitted
- the new use fittedjava.lang.IllegalArgumentException
- if this Path has not been fittedpublic boolean getUseFitted()
public int getChannel()
public int getFrame()
public void setCTposition(int channel, int frame)
channel
- the channel (one-based index)frame
- the frame (one-based index)public Path getFitted()
public static java.util.ArrayList<java.lang.String> getSWCtypeNames()
SWC_FORK_POINT_LABEL
, and
SWC_FORK_POINT_LABEL
public static java.util.ArrayList<java.lang.Integer> getSWCtypes()
SWC_FORK_POINT_LABEL
, and
SWC_FORK_POINT_LABEL
public static java.lang.String getSWCtypeName(int type, boolean capitalized)
type
- the SWC type flagcapitalized
- whether output String should be capitalizedSWC_UNDEFINED_LABEL
if flag
was not recognizedpublic double getMeanRadius()
hasRadii()
public double getNodeRadius(int pos)
pos
- the node positionpublic boolean hasRadii()
public java.lang.String realToString()
public java.lang.String toString()
toString
in class java.lang.Object
public void setSWCType(int newSWCType)
newSWCType
- the new SWC typepublic int getSWCType()
public int getOrder()
public void removeFrom3DViewer(ij3d.Image3DUniverse univ)
public java.util.List<org.scijava.vecmath.Point3f> getPoint3fList()
@Deprecated public ij3d.Content addAsLinesTo3DViewer(ij3d.Image3DUniverse univ, java.awt.Color c, ij.ImagePlus colorImage)
@Deprecated public ij3d.Content addDiscsTo3DViewer(ij3d.Image3DUniverse univ, java.awt.Color c, ij.ImagePlus colorImage)
@Deprecated public ij3d.Content addDiscsTo3DViewer(ij3d.Image3DUniverse univ, org.scijava.vecmath.Color3f c, ij.ImagePlus colorImage)
@Deprecated public void addTo3DViewer(ij3d.Image3DUniverse univ, java.awt.Color c, ij.ImagePlus colorImage)
@Deprecated public void addTo3DViewer(ij3d.Image3DUniverse univ, org.scijava.vecmath.Color3f c, ij.ImagePlus colorImage)
public void setSelected(boolean newSelectedStatus)
public boolean isSelected()
public boolean versionInUse()
public double getApproximatedVolume()
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.
hasRadii()
public Path transform(PathTransformer transformation, ij.ImagePlus template, ij.ImagePlus model)
public java.util.List<PointInImage> findJunctions()
PointInImage
objectsfindJunctionIndices()
public java.util.TreeSet<java.lang.Integer> findJunctionIndices()
findJunctions()
public void downsample(double maximumAllowedDeviation)
public void setRadius(double r)
r
- the radius to be assigned. Setting it to 0 or Double.NaN removes
the radius attribute from the Pathpublic void setRadii(double[] radii)
radii
- the radii array. Setting it null removes the radius attribute
from the PathsetRadius(double)