69 #include <boost/filesystem.hpp>
74 #include "WFileParser.h"
92 explicit WHtree( std::string filename );
108 explicit WHtree( std::string treeName, HC_GRID datasetGridInit,
WHcoord datasetSizeInit,
size_t numStreamlinesInit,
float logFactorInit,
109 std::vector<WHnode> leavesInit, std::vector<WHnode> nodesInit, std::vector<size_t> trackidInit, std::vector<WHcoord> coordInit,
110 std::list<WHcoord> discardInit,
float cpccInit = 0 );
163 std::vector<WHnode>
getNodes()
const;
193 std::vector<WHcoord>
getRoi()
const;
251 std::string
getReport(
bool longMsg =
true )
const;
299 size_t getTrackID(
const size_t &leafID )
const;
313 std::vector<size_t>
getLeaves4node(
const nodeID_t &nodeID )
const;
371 nodeID_t
getCommonAncestor(
const nodeID_t &nodeID1,
const nodeID_t &nodeID2 )
const;
378 std::vector<nodeID_t>
getRoute2Root(
const nodeID_t &nodeID )
const;
387 unsigned int getTripletOrder(
const nodeID_t &nodeIDa,
const nodeID_t &nodeIDb,
const nodeID_t &nodeIDc )
const;
394 std::vector<size_t>
getBaseNodes(
const size_t root )
const;
401 std::vector<nodeID_t>
getBaseNodes(
const nodeID_t &root )
const;
421 dist_t
getDistance(
const size_t nodeID1,
const size_t nodeID2 )
const;
429 dist_t
getDistance(
const nodeID_t &nodeID1,
const nodeID_t &nodeID2 )
const;
445 dist_t
getLeafDistance(
const size_t leafID1,
const size_t leafID2 )
const;
453 void sortBySize( std::vector<size_t>*
const nodeVector )
const;
459 void sortBySize( std::vector<nodeID_t>*
const nodeVector )
const;
465 void sortBySize( std::list<size_t>*
const nodeList )
const;
471 void sortBySize( std::list<nodeID_t>*
const nodeList )
const;
478 void sortByHLevel( std::vector<size_t>*
const nodeVector )
const;
484 void sortByHLevel( std::list<size_t>*
const nodeList )
const;
491 void sortByHLevel( std::vector<nodeID_t>*
const nodeVector )
const;
497 void sortByHLevel( std::list<nodeID_t>*
const nodeList )
const;
522 bool readTree(
const std::string &filename );
530 bool writeTree(
const std::string &filename,
const bool isNifti =
true )
const;
559 void insertPartitions(
const std::vector<std::vector<size_t> > &selectedPartitions,
const std::vector< float > &selectedValues,
560 const std::vector<std::vector<WHcoord> > &selectedColors = std::vector<std::vector<WHcoord> >() );
566 void insertPartColors(
const std::vector<std::vector<WHcoord> > &selectedColors );
586 std::vector< std::vector< unsigned int > >
getBranching(
const std::vector < nodeID_t > &thisPartition,
588 std::vector< std::vector < nodeID_t > > *partitionSet,
589 const bool excludeLeaves );
598 std::vector< std::vector< unsigned int > >
getBranching(
const std::vector < size_t > &thisPartition,
600 std::vector< std::vector < size_t > > *partitionSet );
704 std::pair<size_t, size_t>
cleanup( std::vector<size_t> *outLookup = 0 );
711 size_t debinarize(
const bool keepBaseNodes =
false );
751 bool operator()(
const nodeID_t &lhs,
const nodeID_t &rhs )
const
787 bool operator()(
const nodeID_t &lhs,
const nodeID_t &rhs )
const
911 return std::vector< size_t >();
928 return std::vector< WHcoord >();
this class to contain a seed voxel coordinate.
this class implements a hierarchical tree node with several relevant attributes
this class operates over the class WHtree to extract partitions and analyze partition quality it may ...
this class implements methods for dendrogram processing, such as pruning, node collapsing and decimat...
this class implements a hierarchical tree and provides functions for creation, partitioning,...
size_t getNumDiscarded() const
Returns the number of leaves of the tree.
void loadContainedLeaves()
stores the contained leaves for each node
std::vector< size_t > getRootBaseNodes() const
returns a vector with all the nodes that have direct link to leaves from the main root
const WHnode & getRoot() const
returns a const reference to the root node
std::vector< WHnode > getNodes() const
Returns the nodes of the tree.
HC_GRID getDataGrid() const
Returns the dataset grid type.
size_t getCommonAncestor(const size_t nodeID1, const size_t nodeID2) const
retrieves the the first common ancestor node of two given nodes
float m_cpcc
Stores the cpcc value of the tree.
friend class graphTreeBuilder
friend class
std::vector< std::vector< WHcoord > > m_selectedColors
Stores the colors of the selected partitions.
bool writeTreeDebug(const std::string &filename) const
writes all redundant tree data for debugging purposes
std::vector< std::vector< size_t > > m_containedLeaves
Stores the contained leafs of each node.
std::vector< size_t > getBaseNodes(const size_t root) const
returns a vector with all the nodes that have direct link to leaves fro the indicated subtree
size_t getNumNodes() const
Returns the number of nodes of the tree.
dist_t getDistance(const size_t nodeID1, const size_t nodeID2) const
computes the cophenetic distance between 2 nodes
std::vector< WHcoord > m_coordinates
Stores the coordinates of the leaf voxels.
std::vector< WHcoord > getCoordinates4node(const size_t nodeID) const
Returns a vector with all the seed voxel coordinates contained in that cluster.
std::vector< size_t > getLeaves4node(const size_t nodeID) const
Returns a vector with all the leaf IDs contained in that cluster.
WHcoord m_datasetSize
Stores the size of the dataset this tree was built from.
friend class pruneTree
friend class
std::vector< WHnode > m_nodes
Stores all the nodes (non-leaves) of the tree.
void insertPartitions(const std::vector< std::vector< size_t > > &selectedPartitions, const std::vector< float > &selectedValues, const std::vector< std::vector< WHcoord > > &selectedColors=std::vector< std::vector< WHcoord > >())
insert a set of partitions into the tree data
friend class image2treeBuilder
friend class
const WHnode & getNode(const nodeID_t &thisNode) const
returns a const pointer to the node indicated by the ID
friend class CnbTreeBuilder
friend class
std::vector< std::vector< size_t > > getSelectedPartitions() const
Returns the set of the selected partitions.
size_t getLeafID(const WHcoord &thisCoord) const
returns the leaf ID of a coordinate in the tree
bool m_loadStatus
Stores all the leaves of the tree (represents a single voxel, for several purposes a leaf also counts...
std::list< WHcoord > getDiscarded() const
Returns the discarded list.
void clearPartitions()
delete all data related to saved partitions
void clearPartColors()
delete only color data of the saved partitions
bool writeTreeOldWalnut(const std::string &filename) const
writes dta for working with the old walnut module
friend class treeComparer
friend class
void forceMonotonicityDown()
eliminates non monotonic steps in the tree top-down, raising the level of parents involved in the non...
dist_t getLeafDistance(const size_t leafID1, const size_t leafID2) const
computes the cophenetic distance between 2 leaves
std::vector< std::vector< size_t > > m_selectedPartitions
Stores a set of selected partitions.
unsigned int getTripletOrder(const nodeID_t &nodeIDa, const nodeID_t &nodeIDb, const nodeID_t &nodeIDc) const
checks the joining order of a given triplet
size_t debinarize(const bool keepBaseNodes=false)
merges nodes joining binary at the same level into non-binary structures
const WHnode & getLeaf(const size_t thisLeaf) const
returns a const pointer to the leaf indicated by the ID
std::vector< WHnode > m_leaves
Stores all the leaves of the tree (represents a single voxel, for several purposes a leaf also counts...
bool writeTreeSimple(const std::string &filename) const
writes only join data without coordinates or reading labels
void clearContainedLeaves()
frees the memory of m_containedLeaves
WHnode * fetchNode(const nodeID_t &thisNode)
returns a pointer to the node indicated by the ID
std::string getReport(bool longMsg=true) const
writes out a small report status of the tree
friend class randCnbTreeBuilder
friend class
std::pair< size_t, size_t > cleanup(std::vector< size_t > *outLookup=0)
cleans leaves/nodes set to be pruned
void sortByHLevel(std::vector< size_t > *const nodeVector) const
Reorders the nodes in the vector according to their hierarchical level.
size_t getTrackID(const size_t &leafID) const
returns the corresponding track ID to a leaf ID on the tree
void insertPartColors(const std::vector< std::vector< WHcoord > > &selectedColors)
insert a set of partitions colors into the tree data in case a set of saved partitions is already pre...
WHcoord getMeanCoordinate4node(const size_t nodeID) const
Returns the mean coordinate of all the seed voxel coordinates contained in that cluster.
WHnode * fetchRoot()
returns a pointer to the root node
void sortBySize(std::vector< size_t > *const nodeVector) const
Reorders the nodes in the vector according to their size.
bool isLoaded() const
Returns the loading status of the tree.
std::vector< float > getSelectedValues() const
Returns the cutting values for the selected partitions.
float m_logFactor
logarithmic normalization factor used in the tractograms when building the tree
size_t m_numStreamlines
number of streamlines generated form each seed voxel in the tractograms used to build the tree
std::string getName() const
Returns the tree name.
void forceMonotonicity(double errorMult=1)
eliminates non monotonic steps in the tree while keeping as much information as possible.
std::vector< size_t > getTrackids() const
Returns the tractogram IDs vector.
std::string m_treeName
Stores the name of the tree file.
bool testRootBaseNodes() const
tests if all base nodes have only leaf children
bool writeTree(const std::string &filename, const bool isNifti=true) const
writes the current tree data
std::vector< nodeID_t > getRoute2Root(const nodeID_t &nodeID) const
node route to root node
bool check() const
checks tree integrity
HC_GRID m_datasetGrid
Stores the the type of coordinate grid of the dataset.
std::vector< size_t > m_trackids
Stores the ids of the seed tracts correesponding to each leaf.
WHcoord getDataSize() const
Returns the dataset size.
bool convert2grid(const HC_GRID newGrid)
converts all the coordinates to the grid format indicated
std::vector< size_t > getBranchNodes(const size_t nodeID) const
Returns a vector with all the node IDs contained in that branch.
float getCpcc() const
Returns the cpcc value of the tree.
WHcoord getCoordinate4leaf(const size_t leafID) const
the coordinates of a particular leaf
std::vector< WHnode > getLeaves() const
Returns the leaves of the tree.
bool readTree(const std::string &filename)
Reads the the tree data from a file and creates the structure, containing it in the leaves,...
WHnode * fetchLeaf(const size_t thisLeaf)
returns a pointer to the leaf indicated by the ID
std::vector< std::vector< WHcoord > > getSelectedColors() const
Returns the set of the selected partition colors.
std::vector< float > m_selectedValues
Stores the quality values of the selected partitions.
friend class treeManager
friend class
size_t getNumLeaves() const
Returns the number of leaves of the tree.
std::list< WHcoord > m_discarded
Stores the coordinates of the voxels that were discarded during the process of building the tree.
std::vector< WHcoord > getRoi() const
Returns the roi coordinate vector.
std::vector< std::vector< unsigned int > > getBranching(const std::vector< nodeID_t > &thisPartition, size_t depthLevel, std::vector< std::vector< nodeID_t > > *partitionSet, const bool excludeLeaves)
gets all possble sets of sub-partitions in a tree given an initial partition and a depth level (where...
void forceMonotonicityUp()
eliminates non monotonic steps in the tree bottom-up, lowering the level of children involved in the ...
implements a compare operator for nodes, depending on the hierarchical level
bool operator()(const size_t lhs, const size_t rhs) const
the comparison operator result when using size_t types
bool operator()(const nodeID_t &lhs, const nodeID_t &rhs) const
the comparison operator result when using nodeID_t types
compHLevel(const WHtree *const tree)
structure constructor, stores the tree pointer into the data member
const WHtree *const m_tree
stores pointer to tree we work on
implements a compare operator for nodes inside a tree structure, depending on the Size
bool operator()(const size_t lhs, const size_t rhs) const
the comparison operator result when using size_t types
bool operator()(const nodeID_t &lhs, const nodeID_t &rhs) const
the comparison operator result when using nodeID_t types
compSize(const WHtree *const tree)
structure constructor, stores the tree pointer into the data member
const WHtree *const m_tree
stores pointer to tree we work on