public class TreeAnalyzer extends ContextCommand
Tree
sModifier and Type | Field and Description |
---|---|
protected DisplayService |
displayService |
protected List<Path> |
innerBranches |
protected List<Path> |
primaryBranches |
protected StatusService |
statusService |
protected DefaultGenericTable |
table |
protected List<Path> |
terminalBranches |
protected Set<PointInImage> |
tips |
protected Tree |
tree |
Constructor and Description |
---|
TreeAnalyzer(Collection<Path> paths,
String label)
Instantiates a new Tree analyzer from a collection of paths.
|
TreeAnalyzer(Tree tree)
Instantiates a new Tree analyzer.
|
Modifier and Type | Method and Description |
---|---|
static List<String> |
getAllMetrics()
Gets the list of all supported metrics.
|
Set<BrainAnnotation> |
getAnnotations() |
Set<BrainAnnotation> |
getAnnotations(int level) |
double |
getAvgBranchLength()
Gets average length for all the branches of the analyzed tree.
|
double |
getAvgContraction()
Gets average
contraction for all the branches
of the analyzed tree. |
double |
getAvgFractalDimension()
Gets the average fractal dimension of the analyzed tree.
|
double |
getAvgFragmentation() |
double |
getAvgPartitionAsymmetry()
Gets the average partition asymmetry of the analyzed tree.
|
double |
getAvgRemoteBifAngle()
Gets the average remote bifurcation angle of the analyzed tree.
|
List<Path> |
getBranches()
Gets all the branches in the analyzed tree.
|
Set<PointInImage> |
getBranchPoints()
Gets the position of all the branch points in the analyzed tree.
|
Set<PointInImage> |
getBranchPoints(BrainAnnotation annot)
Gets the position of all the branch points in the analyzed tree associated
with the specified annotation.
|
double |
getCableLength()
Gets the cable length.
|
double |
getCableLength(BrainAnnotation compartment)
Gets the cable length associated with the specified compartment (neuropil
label).
|
double |
getCableLength(BrainAnnotation compartment,
boolean includeChildren)
Gets the cable length associated with the specified compartment (neuropil
label).
|
double |
getCableLengthNorm(BrainAnnotation compartment)
Gets the cable length associated with the specified compartment (neuropil
label) as a ratio of total length.
|
protected int |
getCol(String header) |
double |
getDepth() |
List<Double> |
getFractalDimension()
Gets the fractal dimension of each branch in the analyzed tree.
|
double |
getHeight() |
int |
getHighestPathOrder()
Gets the highest
path order of the analyzed tree |
List<Path> |
getInnerBranches()
Retrieves the branches of highest
Strahler order in the Tree. |
double |
getInnerLength()
Gets the cable length of inner branches
|
Number |
getMetric(String metric)
Computes the specified metric.
|
protected Number |
getMetricInternal(String metric) |
static List<String> |
getMetrics()
Gets a list of supported metrics.
|
protected Number |
getMetricWithoutChecks(String metric) |
int |
getNBranches()
Gets the number of branches in the analyzed tree.
|
int |
getNbranchPoints(BrainAnnotation annot)
Gets the number of branch points in the analyzed tree associated with the
specified annotation.
|
double |
getNbranchPointsNorm(BrainAnnotation annot)
Gets the percentage of branch points in the analyzed tree associated with the
specified annotation
|
protected int |
getNextRow(String rowHeader) |
protected int |
getNFittedPaths() |
int |
getNoSpinesOrVaricosities()
Gets the number of spines/varicosities that have been (manually) assigned to
tree being analyzed.
|
int |
getNPaths()
Gets the no.
|
int |
getNtips(BrainAnnotation annot)
Gets the number of end points in the analyzed tree associated with the
specified annotation.
|
double |
getNtipsNorm(BrainAnnotation annot)
Gets the percentage of end points in the analyzed tree associated with the
specified annotation
|
Tree |
getParsedTree()
Returns the set of parsed Paths.
|
List<Double> |
getPartitionAsymmetry()
Gets the partition asymmetry at each bifurcation point in the analyzed tree.
|
List<Path> |
getPrimaryBranches()
Retrieves the primary branches of the analyzed Tree.
|
double |
getPrimaryLength()
Gets the cable length of primary branches.
|
List<Path> |
getPrimaryPaths()
Retrieves all the Paths in the analyzed Tree tagged as primary.
|
List<Double> |
getRemoteBifAngles()
Gets the angle between each bifurcation point and its children in the simplified graph,
which comprise either branch points or terminal nodes.
|
ShollAnalyzer |
getShollAnalyzer()
Gets the
ShollAnalyzer instance associated with this analyzer. |
protected int |
getSinglePointPaths() |
double |
getSpineOrVaricosityDensity()
Gets the overall density of spines/varicosities associated with this tree
|
StrahlerAnalyzer |
getStrahlerAnalyzer()
Gets the
StrahlerAnalyzer instance associated with this analyzer |
double |
getStrahlerBifurcationRatio()
Gets the average
Strahler
bifurcation ratio of the analyzed tree. |
int |
getStrahlerNumber()
Gets the highest
Strahler number of
the analyzed tree. |
protected String |
getSWCTypesAsString() |
DefaultGenericTable |
getTable()
Gets the table currently being used by the Analyzer
|
List<Path> |
getTerminalBranches()
Retrieves the terminal branches of the analyzed Tree.
|
double |
getTerminalLength()
Gets the cable length of terminal branches
|
Set<PointInImage> |
getTips()
Gets the position of all the tips in the analyzed tree.
|
Set<PointInImage> |
getTips(BrainAnnotation annot)
Gets the position of all the tips in the analyzed tree associated with the
specified annotation.
|
double |
getWidth() |
void |
ignoreSWCType(int... types)
Ignores Paths sharing the specified SWC flag(s).
|
protected boolean |
isSameOrParentAnnotation(BrainAnnotation annot,
BrainAnnotation annotToBeTested) |
boolean |
isValid()
Checks whether this tree is topologically valid, i.e., contains only one root
and no loops.
|
static void |
main(String[] args) |
void |
measure(Collection<String> metrics,
boolean groupByType)
Measures this Tree, outputting the result to this Analyzer table using
default row labels.
|
void |
measure(String rowHeader,
Collection<String> metrics,
boolean groupByType)
Measures this Tree, outputting the result to this Analyzer table.
|
void |
resetRestrictions()
Removes any filtering restrictions that may have been set.
|
void |
restrictToLength(double lowerBound,
double upperBound)
Restricts analysis to paths sharing the specified length range.
|
void |
restrictToNamePattern(String pattern)
Restricts analysis to Paths containing the specified string in their name.
|
void |
restrictToOrder(int... orders)
Restricts analysis to Paths sharing the specified Path
order (s). |
void |
restrictToSize(int minSize,
int maxSize)
Restricts analysis to paths having the specified number of nodes.
|
void |
restrictToSWCType(int... types)
Restricts analysis to Paths sharing the specified SWC flag(s).
|
void |
run()
Generates detailed summaries in which measurements are grouped by SWC-type
flags
|
void |
setTable(DefaultGenericTable table)
Sets the Analyzer table.
|
void |
setTable(DefaultGenericTable table,
String title)
Sets the table.
|
void |
summarize(boolean groupByType)
Outputs a summary of the current analysis to the Analyzer table using the
default Tree label.
|
void |
summarize(String rowHeader,
boolean groupByType)
Outputs a summary of the current analysis to the Analyzer table.
|
void |
updateAndDisplayTable()
Updates and displays the Analyzer table.
|
cancel, getCancelReason, isCanceled
context, getContext
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
setContext
protected StatusService statusService
protected DisplayService displayService
protected Tree tree
protected Set<PointInImage> tips
protected DefaultGenericTable table
public TreeAnalyzer(Collection<Path> paths, String label)
paths
- Collection of Paths to be analyzed. Note that null Paths are
discarded. Also, when a Path has been fitted and
Path.getUseFitted()
is true, its fitted 'flavor' is used.label
- the label describing the path collectiongetParsedTree()
public TreeAnalyzer(Tree tree)
tree
- the Tree to be analyzed.public void restrictToSWCType(int... types)
types
- the allowed SWC flags (e.g., Path.SWC_AXON
, etc.)public void ignoreSWCType(int... types)
types
- the SWC flags to be ignored (e.g., Path.SWC_AXON
,
etc.)public void restrictToOrder(int... orders)
order
(s).orders
- the allowed Path orderspublic void restrictToSize(int minSize, int maxSize)
minSize
- the smallest number of nodes a path must have in order to be
analyzed. Set it to -1 to disable minSize filteringmaxSize
- the largest number of nodes a path must have in order to be
analyzed. Set it to -1 to disable maxSize filteringpublic void restrictToLength(double lowerBound, double upperBound)
lowerBound
- the smallest length a path must have in order to be
analyzed. Set it to Double.NaN to disable lowerBound filteringupperBound
- the largest length a path must have in order to be
analyzed. Set it to Double.NaN to disable upperBound filteringpublic void restrictToNamePattern(String pattern)
pattern
- the string to search forpublic void resetRestrictions()
public Tree getParsedTree()
resetRestrictions()
public void summarize(boolean groupByType)
groupByType
- if true measurements are grouped by SWC-type flagrun()
,
setTable(DefaultGenericTable)
public void summarize(String rowHeader, boolean groupByType)
rowHeader
- the String to be used as label for the summarygroupByType
- if true measurements are grouped by SWC-type flagrun()
,
setTable(DefaultGenericTable)
protected int getNextRow(String rowHeader)
public static List<String> getMetrics()
getAllMetrics()
MultiTreeStatistics.getMetrics()
public static List<String> getAllMetrics()
MultiTreeStatistics.getAllMetrics()
public Number getMetric(String metric) throws IllegalArgumentException
metric
- the metric to be computed (case insensitive). While it is
expected to be an element of getMetrics()
, it can be
specified in a "loose" manner: If metric
is not
initially recognized, an heuristic will match it to the closest
entry in the list of possible metrics. E.g., "# bps", "n
junctions", will be both mapped to
MultiTreeStatistics.N_BRANCH_POINTS
. Details on the
matching are printed to the Console when in debug mode.IllegalArgumentException
- if metric is not recognizedgetMetrics()
protected Number getMetricWithoutChecks(String metric) throws sc.fiji.snt.analysis.UnknownMetricException
public void measure(Collection<String> metrics, boolean groupByType)
metrics
- the list of metrics to be computed. When null or an empty
collection is specified, getMetrics()
is used.groupByType
- if false, metrics are computed to all branches in the
Tree. If true, measurements will be split by SWC type
annotations (axon, dendrite, etc.)public void measure(String rowHeader, Collection<String> metrics, boolean groupByType)
rowHeader
- the row header labelmetrics
- the list of metrics to be computed. When null or an empty
collection is specified, getMetrics()
is used.groupByType
- if false, metrics are computed to all branches in the
Tree. If true, measurements will be split by SWC type
annotations (axon, dendrite, etc.)protected String getSWCTypesAsString()
public void setTable(DefaultGenericTable table)
table
- the table to be used by the analyzersummarize(boolean)
public void setTable(DefaultGenericTable table, String title)
table
- the table to be used by the analyzertitle
- the title of the table display windowpublic DefaultGenericTable getTable()
public void run()
summarize(String, boolean)
public void updateAndDisplayTable()
protected int getCol(String header)
protected int getSinglePointPaths()
public int getNPaths()
protected int getNFittedPaths()
public double getWidth()
public double getHeight()
public double getDepth()
public List<Path> getPrimaryPaths()
getPrimaryBranches()
public List<Path> getInnerBranches()
Strahler order
in the Tree.
This typically correspond to the most 'internal' branches of the Tree in
direct sequence from the root.getPrimaryPaths()
,
StrahlerAnalyzer.getBranches()
,
StrahlerAnalyzer.getHighestBranchOrder()
public List<Path> getPrimaryBranches()
getPrimaryPaths()
,
StrahlerAnalyzer.getRootAssociatedBranches()
public List<Path> getTerminalBranches()
Path.getSection(int, int)
, these branches will not carry any
connectivity information.getPrimaryBranches()
,
restrictToOrder(int...)
public Set<PointInImage> getTips()
public Set<PointInImage> getTips(BrainAnnotation annot)
annot
- the BrainAnnotation to be queried. Null not allowed.public int getNtips(BrainAnnotation annot)
annot
- the BrainAnnotation to be queried.public double getNtipsNorm(BrainAnnotation annot)
annot
- the BrainAnnotation to be queried.annot
and the total number of end points in the tree.public Set<PointInImage> getBranchPoints()
public Set<PointInImage> getBranchPoints(BrainAnnotation annot)
annot
- the BrainAnnotation to be queried.public int getNbranchPoints(BrainAnnotation annot)
annot
- the BrainAnnotation to be queried.public double getNbranchPointsNorm(BrainAnnotation annot)
annot
- the BrainAnnotation to be queried.annot
and the total number of branch points in the tree.public double getCableLength()
public double getCableLength(BrainAnnotation compartment)
compartment
- the query compartment (null not allowed). All of its
children will be consideredpublic double getCableLengthNorm(BrainAnnotation compartment)
compartment
- the query compartment (null not allowed). All of its
children will be consideredpublic double getCableLength(BrainAnnotation compartment, boolean includeChildren)
compartment
- the query compartment (null not allowed)includeChildren
- whether children of compartment
should be includedprotected boolean isSameOrParentAnnotation(BrainAnnotation annot, BrainAnnotation annotToBeTested)
public Set<BrainAnnotation> getAnnotations()
public Set<BrainAnnotation> getAnnotations(int level)
public double getPrimaryLength()
getPrimaryBranches()
public double getInnerLength()
getInnerBranches()
public double getTerminalLength()
getTerminalBranches()
public int getHighestPathOrder()
path order
of the analyzed treegetStrahlerNumber()
public boolean isValid()
public int getStrahlerNumber() throws IllegalArgumentException
Strahler number
of
the analyzed tree.IllegalArgumentException
- if tree contains multiple roots or loopspublic StrahlerAnalyzer getStrahlerAnalyzer() throws IllegalArgumentException
StrahlerAnalyzer
instance associated with this analyzerIllegalArgumentException
- if tree contains multiple roots or loopspublic ShollAnalyzer getShollAnalyzer()
ShollAnalyzer
instance associated with this analyzer. Note
that changes to ShollAnalyzer
must be performed before calling
getMetric(String)
, measure(Collection, boolean)
, etc.public double getStrahlerBifurcationRatio() throws IllegalArgumentException
Strahler
bifurcation ratio
of the analyzed tree.IllegalArgumentException
- if tree contains multiple roots or loopspublic int getNBranches() throws IllegalArgumentException
IllegalArgumentException
- if tree contains multiple roots or loopspublic List<Path> getBranches() throws IllegalArgumentException
IllegalArgumentException
- if tree contains multiple roots or loopsStrahlerAnalyzer.getBranches()
public double getAvgContraction() throws IllegalArgumentException
contraction
for all the branches
of the analyzed tree.IllegalArgumentException
- if tree contains multiple roots or loopspublic double getAvgFragmentation()
public double getAvgBranchLength() throws IllegalArgumentException
IllegalArgumentException
- if tree contains multiple roots or loopspublic List<Double> getRemoteBifAngles() throws IllegalArgumentException
IllegalArgumentException
- if the tree contains multiple roots or loopspublic double getAvgRemoteBifAngle() throws IllegalArgumentException
IllegalArgumentException
- if the tree contains multiple roots or loopspublic List<Double> getPartitionAsymmetry() throws IllegalArgumentException
IllegalArgumentException
- if the tree contains multiple roots or loopspublic double getAvgPartitionAsymmetry() throws IllegalArgumentException
IllegalArgumentException
- if the tree contains multiple roots or loopspublic List<Double> getFractalDimension() throws IllegalArgumentException
IllegalArgumentException
- if the tree contains multiple roots or loopsStrahlerAnalyzer.getBranches()
public double getAvgFractalDimension() throws IllegalArgumentException
IllegalArgumentException
- if the tree contains multiple roots or loopspublic int getNoSpinesOrVaricosities()
public double getSpineOrVaricosityDensity()
getNoSpinesOrVaricosities()/getCableLength()
)public static void main(String[] args) throws InterruptedException
InterruptedException
Copyright © 2015–2021 Fiji. All rights reserved.