Class NodeStatistics<T extends PointInImage>

java.lang.Object
sc.fiji.snt.analysis.NodeStatistics<T>
Type Parameters:
T - Pixel type

public class NodeStatistics<T extends PointInImage> extends Object
Computes summary and descriptive statistics from a Collection of nodes, including convenience methods to plot distributions of such data.
Author:
Tiago Ferreira
  • Field Details

  • Constructor Details

    • NodeStatistics

      public NodeStatistics(Collection<T> points)
      Performs statistics on a collection of nodes.
      Parameters:
      points - the points to be analyzed
    • NodeStatistics

      public NodeStatistics(Collection<T> points, Tree tree)
      Performs statistics on a collection of nodes.
      Parameters:
      points - the points to be analyzed
      tree - the Tree associated with points
  • Method Details

    • getMetrics

      public static List<String> getMetrics()
      Gets the list of supported metrics.
      Returns:
      the list of supported metrics
    • setLabel

      public void setLabel(String label)
      Sets a descriptive label to this statistic analysis to be used in histograms, etc.
      Parameters:
      label - the descriptive label
    • getDescriptiveStatistics

      public org.apache.commons.math3.stat.descriptive.DescriptiveStatistics getDescriptiveStatistics(String metric) throws UnknownMetricException
      Computes the DescriptiveStatistics for the specified measurement.
      Parameters:
      metric - the measurement (X_COORDINATES, Y_COORDINATES, etc.)
      Returns:
      the DescriptiveStatistics object.
      Throws:
      UnknownMetricException
    • filter

      public List<T> filter(String metric, double lowerBound, double upperBound) throws UnknownMetricException
      Filters the current pool of nodes matching a measurement-based criterion.
      Parameters:
      metric - the measurement (X_COORDINATES, Y_COORDINATES, BRANCH_ORDER, etc.)
      lowerBound - the lower metric value (inclusive)
      upperBound - the upper metric value (inclusive)
      Returns:
      the filtered list.
      Throws:
      UnknownMetricException
    • getHistogram

      public SNTChart getHistogram(String metric)
      Gets the relative frequencies histogram for a univariate measurement. The number of bins is determined using the Freedman-Diaconis rule.
      Parameters:
      metric - the measurement (X_COORDINATES, RADIUS, etc.)
      Returns:
      the frame holding the histogram
    • get

      public List<T> get(BrainAnnotation compartment)
      Gets the list of nodes associated with the specified compartment (neuropil label).
      Parameters:
      compartment - the query compartment (null not allowed). All of its children will be considered
      Returns:
      the list of filtered nodes
    • get

      public List<T> get(BrainAnnotation compartment, boolean includeChildren)
      Gets the list of nodes associated with the specified compartment (neuropil label).
      Parameters:
      compartment - the query compartment (null not allowed)
      includeChildren - whether children of compartment should be included
      Returns:
      the list of filtered nodes
    • getAnnotatedNodes

      public Map<BrainAnnotation,Set<T>> getAnnotatedNodes()
      Splits the nodes being analyzed into groups sharing the same brain annotation.
      Returns:
      the map containing the brain annotations as keys, and list of nodes as values.
    • getAnnotatedNodes

      public Map<BrainAnnotation,Set<T>> getAnnotatedNodes(int level)
      Splits the nodes being analyzed into groups sharing the same brain annotation.
      Parameters:
      level - the ontological depth of the compartments to be considered
      Returns:
      the map containing the brain annotations as keys, and list of nodes as values.
    • getAnnotatedFrequencies

      public Map<BrainAnnotation,Integer> getAnnotatedFrequencies()
      Retrieves the count frequencies across brain compartment.
      Returns:
      the map containing the brain compartments as keys, and count frequencies as values.
    • getAnnotatedFrequencies

      public Map<BrainAnnotation,Integer> getAnnotatedFrequencies(int level)
      Retrieves the count frequencies across brain compartment.
      Parameters:
      level - the ontological depth of the compartments to be considered
      Returns:
      the map containing the brain compartments as keys, and count frequencies as values.
      See Also:
    • getAnnotatedFrequencies

      public Map<BrainAnnotation,Integer> getAnnotatedFrequencies(int level, String hemisphere)
      Retrieves the count frequencies across brain compartment.
      Parameters:
      level - the ontological depth of the compartments to be considered
      hemisphere - typically 'left' or 'right'. The hemisphere flag ( BrainAnnotation.LEFT_HEMISPHERE or BrainAnnotation.RIGHT_HEMISPHERE) is extracted from the first character of the string (case-insensitive). Ignored if not a recognized option
      Returns:
      the map containing the brain compartments as keys, and frequencies as values.
      See Also:
    • getAnnotatedFrequenciesByHemisphere

      public Map<BrainAnnotation,int[]> getAnnotatedFrequenciesByHemisphere(int level, Tree tree)
    • getAnnotatedHistogram

      public SNTChart getAnnotatedHistogram()
      Retrieves the histogram of count frequencies across brain areas.
      Returns:
      the annotated frequencies histogram
    • getAnnotatedHistogram

      public SNTChart getAnnotatedHistogram(int depth)
      Retrieves the histogram of count frequencies across brain areas of the specified ontology level.
      Parameters:
      depth - the ontological depth of the compartments to be considered
      Returns:
      the annotated frequencies histogram
      See Also:
    • getAnnotatedFrequencyHistogram

      public SNTChart getAnnotatedFrequencyHistogram(int depth, String hemisphere, Tree tree)
      Retrieves the histogram of count frequencies across brain areas of the specified ontology level across the specified hemisphere.
      Parameters:
      depth - the ontological depth of the compartments to be considered
      hemisphere - 'left', 'right' or 'ratio' (case-insensitive). Ignored if not a recognized option
      tree - the Tree associated with the nodes being analyzed. Only used if hemisphere is 'ratio'.
      Returns:
      the annotated frequencies histogram
      See Also:
    • getStandardizedMetric

      protected static String getStandardizedMetric(String guess)
    • assignBranches

      public void assignBranches(Tree tree)
      Associates the nodes being analyzed to the branches of the specified tree
      Parameters:
      tree - the association tree
    • isBranchesAssigned

      protected boolean isBranchesAssigned()
    • getNormalizedMeasurement

      protected static String getNormalizedMeasurement(String measurement)
    • assessIfBranchesHaveBeenAssigned

      protected void assessIfBranchesHaveBeenAssigned()
    • computeNearestNeighborDistances

      public static <T extends PointInImage> void computeNearestNeighborDistances(List<T> points)
      Computes nearest neighbor distances. Assigns the computed value to the v value of each point
      Type Parameters:
      T - the type of PointImage
      Parameters:
      points - the list of points
    • main

      public static void main(String[] args)