Package noduledistances.imagej
Class Statistics
java.lang.Object
noduledistances.imagej.Statistics
A class that generates all of the statistical data for analysis, and saves it as
one csv file.
Data we want for any given node:
✅ distance to closest red nodule
✅ distance to closest green nodule
✅ mean distance to all red nodules
✅ mean distance to all green nodules
✅ whether closest nodule is red or green
✅ # of red nodules within a given distance
✅ # of green nodules within a given distance
As I code methods to compute this data, I can't help but feel there's a much more
efficient way to go about this where I don't create a separate method iterating
through paths for each data point desired. Rather than iterating through this paths list for
each data desired, we itereate through the paths, and call methods that compute that specific data,
that way we only loop through ptahs once per nodule. Will have to refactor to do this.
- Author:
- Farris
-
Constructor Summary
ConstructorsConstructorDescriptionStatistics(String imageName, String redAttribute, String greenAttribute) Initializer method for the Statistics class. -
Method Summary
Modifier and TypeMethodDescriptionprotected intclosestColorType(Node node, RootGraph graph) computes what color the closest nodule is.protected intclosestDistance(int color, Node node, RootGraph graph) computeStatistics(int[] radii, Node node, RootGraph graph, ArrayList<Integer> options) Computes the number of nodules within a given radius of a given color.voidgenerateData(RootGraph graph, int[] radii, String saveFile) Populates the String[][] data with computed statistics relevant to distance data.protected static doublemeanDistance(int color, Node node, RootGraph graph) Computes the mean distance from the given nodule to all other nodules of a given type.protected intnumNodulesinBall(int color, int radius, Node node, RootGraph graph) Finds the number of nodules in the ball of given radius, centered at given node.voidsavePairwiseDistanceMatrices(RootGraph graph, String saveFile, int numIters) Saves the pair-wise distance matrices as csv files.
-
Constructor Details
-
Statistics
public Statistics(String imageName, String redAttribute, String greenAttribute) throws com.opencsv.exceptions.CsvValidationException Initializer method for the Statistics class. This method preps the program for computing the desired statistics.- Parameters:
imageName-redAttribute- : optional user input representing an attribute of the red nodules in the image.greenAttribute- : optional user input representing an attribute of the green nodules in the image.- Throws:
com.opencsv.exceptions.CsvValidationException
-
-
Method Details
-
generateData
Populates the String[][] data with computed statistics relevant to distance data.- Parameters:
graph-
-
savePairwiseDistanceMatrices
Saves the pair-wise distance matrices as csv files. the _i at the end of csv names is the i'th set of shortest paths (i.e. the _1 is the absolute shortest paths) -
computeStatistics
protected static HashMap<Integer,double[]> computeStatistics(int[] radii, Node node, RootGraph graph, ArrayList<Integer> options) Computes the number of nodules within a given radius of a given color. Note that our ball here is not a literal ball, as we use the distances along the root systems to compute whether a node falls within the ball, i.e. distance along root system < radius.- Parameters:
radii- : array of radii we'll search around.node- : node we're searching around (center)graph- : graph objectoptions- : list telling us what statistics to compute- Returns:
-
numNodulesinBall
Finds the number of nodules in the ball of given radius, centered at given node.- Parameters:
color- : color of the given nodule node.radius- : radius of the ball.node- : center of the ball.graph- : graph object.- Returns:
- : number of nodules in radius distance away from node.
-
closestDistance
- Parameters:
color- == 1 -> red nodule == 2 -> green nodule == 3 -> mixed nodule- Returns:
- : the closest distance from a given node to another node of the given color
-
closestColorType
computes what color the closest nodule is. If there is a tie, it...- Parameters:
node-graph-- Returns:
-
meanDistance
Computes the mean distance from the given nodule to all other nodules of a given type.- Parameters:
color- : color to restrict the mean distances tonode- : node we're computing the mean distances fromgraph- : the graph object.- Returns:
- : mean distance from the given nodule to all other nodules of a given type.
-