32 #include "WHierarchicalTreeFibers.h"
55 std::pair<size_t, size_t>tmp2;
58 m_colors.push_back( WColor( 0.3, 0.3, 0.3, 1.0 ) );
74 m_colors.push_back( WColor( 0.3, 0.3, 0.3, 1.0 ) );
76 std::pair<size_t, size_t>childs( cluster1, cluster2 );
87 boost::shared_ptr< std::vector< bool > > bf;
91 bf = boost::shared_ptr< std::vector< bool > >(
new std::vector< bool >(
m_leafCount, false ) );
92 ( *bf )[cluster] =
true;
101 bf = boost::shared_ptr< std::vector< bool > >(
new std::vector< bool >(
m_leafCount, false ) );
104 for(
size_t i = 0; i < fibers.size(); ++i )
106 ( *bf )[fibers[i]] =
true;
116 boost::shared_ptr< std::vector< bool > > bf;
119 bf = boost::shared_ptr< std::vector< bool > >(
new std::vector< bool >(
m_leafCount, false ) );
121 for(
size_t k = 0; k < clusters.size(); ++k )
123 size_t cluster = clusters[k];
125 for(
size_t i = 0; i < fibers.size(); ++i )
127 ( *bf )[fibers[i]] =
true;
139 std::list<size_t>candidateList;
141 std::queue<size_t>worklist;
144 while( !worklist.empty() )
146 size_t current = worklist.front();
151 candidateList.push_back( current );
157 std::pair<size_t, size_t> children =
getChildren( current );
158 if(
getLevel( children.first ) > 0 )
160 worklist.push( children.first );
162 if(
getLevel( children.second ) > 0 )
164 worklist.push( children.second );
169 candidateList.sort(
compSize(
this ) );
171 std::vector<size_t>returnList;
173 std::list<size_t>::iterator it;
174 for( it = candidateList.begin(); it != candidateList.end(); ++it )
176 size_t current = *it;
177 returnList.push_back( current );
193 size_t countFibersInCluster = fibersInCluster.size();
194 size_t fibersFromClusterActive = 0;
196 for(
size_t i = 0; i < countFibersInCluster; ++i )
200 ++fibersFromClusterActive;
203 return static_cast<float>( fibersFromClusterActive ) / static_cast<float>( countFibersInCluster );
size_t m_maxLevel
the maximum level, naturally the level of the root node
size_t m_leafCount
number of leaf nodes
implements a compare operator for clusters, depending on leaf count
std::vector< size_t > getBestClustersFittingRoi(float ratio=0.9, size_t number=1)
finds clusters that match a given ROI up to a certain percentage
~WHierarchicalTreeFibers()
destructor
std::pair< size_t, size_t > getChildren(size_t cluster)
getter
std::vector< std::vector< size_t > > m_containsLeafes
vector that stores the leaf id's for each cluster, this is quite memory intensive but speeds up selec...
std::vector< float > m_customData
custom data for each cluster, this may some energy or similarity level generated by the clustering al...
std::vector< std::pair< size_t, size_t > > m_children
vector that stores the 2 children of each cluster, contains an empty pair for leafes ...
bool m_leafesLocked
to enforce valid datastructures there will be no leaf with an id higher than a cluster, thus when the first cluster is inserted, no leafes may be added
std::vector< size_t > m_level
vector that stores the level of each cluster, the level is the maximum of the levels of the child clu...
std::vector< size_t > m_parents
vector that stores the parent cluster for each cluster
base class for hierarchical tree implementations
WHierarchicalTreeFibers()
standard constructor
boost::shared_ptr< std::vector< bool > > getOutputBitfield(size_t cluster)
generates a bitfield where for every leaf in the selected cluster the value is true, false otherwise
size_t m_clusterCount
overall number of cluster, counts both leafes ( clusters of size one ) and real clusters ...
float getRatio(size_t cluster)
calculates the ratio of fibers in the roi for a given cluster
void addCluster(size_t cluster1, size_t cluster2, size_t level, std::vector< size_t > leafes, float customData)
adds a cluster to the set, it combines 2 already existing clusters
size_t getClusterCount()
getter
boost::shared_ptr< std::vector< bool > > m_roiSelection
stores a pointer to the bitfield by the current roi setting
void addLeaf()
A leaf is at the very bottom of the tree, it represents a single fiber or voxel, for several purposes...
std::vector< WColor > m_colors
a color value for each cluster
size_t getLevel(size_t cluster)
getter