Class PathStatistics

java.lang.Object
org.scijava.AbstractContextual
org.scijava.command.ContextCommand
sc.fiji.snt.analysis.TreeStatistics
sc.fiji.snt.analysis.PathStatistics
All Implemented Interfaces:
Runnable, org.scijava.Cancelable, org.scijava.command.Command, org.scijava.Contextual, org.scijava.plugin.SciJavaPlugin

public class PathStatistics extends TreeStatistics
A specialized version of TreeStatistics for analyzing individual paths without considering their connectivity relationships.

PathStatistics provides morphometric analysis of neuronal paths while treating each path as an independent entity, rather than as part of a connected tree structure.

Key differences from TreeStatistics:
  • No graph conversion - paths are analyzed independently
  • Branch-related metrics are redefined to work with individual paths
  • Supports path-specific measurements like Path ID and number of children
  • Provides individual path measurement capabilities
Example usage:
 // Analyze a single path
 PathStatistics stats = new PathStatistics(path);
 double length = stats.getMetric("Path length").doubleValue();
 
 // Analyze multiple paths independently
 Collection<Path> paths = getPaths();
 PathStatistics multiStats = new PathStatistics(paths, "My Analysis");
 multiStats.measureIndividualPaths(Arrays.asList("Path length", "N. nodes"), true);
 
Author:
Tiago Ferreira
See Also:
  • Field Details

  • Constructor Details

    • PathStatistics

      public PathStatistics(Collection<Path> paths, String label)
      Instantiates PathStatistics from a collection of paths.

      Creates a PathStatistics instance for analyzing a collection of Path objects. The spatial unit is automatically determined from the paths if they all share the same calibration unit.

      Parameters:
      paths - the collection of paths to be analyzed
      label - the label describing the path collection
    • PathStatistics

      public PathStatistics(Path path)
      Instantiates PathStatistics from a single path.

      Creates a PathStatistics instance for analyzing a single Path object. The path's name is used as the label for the analysis.

      Parameters:
      path - the path to be analyzed
  • Method Details

    • getBranches

      public List<Path> getBranches()
      Gets all the paths being analyzed as branches.

      In PathStatistics, all paths are considered as branches since each path represents a distinct structural element.

      Overrides:
      getBranches in class TreeStatistics
      Returns:
      the list of all paths
      See Also:
    • getNBranches

      public int getNBranches()
      Gets the number of branches (paths) being analyzed.

      Returns the total count of paths in this PathStatistics instance.

      Overrides:
      getNBranches in class TreeStatistics
      Returns:
      the number of paths
    • getMetric

      public Number getMetric(String metric) throws UnknownMetricException
      Gets a summary metric for the analyzed paths.

      Extends the parent class functionality to support path-specific metrics such as "Path ID". For single-path analyses, returns the specific path ID; for multi-path analyses, returns NaN for path-specific metrics.

      Overrides:
      getMetric in class TreeStatistics
      Parameters:
      metric - the name of the metric to retrieve
      Returns:
      the metric value, or NaN if not applicable
      Throws:
      UnknownMetricException - if the metric is not recognized
      See Also:
    • getPrimaryBranches

      public List<Path> getPrimaryBranches()
      Gets the primary branches from the analyzed paths.

      Returns only those paths that are marked as primary branches, typically those that originate directly from the root or soma.

      Overrides:
      getPrimaryBranches in class TreeStatistics
      Returns:
      the list of primary paths
      See Also:
    • getTerminalBranches

      public List<Path> getTerminalBranches()
      Gets the terminal branches from the analyzed paths.

      Returns paths that have children, representing non-terminal segments. Note: This implementation differs from typical terminal branch definition as it returns paths with children rather than leaf paths.

      Overrides:
      getTerminalBranches in class TreeStatistics
      Returns:
      the list of paths with children
      See Also:
    • getPrimaryLength

      public double getPrimaryLength()
      Gets the total length of primary branches.

      Calculates the sum of lengths of all paths marked as primary branches.

      Overrides:
      getPrimaryLength in class TreeStatistics
      Returns:
      the total length of primary branches
      See Also:
    • getTerminalLength

      public double getTerminalLength()
      Gets the total length of terminal branches.

      Calculates the sum of lengths of all terminal branches as defined by getTerminalBranches().

      Overrides:
      getTerminalLength in class TreeStatistics
      Returns:
      the total length of terminal branches
      See Also:
    • getInnerBranches

      public List<Path> getInnerBranches()
      Gets the inner branches from the analyzed paths.

      In PathStatistics, inner branches are equivalent to primary branches.

      Overrides:
      getInnerBranches in class TreeStatistics
      Returns:
      the list of inner branches (same as primary branches)
      See Also:
    • getInnerLength

      public double getInnerLength()
      Gets the total length of inner branches.

      In PathStatistics, this returns the same value as getPrimaryLength().

      Overrides:
      getInnerLength in class TreeStatistics
      Returns:
      the total length of inner branches
      See Also:
    • getCol

      protected int getCol(String header)
      Overrides:
      getCol in class TreeStatistics
    • assembleStats

      protected void assembleStats(sc.fiji.snt.analysis.TreeStatistics.StatisticsInstance stat, String measurement)
      Overrides:
      assembleStats in class TreeStatistics
    • getSummaryStats

      public org.apache.commons.math3.stat.descriptive.SummaryStatistics getSummaryStats(String metric)
      Description copied from class: TreeStatistics
      Computes the SummaryStatistics for the specified measurement.
      Overrides:
      getSummaryStats in class TreeStatistics
      Parameters:
      metric - the measurement (TreeStatistics.N_NODES, TreeStatistics.NODE_RADIUS, etc.)
      Returns:
      the SummaryStatistics object.
    • getMetric

      public Number getMetric(String metric, Path path) throws UnknownMetricException
      Gets a specific metric value for an individual path.

      This method provides direct access to morphometric properties of individual paths, including geometric measurements, connectivity information, and structural characteristics. It supports all standard path metrics plus PathStatistics-specific measurements.

      Supported metrics include:
      • Geometric: length, volume, surface area, mean radius
      • Structural: number of nodes, branch points, children
      • Angular: extension angles in XY, XZ, ZY planes
      • Morphological: contraction, fractal dimension, spine density
      • Metadata: path ID, channel, frame, order
      Parameters:
      metric - the name of the metric to retrieve
      path - the specific path to measure
      Returns:
      the metric value for the specified path
      Throws:
      UnknownMetricException - if the metric is not recognized
    • measureIndividualPaths

      public void measureIndividualPaths(Collection<String> metrics, boolean summarize)
      Measures specified metrics for each individual path and creates a detailed table.

      This method generates a comprehensive measurement table where each row represents an individual path and columns contain the requested morphometric measurements. This is particularly useful for comparative analysis of path properties or for exporting detailed morphometric data.

      The generated table includes:
      • Path identification information (name, SWC type)
      • All requested morphometric measurements
      • Optional summary statistics (if summarize is true)
      Parameters:
      metrics - the collection of metric names to measure for each path. If null or empty, a default "safe" set of metrics is used
      summarize - if true, adds summary statistics to the table