A.I.M.S algorithms


talBox.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_TALBOX_H
36 #define AIMS_TALAIRACH_TALBOX_H
37 
38 #include <cstdlib>
39 #include <aims/data/data.h>
41 
42 
43 template< class T >
45 {
46 public:
48  inline virtual ~TalairachBox() {}
49  void computeBox( const AimsData< T >& );
51  const AimsData< T >& );
52 
53  // Returns a motion from current subject to a normalized template, where
54  // AC (0, 0, 0) PC (0, 1, 0) and IHP (0, 1, cout0)
55 };
56 
57 
58 template< class T > inline
60 {
61  int x, y, z, dx = d.dimX(), dy = d.dimY(), dz = d.dimZ();
62  Point3df dsize( d.sizeX(), d.sizeY(), d.sizeZ() );
63  Point3df boxmax( -10000.0f, -10000.0f, -10000.0f );
64  Point3df boxmin( 10000.0f, 10000.0f, 10000.0f );
65  Point3df pt, npt;
66 
67  for ( z=0; z<dz; z++ )
68  for ( y=0; y<dy; y++ )
69  for ( x=0; x<dx; x++ )
70  if ( d( x, y, z ) )
71  {
72  pt = Point3df( float( x ), float( y ), float( z ) );
73  pt[ 0 ] *= dsize[ 0 ];
74  pt[ 1 ] *= dsize[ 1 ];
75  pt[ 2 ] *= dsize[ 2 ];
77 
78  if ( npt[ 0 ] < boxmin[ 0 ] ) boxmin[ 0 ] = npt[ 0 ];
79  if ( npt[ 1 ] < boxmin[ 1 ] ) boxmin[ 1 ] = npt[ 1 ];
80  if ( npt[ 2 ] < boxmin[ 2 ] ) boxmin[ 2 ] = npt[ 2 ];
81  if ( npt[ 0 ] > boxmax[ 0 ] ) boxmax[ 0 ] = npt[ 0 ];
82  if ( npt[ 1 ] > boxmax[ 1 ] ) boxmax[ 1 ] = npt[ 1 ];
83  if ( npt[ 2 ] > boxmax[ 2 ] ) boxmax[ 2 ] = npt[ 2 ];
84  }
85 
86  if ( fabs( boxmin[ 0 ] ) > fabs( boxmax[ 0 ] ) )
87  _scale[ 0 ] = 1.0f / fabs( boxmin[ 0 ] );
88  else _scale[ 0 ] = 1.0f / fabs( boxmax[ 0 ] );
89 
90  std::cout << "Box Min : " << boxmin << "\tBox Max :" << boxmax << std::endl ;
91  _scale[ 1 ] = 1.0f / fabs( boxmax[ 1 ] );
92  // On peut ausi prendre
93  // _scale[ 1 ] = 1.0f/_ACPCVec.norm()
94  _scale[ 2 ] = 1.0f / fabs( boxmin[ 2 ] );
95 }
96 
97 
98 template< class T > inline
100  const AimsData< T >& d )
101 {
102  computeTransformation( pt );
103  computeBox( d );
104 
105  AimsData<float> rotation(3, 3) ;
106  Point3df translation = -pt.ACmm() ;
107 
108  rotation(0, 0) = -_crossVec[ 0 ];
109  rotation(0, 1) = -_crossVec[ 1 ];
110  rotation(0, 2) = -_crossVec[ 2 ];
111 
112  rotation(1, 0) = _ACPCVec[ 0 ];
113  rotation(1, 1) = _ACPCVec[ 1 ];
114  rotation(1, 2) = _ACPCVec[ 2 ];
115 
116  rotation(2, 0) = _hemiVec[ 0 ];
117  rotation(2, 1) = _hemiVec[ 1 ];
118  rotation(2, 2) = _hemiVec[ 2 ];
119 
120  _transformation.translation() = Point3df(0., 0., 0.) ;
121  _transformation.rotation() = rotation ;
122 
123  std::cout << "Scale : " << _scale << std::endl ;
124  _transformation.scale( Point3df(1., 1., 1. ),
125  Point3df(1.0f/_scale[0], 1.0f/_scale[1], 1.0f/_scale[2] ) ) ;
126  _transformation.translation() = _transformation.transform(translation) ;
127  return _transformation ;
128 }
129 
130 #endif
int dimX() const
float sizeY() const
Motion computeTransformationAndBox(const TalairachPoints &, const AimsData< T > &)
Definition: talBox.h:99
virtual ~TalairachBox()
Definition: talBox.h:48
void computeBox(const AimsData< T > &)
Definition: talBox.h:59
Point3df & ACmm()
Definition: talPoints.h:67
float sizeZ() const
Point3df toTalairach(const Point3df &)
float sizeX() const
int dimZ() const
int dimY() const
TalairachBox()
Definition: talBox.h:47