Package sc.fiji.snt.analysis
Class PCAnalyzer
java.lang.Object
sc.fiji.snt.analysis.PCAnalyzer
Utility class for performing Principal Component Analysis (PCA) on various
SNT data structures including Trees, Paths, and collections of SNTPoints.
This class provides methods to compute the principal axes of 3D point data, which represent the directions of maximum variance in the data. This is useful for analyzing the overall orientation and shape characteristics of neuronal structures, meshes, and other 3D geometries.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents a principal axis containing the direction vector and associated variance (eigenvalue) from Principal Component Analysis. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic PCAnalyzer.PrincipalAxis[]getPrincipalAxes(Collection<? extends SNTPoint> points) Computes the principal axes for a collection of SNTPoints.static PCAnalyzer.PrincipalAxis[]getPrincipalAxes(net.imagej.mesh.Vertices vertices) Computes the principal axes from the vertices of a meshstatic PCAnalyzer.PrincipalAxis[]getPrincipalAxes(Path path) Computes the principal axes for a Path structure.static PCAnalyzer.PrincipalAxis[]getPrincipalAxes(Tree tree) Computes the principal axes for a Tree structure.static PCAnalyzer.PrincipalAxis[]getPrincipalAxes(Tree tree, boolean excludeRoot) Computes the principal axes for a Tree structure with option to exclude root.static double[]Computes the variance percentages for an array of principal axes.static PCAnalyzer.PrincipalAxis[]orientTowardDirection(PCAnalyzer.PrincipalAxis[] axes, double[] referenceDirection) Orients principal axes so the primary axis points toward a reference direction, i.e., the primary axis is oriented to minimize the angle with the reference direction.static PCAnalyzer.PrincipalAxis[]orientTowardTips(PCAnalyzer.PrincipalAxis[] axes, Tree tree) Convenience method to orient existing principal axes toward a tree's tips centroid.
-
Constructor Details
-
PCAnalyzer
public PCAnalyzer()
-
-
Method Details
-
getPrincipalAxes
Computes the principal axes for a Tree structure.- Parameters:
tree- the Tree to analyze- Returns:
- array of three PrincipalAxis objects ordered by decreasing variance (primary, secondary, tertiary), or null if computation fails
-
getPrincipalAxes
Computes the principal axes for a Tree structure with option to exclude root.- Parameters:
tree- the Tree to analyzeexcludeRoot- if true, excludes the root node from the analysis- Returns:
- array of three PrincipalAxis objects ordered by decreasing variance (primary, secondary, tertiary), or null if computation fails
-
getPrincipalAxes
Computes the principal axes for a Path structure.- Parameters:
path- the Path to analyze- Returns:
- array of three PrincipalAxis objects ordered by decreasing variance (primary, secondary, tertiary), or null if computation fails
-
getPrincipalAxes
Computes the principal axes from the vertices of a mesh- Parameters:
vertices- the collection of vertices to analyze- Returns:
- array of three PrincipalAxis objects ordered by decreasing variance (primary, secondary, tertiary), or null if computation fails
-
getPrincipalAxes
Computes the principal axes for a collection of SNTPoints.- Parameters:
points- the collection of points to analyze- Returns:
- array of three PrincipalAxis objects ordered by decreasing variance (primary, secondary, tertiary), or null if computation fails
-
getVariancePercentages
Computes the variance percentages for an array of principal axes. This is a convenience method that returns the percentage of total variance explained by each principal axis.- Parameters:
axes- the array of three PrincipalAxis objects (primary, secondary, tertiary)- Returns:
- array of three percentages (primary, secondary, tertiary) that sum to 100%, or null if axes is null
-
orientTowardTips
public static PCAnalyzer.PrincipalAxis[] orientTowardTips(PCAnalyzer.PrincipalAxis[] axes, Tree tree) Convenience method to orient existing principal axes toward a tree's tips centroid. For several topologies, this orients the primary axis is so it aligns with the general growth direction of the arbor.- Parameters:
axes- the principal axes to orienttree- the tree to get tips centroid from (orientation reference)- Returns:
- oriented principal axes
-
orientTowardDirection
public static PCAnalyzer.PrincipalAxis[] orientTowardDirection(PCAnalyzer.PrincipalAxis[] axes, double[] referenceDirection) Orients principal axes so the primary axis points toward a reference direction, i.e., the primary axis is oriented to minimize the angle with the reference direction. If the primary axis points away from the reference (dot product < 0), it's flipped.\- Parameters:
axes- the principal axes to orientreferenceDirection- the reference direction vector [x, y, z]- Returns:
- oriented principal axes
-