OpenWalnut  1.5.0dev
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 <list>
29 #include <memory>
30 #include <queue>
31 #include <utility>
32 #include <vector>
33 
34 
35 #include "WColor.h"
36 #include "WHierarchicalTree.h"
37 
38 
39 /**
40  * Class implements a hierarchical tree and provides helper functions for selection and navigation
41  */
43 {
44 public:
45  /**
46  * standard constructor
47  */
49 
50  /**
51  * destructor
52  */
54 
55  /**
56  * A leaf is at the very bottom of the tree, it represents a single fiber or voxel, for several purposes
57  * a leaf also counts as a cluster
58  */
59  void addLeaf();
60 
61  /**
62  * adds a cluster to the set, it combines 2 already existing clusters
63  *
64  * \param cluster1 first cluster to add
65  * \param cluster2 second cluster to add
66  * \param level level of the new cluster
67  * \param leafes vector of leafes the new cluster contains
68  * \param customData some arbitrary data stored with the cluster
69  */
70  void addCluster( size_t cluster1, size_t cluster2, size_t level, std::vector<size_t> leafes, float customData );
71 
72  /**
73  * generates a bitfield where for every leaf in the selected cluster the value is true, false otherwise
74  *
75  * \param cluster
76  * \return shared pointer to the bitfield
77  */
78  std::shared_ptr< std::vector<bool> >getOutputBitfield( size_t cluster );
79 
80  /**
81  * generates a bitfield where for every leaf in the selected cluster the value is true, false otherwise
82  *
83  * \param clusters
84  * \return shared pointer to the bitfield
85  */
86  std::shared_ptr< std::vector<bool> >getOutputBitfield( std::vector<size_t>clusters );
87 
88  /**
89  * finds clusters that match a given ROI up to a certain percentage
90  *
91  * \param ratio value of [0,1] of how many leafs have to be in the ROI to activate the cluster
92  * \param number number of clusters to select, if more than given number matches the ratio criterion only the
93  * biggest clusters are returned
94  *
95  * \return The indices of the chosen clusters.
96  */
97  std::vector<size_t> getBestClustersFittingRoi( float ratio = 0.9, size_t number = 1 );
98 
99  /**
100  * calculates the ratio of fibers in the roi for a given cluster
101  * \param cluster
102  * \return ratio
103  */
104  float getRatio( size_t cluster );
105 
106  /**
107  * setter
108  * \param bitfield
109  */
110  void setRoiBitField( std::shared_ptr< std::vector<bool> > bitfield );
111 
112 protected:
113 private:
114  /**
115  * stores a pointer to the bitfield by the current roi setting
116  */
117  std::shared_ptr< std::vector<bool> > m_roiSelection;
118 };
119 
120 
121 inline void WHierarchicalTreeFibers::setRoiBitField( std::shared_ptr< std::vector<bool> > bitfield )
122 {
123  m_roiSelection = bitfield;
124 }
125 
126 #endif // WHIERARCHICALTREEFIBERS_H
Class implements a hierarchical tree and provides helper functions for selection and navigation.
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
std::shared_ptr< std::vector< bool > > m_roiSelection
stores a pointer to the bitfield by the current roi setting
std::shared_ptr< std::vector< bool > > getOutputBitfield(size_t cluster)
generates a bitfield where for every leaf in the selected cluster the value is true,...
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()
standard constructor
void setRoiBitField(std::shared_ptr< std::vector< bool > > bitfield)
setter
void addLeaf()
A leaf is at the very bottom of the tree, it represents a single fiber or voxel, for several purposes...
float getRatio(size_t cluster)
calculates the ratio of fibers in the roi for a given cluster
base class for hierarchical tree implementations