de.unihalle.informatik.MiToBo.core.datatypes
Class MTBNeuriteSkelGraph

java.lang.Object
  extended by de.unihalle.informatik.MiToBo.core.datatypes.MTBGraph
      extended by de.unihalle.informatik.MiToBo.core.datatypes.MTBNeuriteSkelGraph

public class MTBNeuriteSkelGraph
extends MTBGraph

 The class implements a neurite skeleton graph (NSG), based on the skeleton
 of a neurite region. The NSG is directed, in the way that exact one START
 node (mostly the point near the neuron cell body area) exists, which can
 have one or more output edges and no input edges. By the way, there are some
 other nodes from type BRANCH or END inside the graph.
 
 BRANCH nodes: have one input edge and two or more out edges
 END nodes: have exact one input edge and no output edges 
 
 The NSG is build by skeleton traversing, beginning at one
 given node. The direction is implicit corrected, so that at every time there
 is a direct "flow" from the START node to all END nodes. So the START node is
 connected with every END node via exact one path.
 
 If the START nodes is changed, the directness of the graph is automatically
 corrected, and the old node becomes automatically a BRANCH or a END node.
 
 The edges hold the pixels of the skeleton between the nodes.
 It is possible to get all paths from the START node to all END nodes,
 get the longest path in the whole graph, and several other operations,
 needed for a NSG.
 
 The graph is always free of circles. If an circle exists in the underlying
 skeleton, the circle is disconnected in two paths
 (due to the approach of building the graph).
 
 

Author:
Danny Misiak
See Also:
MTBGraph, MTBGraphEdge, MTBNeuriteSkelGraphNode

Field Summary
 
Fields inherited from class de.unihalle.informatik.MiToBo.core.datatypes.MTBGraph
directed, edges, nodes, numberOfEdges, numberOfNodes
 
Constructor Summary
MTBNeuriteSkelGraph()
          Standard constructor.
MTBNeuriteSkelGraph(int _maxSpineLength)
          Constructor that creates an empty directed MTBNeuriteSkelGraph with defined maximum spine length.
MTBNeuriteSkelGraph(Vector<MTBNeuriteSkelGraphNode<Point2D.Double>> skelNodes, Vector<MTBGraphEdge> skelEdges, int _maxSpineLength, int _width, int _heigth)
          Constructor to create an directed MTBNeuriteSkelGraph with the given MTBSkeletonGraphNodes and MTBGraphEdges.
 
Method Summary
 boolean buildSkeletonGraph(int x, int y, int w, int h, MTBImageByte skeletonImg, int skelColor)
           Build the skeleton graph from a given binary skeleton image and a given starting point to build up the graph.
 MTBNeuriteSkelGraph clone()
           
 Vector<Vector<Point2D.Double>> getAllPaths(boolean includeSpines)
          Get the pixels of all paths of the neurite skeleton graph.
 void getAllPixels(Vector<Point2D.Double> pixels)
           Get all pixels of the neurite skeleton graph from the nodes and edges.
 Vector<MTBNeuriteSkelGraphNode<Point2D.Double>> getBranchNodes()
          Get all branch nodes of the MTBNeuriteSkelGraph.
 Vector<MTBNeuriteSkelGraphNode<Point2D.Double>> getEndNodes()
          Get all end nodes of the MTBNeuriteSkelGraph.
 int getHeight()
          Get skeleton graph image size in y direction.
 Vector<Point2D.Double> getLongestPath(boolean includeSpines)
          Get the pixels of the longest path of the neurite skeleton graph.
 int getRegionID()
          Get the region id.
 Vector<Point2D.Double> getShortestPath(boolean includeSpines)
          Get the pixels of the shortest path of the neurite skeleton graph.
 Vector<MTBNeuriteSkelGraphNode<Point2D.Double>> getSkeletonGraphNodes()
          Get all nodes of the MTBNeuriteSkelGraph as MTBNeuriteSkelGraphNodes.
 Vector<Vector<Point2D.Double>> getSpinePaths()
          Get the pixels of all spine paths of the neurite skeleton graph.
 MTBNeuriteSkelGraphNode<Point2D.Double> getStartNode()
          Get the start node of the MTBNeuriteSkelGraph.
 int getWidth()
          Get skeleton graph image size in x direction.
 void print()
          Print the neurite skeleton graph informations.
 void setRegionID(int id)
          Set the region id.
 void setStartNode(MTBNeuriteSkelGraphNode<Point2D.Double> node)
          Set a new start node.
 MTBImageByte toByteImage()
          Draw the skeleton graph into a binary image.
 MTBImageRGB toImage()
          Visualize the skeleton graph as RGB image.
 MTBImageRGB toImage(MTBImageRGB rgbImage)
          Draw the skeleton graph in the given RGB image.
 MTBTableModel toSWC(String fileName, MTBImageByte neuronImage)
          Method to save neurite skeleton graph as SWC file.
 
Methods inherited from class de.unihalle.informatik.MiToBo.core.datatypes.MTBGraph
addEdge, addNode, getEdgeNum, getEdges, getGraphCost, getNodeNum, getNodes, isDirected, removeEdge, removeNode
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MTBNeuriteSkelGraph

public MTBNeuriteSkelGraph()
Standard constructor. Creates an empty directed MTBNeuriteSkelGraph. Maximum spine length is set to 0.


MTBNeuriteSkelGraph

public MTBNeuriteSkelGraph(int _maxSpineLength)
Constructor that creates an empty directed MTBNeuriteSkelGraph with defined maximum spine length.

Parameters:
_maxSpineLength -

MTBNeuriteSkelGraph

public MTBNeuriteSkelGraph(Vector<MTBNeuriteSkelGraphNode<Point2D.Double>> skelNodes,
                           Vector<MTBGraphEdge> skelEdges,
                           int _maxSpineLength,
                           int _width,
                           int _heigth)
                    throws MTBNeuriteSkelGraphException
Constructor to create an directed MTBNeuriteSkelGraph with the given MTBSkeletonGraphNodes and MTBGraphEdges.

Parameters:
skelNodes - vector of MTBNeuriteSkelGraphNodes
skelEdges - vector of MTBGraphEdges
Throws:
MTBNeuriteSkelGraphException
Method Detail

getWidth

public int getWidth()
Get skeleton graph image size in x direction.


getHeight

public int getHeight()
Get skeleton graph image size in y direction.


clone

public MTBNeuriteSkelGraph clone()
Overrides:
clone in class Object

getSkeletonGraphNodes

public Vector<MTBNeuriteSkelGraphNode<Point2D.Double>> getSkeletonGraphNodes()
Get all nodes of the MTBNeuriteSkelGraph as MTBNeuriteSkelGraphNodes.

Returns:
Vector of MTBNeuriteSkelGraphNode.

getStartNode

public MTBNeuriteSkelGraphNode<Point2D.Double> getStartNode()
Get the start node of the MTBNeuriteSkelGraph.

Returns:
MTBNeuriteSkelGraphNode of type START.

setStartNode

public void setStartNode(MTBNeuriteSkelGraphNode<Point2D.Double> node)
Set a new start node. For the skeleton graph only one start node can exist! The node type for the old start node automatically becomes a node of type BRANCH or END, depending on the number of output edges. If no output edges exist, the nodes becomes a END node, if some output edges exit, the node becomes a BRANCH node. Direction correction of the edges is automatically applied too.

Parameters:
node - new start node

getBranchNodes

public Vector<MTBNeuriteSkelGraphNode<Point2D.Double>> getBranchNodes()
Get all branch nodes of the MTBNeuriteSkelGraph.

Returns:
Vector of MTBNeuriteSkelGraphNode of type BRANCH.

getEndNodes

public Vector<MTBNeuriteSkelGraphNode<Point2D.Double>> getEndNodes()
Get all end nodes of the MTBNeuriteSkelGraph.

Returns:
Vector of MTBNeuriteSkelGraphNode of type END.

setRegionID

public void setRegionID(int id)
Set the region id. This id indirectly links the neurite skeleton graph to a neurite region, where the skeleton is created from. So in another application the skeleton can be linked to a region and vice versa.


getRegionID

public int getRegionID()
Get the region id. This id indirectly links the neurite skeleton graph to a neurite region, where the skeleton is created from. So in another application the skeleton can be linked to a region and vice versa.


buildSkeletonGraph

public boolean buildSkeletonGraph(int x,
                                  int y,
                                  int w,
                                  int h,
                                  MTBImageByte skeletonImg,
                                  int skelColor)
 Build the skeleton graph from a given binary skeleton image and a given
 starting point to build up the graph.
 
 
 Build definition:
 
 The graph is build from a given starting point (mostly a end point of the
 skeleton, near the neuron cell body). All other points are marked
 automatically by building up the graph.
 Branch points are marked as BRANCH nodes, end points are marked as END
 nodes and edge points are added to the edge data structure.
 
 BRANCH nodes: have one input edge and two or more out edges
 END nodes: have exact one input edge and no output edges 
 
 By building up the graph, 4-way neighbors are visited first, diagonal
 neighbors are visited in the second step.
 
 The graph is always free of circles. If an circle exists in the underlying
 skeleton, the circle is disconnected in two paths
 (due to the approach of building the graph).
 
 

Parameters:
x - starting point coordinate in x-direction
y - starting point coordinate in y-direction
w - width of the skeleton image
h - height of the skeleton image
skeletonImg - the binary skeleton image
skelColor - color of the skeleton, the background is set to the opposite color, for example the skeleton is 0, then the background is set to 255 and vice versa
Returns:
true if graph was successfully build

getAllPixels

public void getAllPixels(Vector<Point2D.Double> pixels)
 
 Get all pixels of the neurite skeleton graph from the nodes and edges.
 Pixel collection starts at the start node of the skeleton graph.
 
 WARNING!!!
 The specific order within the list depends on the edge direction between
 the single nodes. Order of the single edges depends on the build process.
 
 

Parameters:
pixels - empty list to be filled

getLongestPath

public Vector<Point2D.Double> getLongestPath(boolean includeSpines)
Get the pixels of the longest path of the neurite skeleton graph. The pixels are ordered from the START node to the corresponding END node of the path.

Parameters:
includeSpines -
Returns:
Pixel of longest path.

getShortestPath

public Vector<Point2D.Double> getShortestPath(boolean includeSpines)
Get the pixels of the shortest path of the neurite skeleton graph. The pixels are ordered from the START node to the corresponding END node of the path.

Parameters:
includeSpines -
Returns:
Pixel of shortest path.

getSpinePaths

public Vector<Vector<Point2D.Double>> getSpinePaths()
Get the pixels of all spine paths of the neurite skeleton graph. The pixels are ordered from the START node to the corresponding END node of the path.

Returns:
Vector of spine paths.

getAllPaths

public Vector<Vector<Point2D.Double>> getAllPaths(boolean includeSpines)
Get the pixels of all paths of the neurite skeleton graph. The pixels are ordered from the START node to the corresponding END node of the path.

Parameters:
includeSpines -
Returns:
Vector of all paths.

toImage

public MTBImageRGB toImage()
Visualize the skeleton graph as RGB image. Edge points colored in bright green, END nodes colored in red, BRANCH nodes colored in blue and START nodes colored in green.

Returns:
RGB labeled graph image.

toImage

public MTBImageRGB toImage(MTBImageRGB rgbImage)
Draw the skeleton graph in the given RGB image. Edge points colored in bright green, END nodes colored in red, BRANCH nodes colored in blue and START nodes colored in green.

Returns:
Graph drawn in the given RGB image.

toByteImage

public MTBImageByte toByteImage()
Draw the skeleton graph into a binary image. Background is filled with white, graph is drawn in black.


print

public void print()
Print the neurite skeleton graph informations.

Overrides:
print in class MTBGraph

toSWC

public MTBTableModel toSWC(String fileName,
                           MTBImageByte neuronImage)
Method to save neurite skeleton graph as SWC file.

Parameters:
fileName - filename for saving the SWC file, if null, file will not be saved
neuronImage - if radii for each skeleton point should be calculated, a image must be given to calculate the distance map of the neuron region and get radius of each skeleton point, can be null
Returns:
MTBTableModel Table with SWC file data.


Copyright © 2010–2015 Martin Luther University Halle-Wittenberg. All rights reserved.