aimsdata  5.0.5
Neuroimaging data handling
flip.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  * Flip data.
36  */
37 #ifndef AIMS_UTILITY_FLIP_H
38 #define AIMS_UTILITY_FLIP_H
39 
41 #include <aims/data/data.h>
42 
43 
48 template <class T>
50 { public:
53  AimsFlip() { }
56  virtual ~AimsFlip() { }
58 
61  inline AimsData<T> doXX( const AimsData<T> &thing );
64  inline AimsData<T> doYY( const AimsData<T> &thing );
66  inline AimsData<T> doZZ( const AimsData<T> &thing );
68  inline AimsData<T> doXXZZ( const AimsData<T> &thing );
70  inline AimsData<T> doXXYY( const AimsData<T> &thing );
72  inline AimsData<T> doYYZZ( const AimsData<T> &thing );
74  inline AimsData<T> doXXYYZZ( const AimsData<T> &thing );
76  inline AimsData<T> doXY( const AimsData<T> &thing );
78  inline AimsData<T> doXZ( const AimsData<T> &thing );
80  inline AimsData<T> doYZ( const AimsData<T> &thing );
82 };
83 
84 
85 template <class T> inline
87 {
88  AimsData<T> res( thing.dimX(), thing.dimY(), thing.dimZ(), thing.dimT(),
89  thing.borderWidth() );
90  if( thing.header() )
91  res.setHeader( thing.header()->cloneHeader() );
92  res.setSizeXYZT( thing );
93 
94  int x, y, z, t;
95  ForEach4d( res, x, y, z, t )
96  res( x, y, z, t ) = thing( thing.dimX() - x - 1, y, z, t );
97 
98  return res;
99 }
100 
101 
102 template <class T> inline
104 {
105  AimsData<T> res( thing.dimX(), thing.dimY(), thing.dimZ(), thing.dimT(),
106  thing.borderWidth() );
107  if( thing.header() )
108  res.setHeader( thing.header()->cloneHeader() );
109  res.setSizeXYZT( thing );
110 
111  int x, y, z, t;
112  ForEach4d( res, x, y, z, t )
113  res( x, y, z, t ) = thing( x, thing.dimY() - y - 1, z, t );
114 
115  return res;
116 }
117 
118 
119 template <class T> inline
121 {
122  AimsData<T> res( thing.dimX(), thing.dimY(), thing.dimZ(), thing.dimT(),
123  thing.borderWidth() );
124  if( thing.header() )
125  res.setHeader( thing.header()->cloneHeader() );
126  res.setSizeXYZT( thing );
127 
128  int x, y, z, t;
129  ForEach4d( res, x, y, z, t )
130  res( x, y, z, t ) = thing( x, y, thing.dimZ() - z - 1, t );
131 
132  return res;
133 }
134 
135 
136 template <class T> inline
138 {
139  AimsData<T> res( thing.dimX(), thing.dimY(), thing.dimZ(), thing.dimT(),
140  thing.borderWidth() );
141  if( thing.header() )
142  res.setHeader( thing.header()->cloneHeader() );
143  res.setSizeXYZT( thing );
144 
145  int x, y, z, t;
146  ForEach4d( res, x, y, z, t )
147  res( x, y, z, t ) = thing(thing.dimX() - x - 1, y,
148  thing.dimZ() - z - 1, t);
149 
150  return res;
151 }
152 
153 template <class T> inline
155 {
156  AimsData<T> res( thing.dimX(), thing.dimY(), thing.dimZ(), thing.dimT(),
157  thing.borderWidth() );
158  if( thing.header() )
159  res.setHeader( thing.header()->cloneHeader() );
160  res.setSizeXYZT( thing );
161 
162  int x, y, z, t;
163  ForEach4d( res, x, y, z, t )
164  res( x, y, z, t ) = thing(thing.dimX() - x - 1, thing.dimY() - y - 1,
165  z, t);
166 
167  return res;
168 }
169 
170 template <class T> inline
172 {
173  AimsData<T> res( thing.dimX(), thing.dimY(), thing.dimZ(), thing.dimT(),
174  thing.borderWidth() );
175  if( thing.header() )
176  res.setHeader( thing.header()->cloneHeader() );
177  res.setSizeXYZT( thing );
178 
179  int x, y, z, t;
180  ForEach4d( res, x, y, z, t )
181  res( x, y, z, t ) = thing(x, thing.dimY() - y - 1,
182  thing.dimZ() - z - 1, t);
183 
184  return res;
185 }
186 
187 
188 template <class T> inline
190 {
191  AimsData<T> res( thing.dimY(), thing.dimX(), thing.dimZ(), thing.dimT(),
192  thing.borderWidth() );
193  if( thing.header() )
194  res.setHeader( thing.header()->cloneHeader() );
195  res.setSizeX( thing.sizeY() );
196  res.setSizeY( thing.sizeX() );
197  res.setSizeZ( thing.sizeZ() );
198  res.setSizeT( thing.sizeT() );
199 
200  int x, y, z, t;
201  ForEach4d( res, x, y, z, t )
202  res( x, y, z, t ) = thing( y, x, z, t );
203 
204  return res;
205 }
206 
207 
208 template <class T> inline
210 {
211  AimsData<T> res( thing.dimZ(), thing.dimY(), thing.dimX(), thing.dimT(),
212  thing.borderWidth() );
213  if( thing.header() )
214  res.setHeader( thing.header()->cloneHeader() );
215  res.setSizeX( thing.sizeZ() );
216  res.setSizeY( thing.sizeY() );
217  res.setSizeZ( thing.sizeX() );
218  res.setSizeT( thing.sizeT() );
219 
220  int x, y, z, t;
221  ForEach4d( res, x, y, z, t )
222  res( x, y, z, t ) = thing( z, y, x, t );
223 
224  return res;
225 }
226 
227 
228 template <class T> inline
230 {
231  AimsData<T> res( thing.dimX(), thing.dimZ(), thing.dimY(), thing.dimT(),
232  thing.borderWidth() );
233  if( thing.header() )
234  res.setHeader( thing.header()->cloneHeader() );
235  res.setSizeX( thing.sizeX() );
236  res.setSizeY( thing.sizeZ() );
237  res.setSizeZ( thing.sizeY() );
238  res.setSizeT( thing.sizeT() );
239 
240  int x, y, z, t;
241  ForEach4d( res, x, y, z, t )
242  res( x, y, z, t ) = thing( x, z, y, t );
243 
244  return res;
245 }
246 
247 
248 template <class T> inline
250 {
251  AimsData<T> res( thing.dimX(), thing.dimY(), thing.dimZ(), thing.dimT(),
252  thing.borderWidth() );
253  if( thing.header() )
254  res.setHeader( thing.header()->cloneHeader() );
255  res.setSizeXYZT( thing );
256 
257  int x, y, z, t;
258  ForEach4d( res, x, y, z, t )
259  res( x, y, z, t ) = thing( thing.dimX() - x - 1,
260  thing.dimY() - y - 1,
261  thing.dimZ() - z - 1, t );
262 
263  return res;
264 }
265 
266 
267 #endif
virtual ~AimsFlip()
Destructor does nothing.
Definition: flip.h:56
AimsData< T > doZZ(const AimsData< T > &thing)
function which returns the ZZ flipped data
Definition: flip.h:120
int dimZ() const
AimsData< T > doXXZZ(const AimsData< T > &thing)
function which returns the XXZZ flipped data
Definition: flip.h:137
AimsData< T > doXXYY(const AimsData< T > &thing)
function which returns the XXYY flipped data
Definition: flip.h:154
AimsData< T > doXZ(const AimsData< T > &thing)
function which returns the XZ flipped data
Definition: flip.h:209
AimsData< T > doYZ(const AimsData< T > &thing)
function which returns the YZ flipped data
Definition: flip.h:229
#define AIMSDATA_API
float sizeZ() const
int dimY() const
float sizeT() const
#define ForEach4d(thing, x, y, z, t)
AimsData< T > doYYZZ(const AimsData< T > &thing)
function which returns the YYZZ flipped data
Definition: flip.h:171
void setHeader(aims::Header *hdr)
AimsData< T > doXXYYZZ(const AimsData< T > &thing)
function which returns the XXYYZZ flipped data
Definition: flip.h:249
float sizeX() const
virtual Header * cloneHeader(bool keepUuid=false) const =0
AimsData< T > doXY(const AimsData< T > &thing)
function which returns the XY flipped data
Definition: flip.h:189
const aims::Header * header() const
The template object function for flipping.
Definition: flip.h:49
float sizeY() const
int dimT() const
AimsData< T > doYY(const AimsData< T > &thing)
function which returns the YY flipped data
Definition: flip.h:103
AimsData< T > doXX(const AimsData< T > &thing)
function which returns the XX flipped data
Definition: flip.h:86
int dimX() const
int borderWidth() const
Usefull offsets for A.I.M.S.
Definition: border.h:200