aimsalgo  5.0.5
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 
38 #include <aims/data/data.h>
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  AimsData< T >& volume() { return m_d; }
52 
53  Point3df toVolume( const TalairachBoxBase&, const Point3df& );
54  Point3df fromVolume( const TalairachBoxBase&, const Point3df& );
55 
57 
58 private:
59 
60  Point3df _scale;
61  Point3df _translation;
62 
63  AimsData< T > m_d;
64 };
65 
66 
67 template< class T > inline
68 void TalairachVolume< T >::TalairachVolume( int dx, int dy, int dz,
69  int cx, int cy, int cz )
70 {
71  m_d = AimsData< T >( dx, dy, dz );
72  m_d.setXYZT( 1.0f, 1.0f, 1.0f );
73 
74  _translation = Point3df( (float)cx, -(float)cy, -(float)cz );
75 
76  int cdx = ( dx - cx - 1 > cx ) ? dx - cx - 1 : cx;
77  _scale = Point3df( (float)cdx, (float)( dy - cy - 1 ), (float)cz );
78 }
79 
80 
81 template< class T > inline
83  const Point3df& pt )
84 {
85  Point3df res = tb.toTalairach( pt );
86 
87  for ( int i=0; i<3; i++ )
88  res[ i ] = res[ i ] * _scale[ i ] + _translation[ i ];
89 
90  return res;
91 }
92 
93 
94 template< class T > inline
96  const Point3df& pt )
97 {
98  Point3df res;
99 
100  for ( int i=0; i<3; i++ )
101  res[ i ] = ( pt[ i ] - _translation[ i ] ) / _scale[ i ];
102 
103  return tb.fromTalairach( res );
104 }
105 
106 
107 template< class T > inline
109  AimsData< T >& d )
110 {
111  int i, j, k;
112  int dx = m_d.dimX();
113  int dy = m_d.dimY();
114  int dz = m_d.dimZ();
115 
116  Point3df pt, npt;
117  Point3df r( 0.5f, 0.5f, 0.5f );
118 
119  for ( k=0; k<dz; k++ )
120  for ( j=0; j<dy; j++ )
121  for ( i=0; i<dx; i++ )
122  {
123  pt = Point3df( (float)i, (float)j, (float)k );
124  npt = fromVolume( pt ) + r;
125  m_d( i, j, k ) = d( (int)npt[ 0 ], (int)npt[ 1 ], (int)npt[ 2 ] );
126  }
127 }
128 
129 
130 #endif
Point3df toVolume(const TalairachBoxBase &, const Point3df &)
Definition: talVolume.h:82
AimsData< T > & create(const TalairachBoxBase &, const AimsData< T > &)
Definition: talVolume.h:108
virtual ~Talairach()
Definition: talVolume.h:49
AimsData< T > & volume()
Definition: talVolume.h:51
Point3df toTalairach(const Point3df &)
Point3df fromTalairach(const Point3df &)
TalairachVolume(int dx=157, int dy=189, int dz=136, int cx=78, int cy=76, int dz=85)
Definition: talVolume.h:68
Point3df fromVolume(const TalairachBoxBase &, const Point3df &)
Definition: talVolume.h:95