OpenWalnut  1.5.0dev
WHcoord.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 //---------------------------------------------------------------------------
26 //
27 // Project: hClustering
28 //
29 // Whole-Brain Connectivity-Based Hierarchical Parcellation Project
30 // David Moreno-Dominguez
31 // d.mor.dom@gmail.com
32 // moreno@cbs.mpg.de
33 // www.cbs.mpg.de/~moreno//
34 // This file is also part of OpenWalnut ( http://www.openwalnut.org ).
35 //
36 // hClustering is free software: you can redistribute it and/or modify
37 // it under the terms of the GNU Lesser General Public License as published by
38 // the Free Software Foundation, either version 3 of the License, or
39 // (at your option) any later version.
40 // http://creativecommons.org/licenses/by-nc/3.0
41 //
42 // hClustering is distributed in the hope that it will be useful,
43 // but WITHOUT ANY WARRANTY; without even the implied warranty of
44 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45 // GNU Lesser General Public License for more details.
46 //
47 //---------------------------------------------------------------------------
48 
49 #ifndef WHCOORD_H
50 #define WHCOORD_H
51 
52 // std library
53 #include <iostream>
54 #include <string>
55 #include <sstream>
56 #include <vector>
57 #include <cmath>
58 
59 // boost library
60 #include <boost/format.hpp>
61 
62 // typedefs
63 //typedef int16_t coord_t;
64 typedef float coord_t;
65 typedef enum
66 {
67  HC_VISTA,
68  HC_NIFTI,
69  HC_SURF
70 } HC_GRID;
71 
72 /**
73  * this class to contain a seed voxel coordinate. consisting on x,y,z also implements coordinate gird changes and physical neighbor search
74  */
75 class WHcoord
76 {
77 public:
78  /**
79  * Constructor
80  */
81  WHcoord();
82 
83  /**
84  * Constructor
85  * \param x_init x coordinate initializer
86  * \param y_init y coordinate initializer
87  * \param z_init z coordinate initializer
88  */
89  WHcoord( coord_t x_init, coord_t y_init, coord_t z_init );
90 
91  /**
92  * Constructor
93  * \param object coordinate initializer
94  */
95  WHcoord( const WHcoord &object );
96 
97  /**
98  * Destructor
99  */
100  ~WHcoord();
101 
102  /**
103  * = member operator
104  * \param rhs object to copy
105  * \return reference to copied object
106  */
107  WHcoord& operator =( const WHcoord &rhs );
108 
109  // === PUBLIC MEMBER FUNCTIONS ===
110 
111  /**
112  * returns the euclidean distance between this voxel and the input voxel
113  * \param voxel coordinate to calculate distance to
114  * \return euclidean distance value
115  */
116  float getPhysDist( const WHcoord voxel ) const;
117 
118  /**
119  * returns a vector containing the coordinates of the physical neighbours adjacent to the voxel, the neighbourhood level is defined by nb_level
120  * \param dataSize dataset limits
121  * \param nbLevel neighborhood value
122  * \return coordinate vector
123  */
124  std::vector< WHcoord > getPhysNbs( const WHcoord dataSize, const unsigned int nbLevel ) const;
125 
126  /**
127  * returns a string with the coordinates of the voxel in the form "xxx_yyy_zzz"
128  * \return output string
129  */
130  std::string getNameString() const;
131 
132  /**
133  * transform coordinates to vista format
134  * \param dataSize dataset size
135  * \return converted coordinate
136  */
137  WHcoord nifti2vista( const WHcoord dataSize ) const;
138 
139  /**
140  * transform coordinates to vista format
141  * \param dataSize dataset size
142  * \return converted coordinate
143  */
144  WHcoord surf2vista( const WHcoord dataSize ) const;
145 
146  /**
147  * transform coordinates to vista format
148  * \param dataSize dataset size
149  * \return converted coordinate
150  */
151  WHcoord vista2nifti( const WHcoord dataSize ) const;
152  // === PUBLIC DATA MEMBERS ===
153 
154  coord_t m_x; //!< x coordinate
155  coord_t m_y; //!< y coordinate
156  coord_t m_z; //!< z coordinate
157 
158 protected:
159 private:
160 };
161 
162 // === NON-MEMBER OPERATORS ===
163 
164 
165 /**
166  * << operator for the coordinate class
167  * \param os output stream
168  * \param object coordinate to print out
169  * \return ostream with the coordinate information
170  */
171 std::ostream& operator <<( std::ostream& os, const WHcoord& object );
172 
173 /**
174  * < operator for the coordinate class
175  * \param lhs left coordinate operator
176  * \param rhs right coordinate operator
177  * \return result of the inequality
178  */
179 bool operator <( const WHcoord &lhs, const WHcoord &rhs );
180 
181 /**
182  * == operator for the coordinate class
183  * \param lhs left coordinate operator
184  * \param rhs right coordinate operator
185  * \return result of the equality
186  */
187 bool operator ==( const WHcoord &lhs, const WHcoord &rhs );
188 
189 /**
190  * != operator for the coordinate class
191  * \param lhs left coordinate operator
192  * \param rhs right coordinate operator
193  * \return result of the inequality
194  */
195 bool operator !=( const WHcoord &lhs, const WHcoord &rhs );
196 
197 /**
198  * helper function to print a string with the coordinate grid name
199  * \param gridType type of coordinate grid to get the string from
200  * \return identifier string
201  */
202 std::string getGridString( const HC_GRID gridType );
203 
204 #endif // WHCOORD_H
this class to contain a seed voxel coordinate.
Definition: WHcoord.h:76
std::vector< WHcoord > getPhysNbs(const WHcoord dataSize, const unsigned int nbLevel) const
returns a vector containing the coordinates of the physical neighbours adjacent to the voxel,...
Definition: WHcoord.cpp:91
~WHcoord()
Destructor.
Definition: WHcoord.cpp:72
WHcoord surf2vista(const WHcoord dataSize) const
transform coordinates to vista format
Definition: WHcoord.cpp:224
WHcoord nifti2vista(const WHcoord dataSize) const
transform coordinates to vista format
Definition: WHcoord.cpp:215
float getPhysDist(const WHcoord voxel) const
returns the euclidean distance between this voxel and the input voxel
Definition: WHcoord.cpp:82
coord_t m_z
z coordinate
Definition: WHcoord.h:156
std::string getNameString() const
returns a string with the coordinates of the voxel in the form "xxx_yyy_zzz"
Definition: WHcoord.cpp:205
WHcoord()
Constructor.
Definition: WHcoord.cpp:60
WHcoord & operator=(const WHcoord &rhs)
= member operator
Definition: WHcoord.cpp:248
coord_t m_y
y coordinate
Definition: WHcoord.h:155
WHcoord vista2nifti(const WHcoord dataSize) const
transform coordinates to vista format
Definition: WHcoord.cpp:233
coord_t m_x
x coordinate
Definition: WHcoord.h:154