vnt

Class Node_Analysis

Implemented Interfaces:
PlugInFilter

public class Node_Analysis
extends VascularNetworkToolkit
implements PlugInFilter

Multi-purpose class for final analysis. Accepts a pruned, thinned distance map skeleton. Performs the following operations:
  1. Generates node information at endpoints and branch points.
  2. Traverses the thinned skeleton and computes adjacency list information.
  3. Merges nodes with significant overlap.
  4. Outputs the final coordinate and adjacency list information to text files for Mathematica analysis.
  5. Performs quantitative and topological analysis on the image's skeleton.
Version:
1.0
Author:
Michael Miller - Truman State University
Since:
1.0

Field Summary

private Node[]
nodes
An array of nodes.
private static ResultsTable
rt
Our own persistent results table.

Constructor Summary

Node_Analysis()

Method Summary

double
calculateAverageSkeletalWidth(ImageProcessor bp)
Parses the given image for skeletal structure.
double
calculateConnectedComponentNetworkLength(ImageProcessor bp, Coordinate startingPoint)
Parses the given image for skeletal structure.
int
calculateMeshCount(ImageProcessor bp)
Takes the segmented image and counts the number of enclosed meshes.
double
calculateTotalNetworkArea(ImageProcessor bp)
Parses the given image for skeletal structure.
double
calculateTotalNetworkLength(ImageProcessor bp)
Parses the given image for skeletal structure.
int
countBranchingPoints()
Counts the number of branching points from the nodes[] datastructure.
int
countEdges()
Counts the number of edges in the image.
int
countEndPoints()
Counts the number of end points from the nodes[] datastructure.
int
countIsolatedPoints()
Counts the number of isolated points from the nodes[] datastructure.
int
countMaxDegree()
Counts the number of edges in the image.
int
countNodes()
Counts the number of nodes in the image.
ResultsTable
displayProperties(ImageProcessor skeleton)
Dumps all quantitative and topological properties extractable from the image into the ImageJ results table.
void
displayResults()
Writes the last row in the results table to the ImageJ window.
boolean
drawNodeGraph(ImageProcessor bp, boolean drawSimple)
Displays the graph of the with nodes with their edges.
boolean
drawNodes(boolean drawSimple)
Displays the computed nodes.
boolean
drawSkeletonWithNodes(ImageProcessor bp, boolean drawSimple)
Displays the image with nodes overlayed.
void
generateAdjacencyLists(ImageProcessor bp)
Builds the adjacency list information by parsing the given image along the skeleton.
int
generateNodeInformation(ImageProcessor bp)
Parses the given image for nodes.
void
mergeOverlappingNodes(double overlap)
Performs node merging accross the entire image.
void
run(ImageProcessor bp)
Receives a binary image (specifically a thinned, pruned distance map skeletonization) and computes information regarding the topological properties of the image.
int
setup(String arg, ImagePlus ip)
Specifies the preconditions for the plug-in.
void
writeTextFiles()
Simulates the original code by Jason Hart and Chris Miller.

Field Details

nodes

private Node[] nodes
An array of nodes. Holds all the nodes of the image.

rt

private static ResultsTable rt
Our own persistent results table. This is responsible for displaying the "Results" window data.

Constructor Details

Node_Analysis

public Node_Analysis()

Method Details

calculateAverageSkeletalWidth

public double calculateAverageSkeletalWidth(ImageProcessor bp)
Parses the given image for skeletal structure. Returns the average skeletal width. Note: This method does NOT account for aspect ratio.

Pre: The ImageProcessor bp must exist. This should be the pruned, thinned distance map skeleton. Background should be white, and the color of the skeleton should be WHITE-radius.
Post: The local member nodes[] is created and populated with the nodes in the image.

Parameters:
bp - The ImageProcessor for the pruned, thinned distance map skeleton.
Returns:
Returns the average width of the skeleton.
See Also:
Node_Analysis

calculateConnectedComponentNetworkLength

public double calculateConnectedComponentNetworkLength(ImageProcessor bp,
                                                       Coordinate startingPoint)
Parses the given image for skeletal structure. Stays within the given 8-connected component. Length of the network is given by the equation: L = N + [sqrt(2)-1]*Nd - 1 Where N is the number of pixels of the skeleton and Nd is the number of diagonally connected pairs of pixels.

Pre: The ImageProcessor bp must exist. This should be the pruned, thinned distance map skeleton. Background should be white, and the color of the skeleton should be WHITE-radius.
Post: The local member nodes[] is created and populated with the nodes in the image.

Parameters:
bp - The ImageProcessor for the pruned, thinned distance map skeleton.
Returns:
Returns the total network length of the skeleton.

calculateMeshCount

public int calculateMeshCount(ImageProcessor bp)
Takes the segmented image and counts the number of enclosed meshes. This is largely taken from the FindEdges_Segment.java algorithm, although this is optimized for counting.

Pre: The image must have been converted to binary.
Post: As long as a valid ImageProcessor is given, the number of enclosed meshes is returned.

Parameters:
bp - The ImageProcessor for the segmented image.
Returns:
Returns -1 on error. Otherwise returns a non-negative number that represents the number of 4-connected enclosed meshes.

calculateTotalNetworkArea

public double calculateTotalNetworkArea(ImageProcessor bp)
Parses the given image for skeletal structure. Returns the total area in pixels.

Pre: The ImageProcessor bp must exist. This should be the segmented image.
Post: The local member nodes[] is created and populated with the nodes in the image.

Parameters:
bp - The ImageProcessor for the segmented image.
Returns:
Returns the total area of the vascular network in pixels.

calculateTotalNetworkLength

public double calculateTotalNetworkLength(ImageProcessor bp)
Parses the given image for skeletal structure. Length of the network is given by the equation: L = N + [sqrt(2)-1]*Nd - 1 Where N is the number of pixels of the skeleton and Nd is the number of diagonally connected pairs of pixels.

Pre: The ImageProcessor bp must exist. This should be the pruned, thinned distance map skeleton. Background should be white, and the color of the skeleton should be WHITE-radius.
Post: The local member nodes[] is created and populated with the nodes in the image.

Parameters:
bp - The ImageProcessor for the pruned, thinned distance map skeleton.
Returns:
Returns the total network length of the skeleton.

countBranchingPoints

public int countBranchingPoints()
Counts the number of branching points from the nodes[] datastructure. A branching point is a node with two or more adjacencies.

Pre: The local member nodes[] is checked for the number of non-null nodes. The nodes[] array must be instantiated. It helps a lot if the generateAdjacencyLists procedure has also been called.
Post: The nodes[] structure is searched for non-null nodes and returns the total count.


countEdges

public int countEdges()
Counts the number of edges in the image.

Pre: The local member nodes[] is checked for the number of non-null nodes. The nodes[] array must be instantiated. It helps a lot if the generateAdjacencyLists procedure has also been called.
Post: The nodes[] structure is searched for non-null nodes and returns the total count.


countEndPoints

public int countEndPoints()
Counts the number of end points from the nodes[] datastructure. An end point is a node with a single adjacency.

Pre: The local member nodes[] is checked for the number of non-null nodes. The nodes[] array must be instantiated. It helps a lot if the generateAdjacencyLists procedure has also been called.
Post: The nodes[] structure is searched for non-null nodes and returns the total count.


countIsolatedPoints

public int countIsolatedPoints()
Counts the number of isolated points from the nodes[] datastructure. An isolated point is a node with no adjacencies.

Pre: The local member nodes[] is checked for the number of non-null nodes. The nodes[] array must be instantiated. It helps a lot if the generateAdjacencyLists procedure has also been called.
Post: The nodes[] structure is searched for non-null nodes and returns the total count.


countMaxDegree

public int countMaxDegree()
Counts the number of edges in the image. Returns the maximum degree.

Pre: The local member nodes[] is checked for the number of non-null nodes. The nodes[] array must be instantiated. It helps a lot if the generateAdjacencyLists procedure has also been called.
Post: The nodes[] structure is searched for non-null nodes and returns the total count.


countNodes

public int countNodes()
Counts the number of nodes in the image.

Pre: The local member nodes[] is checked for the number of non-null nodes. The nodes[] array must be instantiated.
Post: The nodes[] structure is searched for non-null nodes and returns the total count.


displayProperties

public ResultsTable displayProperties(ImageProcessor skeleton)
Dumps all quantitative and topological properties extractable from the image into the ImageJ results table.

displayResults

public void displayResults()
Writes the last row in the results table to the ImageJ window. (Parts of code stolen from ImageJ's Analyzer.java)

drawNodeGraph

public boolean drawNodeGraph(ImageProcessor bp,
                             boolean drawSimple)
Displays the graph of the with nodes with their edges.

Pre: The local member nodes[] is created and populated with the nodes in the image. Some nodes may be null (due to merging).
Post: A new image should be created of circular nodes drawn with their edges.

Parameters:
bp - The ImageProcessor for the pruned, thinned distance map skeleton.
drawSimple - If true, the image will be drawn with constant sized nodes. If false, the image will be drawn with true node sizes.
Returns:
Returns true on successful draw. False otherwise.

drawNodes

public boolean drawNodes(boolean drawSimple)
Displays the computed nodes.

Pre: The local member nodes[] is created and populated with the nodes in the image. Some nodes may be null (due to merging).
Post: A new image should be created with circular nodes overlayed on a white background.

Parameters:
drawSimple - If true, the image will be drawn with constant sized nodes. If false, the image will be drawn with true node sizes.
Returns:
Returns true on successful draw. False otherwise.

drawSkeletonWithNodes

public boolean drawSkeletonWithNodes(ImageProcessor bp,
                                     boolean drawSimple)
Displays the image with nodes overlayed.

Pre: The local member nodes[] is created and populated with the nodes in the image. Some nodes may be null (due to merging). The ImageProcessor bp must exist. This should be the pruned, thinned distance map skeleton. Background should be white, and the color of the skeleton should be (WHITE-radius).
Post: A new image should be created of the original with circular nodes overlayed.

Parameters:
bp - The ImageProcessor for the pruned, thinned distance map skeleton.
drawSimple - If true, the image will be drawn with a black skeleton and constant sized nodes. If false, the image will be drawn with distance map skeleton and true node sizes.
Returns:
Returns true on successful draw. False otherwise.

generateAdjacencyLists

public void generateAdjacencyLists(ImageProcessor bp)
Builds the adjacency list information by parsing the given image along the skeleton. Each node's 8-neighbors are traversed until another node is found.

Pre: The local member nodes[] is created and populated with the nodes in the image. The ImageProcessor bp must exist. This should be the pruned, thinned distance map skeleton. Background should be white, and the color of the skeleton should be (WHITE-radius).
Post: The nodes[] structure now contains all adjacency list information.

Parameters:
bp - The ImageProcessor for the pruned, thinned distance map skeleton.

generateNodeInformation

public int generateNodeInformation(ImageProcessor bp)
Parses the given image for nodes. Nodes are identifiable as pixels with either one or three 8-neighbor backgorund 4-connected components. Ie, nodes are either at endpoints or at branch points.

Pre: The ImageProcessor bp must exist. This should be the pruned, thinned distance map skeleton. Background should be white, and the color of the skeleton should be WHITE-radius.
Post: The local member nodes[] is created and populated with the nodes in the image.

Parameters:
bp - The ImageProcessor for the pruned, thinned distance map skeleton.
Returns:
Returns the number of nodes that were found in the image.

mergeOverlappingNodes

public void mergeOverlappingNodes(double overlap)
Performs node merging accross the entire image.

Pre: The local member nodes[] is created and populated with the nodes in the image. Some nodes may be null.
Post: The nodes[] structure now contains all adjacency list information.

Parameters:
overlap - The amount of overlap required before two nodes are considered the same. The parameter should be in the range of [0, 1], where 0 implies two tangent circles will merged, and 1 requires that a node be completely inside another node to merge.

run

public void run(ImageProcessor bp)
Receives a binary image (specifically a thinned, pruned distance map skeletonization) and computes information regarding the topological properties of the image. 1) Parses the image for possible node locations. 2) Accesses the distance map to calculate node radii information. 3) Simplifies the structures by testing for node overlap. 4) Performs graph theoretic analysis based on the information generated.

Pre: The image was cleared to run by the setup() method.
Post: Quantitative data is finally extracted from the image.

Parameters:
bp - Required by the interface. The access information to the original image.

setup

public int setup(String arg,
                 ImagePlus ip)
Specifies the preconditions for the plug-in. If this method succeeds then run() is called.

Pre: ImageJ is running and an 8-bit grayscale image is open. The plug-in was just activated.
Post: Either an argument was processed, the image was not saved to a local folder, or the plug-in is cleared to run on the image.

Parameters:
arg - Required by the interface. The argument list passed to the plug-in.
Returns:
If DONE is returned, ImageJ quits without run()'ing the plug-in. Otherwise, the plug-in signals to ImageJ that this plugin only handles 8-bit (256 grayscale) and will not change the original image.

writeTextFiles

public void writeTextFiles()
Simulates the original code by Jason Hart and Chris Miller. Dumps coordinates and adjacency list information to a text file for analysis in Mathematica using Kathleen Field's code.