aimsalgo  5.1.2
Neuroimaging image processing
talVolume.h
Go to the documentation of this file.
1 /* This software and supporting documentation are distributed by
2  * Institut Federatif de Recherche 49
3  * CEA/NeuroSpin, Batiment 145,
4  * 91191 Gif-sur-Yvette cedex
5  * France
6  *
7  * This software is governed by the CeCILL-B license under
8  * French law and abiding by the rules of distribution of free software.
9  * You can use, modify and/or redistribute the software under the
10  * terms of the CeCILL-B license as circulated by CEA, CNRS
11  * and INRIA at the following URL "http://www.cecill.info".
12  *
13  * As a counterpart to the access to the source code and rights to copy,
14  * modify and redistribute granted by the license, users are provided only
15  * with a limited warranty and the software's author, the holder of the
16  * economic rights, and the successive licensors have only limited
17  * liability.
18  *
19  * In this respect, the user's attention is drawn to the risks associated
20  * with loading, using, modifying and/or developing or reproducing the
21  * software by the user in light of its specific status of free software,
22  * that may mean that it is complicated to manipulate, and that also
23  * therefore means that it is reserved for developers and experienced
24  * professionals having in-depth computer knowledge. Users are therefore
25  * encouraged to load and test the software's suitability as regards their
26  * requirements in conditions enabling the security of their systems and/or
27  * data to be ensured and, more generally, to use and operate it in the
28  * same conditions as regards security.
29  *
30  * The fact that you are presently reading this means that you have had
31  * knowledge of the CeCILL-B license and that you accept its terms.
32  */
33 
34 
35 #ifndef AIMS_TALAIRACH_TALVOLUME_H
36 #define AIMS_TALAIRACH_TALVOLUME_H
37 
40 
41 
42 template< class T >
44 {
45 public:
46 
47  TalairachVolume( int dx=157, int dy=189, int dz=136, int cx=78, int cy=76,
48  int dz=85 );
49  virtual ~Talairach() { }
50 
51  carto::VolumeRef< T >& volume() { return m_d; }
52 
53  Point3df toVolume( const TalairachBoxBase&, const Point3df& );
54  Point3df fromVolume( const TalairachBoxBase&, const Point3df& );
55 
58 
59 private:
60 
61  Point3df _scale;
62  Point3df _translation;
63 
65 };
66 
67 
68 template< class T > inline
69 void TalairachVolume< T >::TalairachVolume( int dx, int dy, int dz,
70  int cx, int cy, int cz )
71 {
72  m_d = carto::VolumeRef< T >( dx, dy, dz );
73  m_d.setVoxelSize( 1.0f, 1.0f, 1.0f );
74 
75  _translation = Point3df( (float)cx, -(float)cy, -(float)cz );
76 
77  int cdx = ( dx - cx - 1 > cx ) ? dx - cx - 1 : cx;
78  _scale = Point3df( (float)cdx, (float)( dy - cy - 1 ), (float)cz );
79 }
80 
81 
82 template< class T > inline
84  const Point3df& pt )
85 {
86  Point3df res = tb.toTalairach( pt );
87 
88  for ( int i=0; i<3; i++ )
89  res[ i ] = res[ i ] * _scale[ i ] + _translation[ i ];
90 
91  return res;
92 }
93 
94 
95 template< class T > inline
97  const Point3df& pt )
98 {
99  Point3df res;
100 
101  for ( int i=0; i<3; i++ )
102  res[ i ] = ( pt[ i ] - _translation[ i ] ) / _scale[ i ];
103 
104  return tb.fromTalairach( res );
105 }
106 
107 
108 template< class T > inline
111 {
112  int i, j, k;
113  int dx = m_d.getSizeX();
114  int dy = m_d.getSizeY();
115  int dz = m_d.getSizeZ();
116 
117  Point3df pt, npt;
118  Point3df r( 0.5f, 0.5f, 0.5f );
119 
120  for ( k=0; k<dz; k++ )
121  for ( j=0; j<dy; j++ )
122  for ( i=0; i<dx; i++ )
123  {
124  pt = Point3df( (float)i, (float)j, (float)k );
125  npt = fromVolume( pt ) + r;
126  m_d( i, j, k ) = d->at( (int)npt[ 0 ], (int)npt[ 1 ], (int)npt[ 2 ] );
127  }
128 }
129 
130 
131 #endif
Point3df fromTalairach(const Point3df &)
Point3df toTalairach(const Point3df &)
carto::VolumeRef< T > & volume()
Definition: talVolume.h:51
virtual ~Talairach()
Definition: talVolume.h:49
Point3df fromVolume(const TalairachBoxBase &, const Point3df &)
Definition: talVolume.h:96
Point3df toVolume(const TalairachBoxBase &, const Point3df &)
Definition: talVolume.h:83
carto::VolumeRef< T > & create(const TalairachBoxBase &, const carto::rc_ptr< carto::Volume< T > > &)
Definition: talVolume.h:109
TalairachVolume(int dx=157, int dy=189, int dz=136, int cx=78, int cy=76, int dz=85)
Definition: talVolume.h:69
int getSizeX() const