64 WHcoord::WHcoord( coord_t x_init, coord_t y_init, coord_t z_init ): m_x( x_init ), m_y( y_init ), m_z( z_init )
85 return sqrt( ( xdif*xdif )+( ydif*ydif )+( zdif*zdif ) );
93 std::vector<WHcoord> physNeighbours;
130 std::cerr <<
"ERROR @ coordinate::getPhysNbs(): Unrecognized nbhood level: " << nbLevel << std::endl;
131 return physNeighbours;
135 for( coord_t i = -range; i <= range ; ++i )
137 for( coord_t j = -range; j <= range ; ++j )
139 for( coord_t k = -range; k <= range ; ++k )
141 const int test( std::abs( i ) + std::abs( j ) + std::abs( k ) );
146 else if( test > condition )
156 if( ( temp.
m_z < 0 ) || ( temp.
m_y < 0 ) || ( temp.
m_x < 0 ) || ( temp.
m_z > dataSize.
m_z ) ||
157 ( temp.
m_y > dataSize.
m_y ) ||( temp.
m_x > dataSize.
m_x ) )
161 physNeighbours.push_back( temp );
170 for( coord_t i =- 2; i <= 2; i += 2 )
172 for( coord_t j =- 2; j <= 2; j += 2 )
174 for( coord_t k =- 2; k <= 2; k += 2 )
176 const int test( std::abs( i ) + std::abs( j ) + std::abs( k ) );
187 if( ( temp.
m_z < 0 ) || ( temp.
m_y < 0 ) || ( temp.
m_x < 0 ) || ( temp.
m_z > dataSize.
m_z ) ||
188 ( temp.
m_y > dataSize.
m_y ) || ( temp.
m_x > dataSize.
m_x ) )
192 physNeighbours.push_back( temp );
199 std::sort( physNeighbours.begin(), physNeighbours.end() );
200 return physNeighbours;
207 std::stringstream stream;
209 stream <<
m_x <<
"_" <<
m_y <<
"_" <<
m_z;
218 returnVista.
m_x = this->
m_x;
219 returnVista.
m_y = ( dataSize.
m_y-1 )-this->
m_y;
220 returnVista.
m_z = ( dataSize.
m_z-1 )-this->
m_z;
227 returnVista.
m_x = this->
m_x+( ( dataSize.
m_x-1.0 )/2.0 );
228 returnVista.
m_y = ( ( dataSize.
m_y-1.0 )/2.0 )-this->
m_y;
229 returnVista.
m_z = ( ( dataSize.
m_z-1.0 )/2.0 )-this->
m_z;
236 returnNifti.
m_x = this->
m_x;
237 returnNifti.
m_y = ( dataSize.
m_y-1 )-this->
m_y;
238 returnNifti.
m_z = ( dataSize.
m_z-1 )-this->
m_z;
262 std::ostream& operator <<( std::ostream& os,
const WHcoord&
object )
264 os << boost::format(
"%03d %03d %03d" ) %
object.m_x %
object.m_y %
object.m_z;
275 else if( lhs.
m_z > rhs.
m_z )
279 else if( lhs.
m_y < rhs.
m_y )
283 else if( lhs.
m_y > rhs.
m_y )
287 else if( lhs.
m_x < rhs.
m_x )
291 else if( lhs.
m_x > rhs.
m_x )
319 return !( lhs == rhs );
322 std::string getGridString(
const HC_GRID gridType )
324 if( gridType == HC_VISTA )
328 else if( gridType == HC_NIFTI )
332 else if( gridType == HC_SURF )
338 std::string emptyString;
this class to contain a seed voxel coordinate.
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,...
WHcoord surf2vista(const WHcoord dataSize) const
transform coordinates to vista format
WHcoord nifti2vista(const WHcoord dataSize) const
transform coordinates to vista format
float getPhysDist(const WHcoord voxel) const
returns the euclidean distance between this voxel and the input voxel
std::string getNameString() const
returns a string with the coordinates of the voxel in the form "xxx_yyy_zzz"
WHcoord & operator=(const WHcoord &rhs)
= member operator
WHcoord vista2nifti(const WHcoord dataSize) const
transform coordinates to vista format