OpenWalnut  1.4.0
WHierarchicalTreeFibers.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WHIERARCHICALTREEFIBERS_H
26 #define WHIERARCHICALTREEFIBERS_H
27 
28 #include <utility>
29 #include <vector>
30 #include <queue>
31 #include <list>
32 
33 #ifndef Q_MOC_RUN
34 #include <boost/shared_ptr.hpp>
35 #endif
36 
37 #include "WColor.h"
38 
39 #include "WHierarchicalTree.h"
40 
41 
42 /**
43  * Class implements a hierarchical tree and provides helper functions for selection and navigation
44  */
46 {
47 public:
48  /**
49  * standard constructor
50  */
52 
53  /**
54  * destructor
55  */
57 
58  /**
59  * A leaf is at the very bottom of the tree, it represents a single fiber or voxel, for several purposes
60  * a leaf also counts as a cluster
61  */
62  void addLeaf();
63 
64  /**
65  * adds a cluster to the set, it combines 2 already existing clusters
66  *
67  * \param cluster1 first cluster to add
68  * \param cluster2 second cluster to add
69  * \param level level of the new cluster
70  * \param leafes vector of leafes the new cluster contains
71  * \param customData some arbitrary data stored with the cluster
72  */
73  void addCluster( size_t cluster1, size_t cluster2, size_t level, std::vector<size_t> leafes, float customData );
74 
75  /**
76  * generates a bitfield where for every leaf in the selected cluster the value is true, false otherwise
77  *
78  * \param cluster
79  * \return shared pointer to the bitfield
80  */
81  boost::shared_ptr< std::vector<bool> >getOutputBitfield( size_t cluster );
82 
83  /**
84  * generates a bitfield where for every leaf in the selected cluster the value is true, false otherwise
85  *
86  * \param clusters
87  * \return shared pointer to the bitfield
88  */
89  boost::shared_ptr< std::vector<bool> >getOutputBitfield( std::vector<size_t>clusters );
90 
91  /**
92  * finds clusters that match a given ROI up to a certain percentage
93  *
94  * \param ratio value of [0,1] of how many leafs have to be in the ROI to activate the cluster
95  * \param number number of clusters to select, if more than given number matches the ratio criterion only the
96  * biggest clusters are returned
97  *
98  * \return The indices of the chosen clusters.
99  */
100  std::vector<size_t> getBestClustersFittingRoi( float ratio = 0.9, size_t number = 1 );
101 
102  /**
103  * calculates the ratio of fibers in the roi for a given cluster
104  * \param cluster
105  * \return ratio
106  */
107  float getRatio( size_t cluster );
108 
109  /**
110  * setter
111  * \param bitfield
112  */
113  void setRoiBitField( boost::shared_ptr< std::vector<bool> > bitfield );
114 
115 protected:
116 private:
117  /**
118  * stores a pointer to the bitfield by the current roi setting
119  */
120  boost::shared_ptr< std::vector<bool> > m_roiSelection;
121 };
122 
123 
124 inline void WHierarchicalTreeFibers::setRoiBitField( boost::shared_ptr< std::vector<bool> > bitfield )
125 {
126  m_roiSelection = bitfield;
127 }
128 
129 #endif // WHIERARCHICALTREEFIBERS_H
void setRoiBitField(boost::shared_ptr< std::vector< bool > > bitfield)
setter
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
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
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
Class implements a hierarchical tree and provides helper functions for selection and navigation...
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...