OpenWalnut
1.4.0
|
00001 //--------------------------------------------------------------------------- 00002 // 00003 // Project: OpenWalnut ( http://www.openwalnut.org ) 00004 // 00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS 00006 // For more information see http://www.openwalnut.org/copying 00007 // 00008 // This file is part of OpenWalnut. 00009 // 00010 // OpenWalnut is free software: you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as published by 00012 // the Free Software Foundation, either version 3 of the License, or 00013 // (at your option) any later version. 00014 // 00015 // OpenWalnut is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 // GNU Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public License 00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>. 00022 // 00023 //--------------------------------------------------------------------------- 00024 00025 #ifndef WHIERARCHICALTREEFIBERS_H 00026 #define WHIERARCHICALTREEFIBERS_H 00027 00028 #include <utility> 00029 #include <vector> 00030 #include <queue> 00031 #include <list> 00032 00033 #include <boost/shared_ptr.hpp> 00034 00035 #include "WColor.h" 00036 00037 #include "WHierarchicalTree.h" 00038 00039 00040 /** 00041 * Class implements a hierarchical tree and provides helper functions for selection and navigation 00042 */ 00043 class WHierarchicalTreeFibers : public WHierarchicalTree 00044 { 00045 public: 00046 /** 00047 * standard constructor 00048 */ 00049 WHierarchicalTreeFibers(); 00050 00051 /** 00052 * destructor 00053 */ 00054 ~WHierarchicalTreeFibers(); 00055 00056 /** 00057 * A leaf is at the very bottom of the tree, it represents a single fiber or voxel, for several purposes 00058 * a leaf also counts as a cluster 00059 */ 00060 void addLeaf(); 00061 00062 /** 00063 * adds a cluster to the set, it combines 2 already existing clusters 00064 * 00065 * \param cluster1 first cluster to add 00066 * \param cluster2 second cluster to add 00067 * \param level level of the new cluster 00068 * \param leafes vector of leafes the new cluster contains 00069 * \param customData some arbitrary data stored with the cluster 00070 */ 00071 void addCluster( size_t cluster1, size_t cluster2, size_t level, std::vector<size_t> leafes, float customData ); 00072 00073 /** 00074 * generates a bitfield where for every leaf in the selected cluster the value is true, false otherwise 00075 * 00076 * \param cluster 00077 * \return shared pointer to the bitfield 00078 */ 00079 boost::shared_ptr< std::vector<bool> >getOutputBitfield( size_t cluster ); 00080 00081 /** 00082 * generates a bitfield where for every leaf in the selected cluster the value is true, false otherwise 00083 * 00084 * \param clusters 00085 * \return shared pointer to the bitfield 00086 */ 00087 boost::shared_ptr< std::vector<bool> >getOutputBitfield( std::vector<size_t>clusters ); 00088 00089 /** 00090 * finds clusters that match a given ROI up to a certain percentage 00091 * 00092 * \param ratio value of [0,1] of how many leafs have to be in the ROI to activate the cluster 00093 * \param number number of clusters to select, if more than given number matches the ratio criterion only the 00094 * biggest clusters are returned 00095 * 00096 * \return The indices of the chosen clusters. 00097 */ 00098 std::vector<size_t> getBestClustersFittingRoi( float ratio = 0.9, size_t number = 1 ); 00099 00100 /** 00101 * calculates the ratio of fibers in the roi for a given cluster 00102 * \param cluster 00103 * \return ratio 00104 */ 00105 float getRatio( size_t cluster ); 00106 00107 /** 00108 * setter 00109 * \param bitfield 00110 */ 00111 void setRoiBitField( boost::shared_ptr< std::vector<bool> > bitfield ); 00112 00113 protected: 00114 private: 00115 /** 00116 * stores a pointer to the bitfield by the current roi setting 00117 */ 00118 boost::shared_ptr< std::vector<bool> > m_roiSelection; 00119 }; 00120 00121 00122 inline void WHierarchicalTreeFibers::setRoiBitField( boost::shared_ptr< std::vector<bool> > bitfield ) 00123 { 00124 m_roiSelection = bitfield; 00125 } 00126 00127 #endif // WHIERARCHICALTREEFIBERS_H