]> Creatis software - creaBruker.git/blob - lib/src1/brukerimage.cpp
41285f579367ec875265488a991eff5f519bfe58
[creaBruker.git] / lib / src1 / brukerimage.cpp
1 //
2 // C++ Implementation: brukerimage
3 //
4 // Description: 
5 //
6 //
7 // Author:  Denis Grenier, (C) 2009
8 //
9 // Copyright: See COPYING file that comes with this distribution
10 //
11 //
12 /**
13 @file brukerimage.cpp
14 */
15 #include "brukerimage.h"
16
17 /**
18 * This method takes care of the initialization of the main parameters usually needed to deal with an MRI experiment 
19  * @fn bool BrukerImage::Init(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
20  * @param TheOrigAcqp 
21  * @param TheOrigReco 
22  * @param TheValue 
23  * @return bool
24  */
25 bool BrukerImage::Init(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
26 {
27
28 // on devrait plutot les nommer 'computeXXX' (setXXX est d'habitude réservé aux accesseurs 'publics')
29
30    setAbsoluteTimePosition     (TheOrigAcqp,TheOrigReco,TheValue);
31    setRelativeTimePosition     (TheOrigAcqp,TheOrigReco,TheValue);
32    setFOVpixels                (TheOrigAcqp,TheOrigReco,TheValue);
33    setFOVcm                    (TheOrigAcqp,TheOrigReco,TheValue);
34    setSliceThickness           (TheOrigAcqp,TheOrigReco,TheValue);
35    setTE                       (TheOrigAcqp,TheOrigReco,TheValue);
36    setTR                       (TheOrigAcqp,TheOrigReco,TheValue);
37    setTI                       (TheOrigAcqp,TheOrigReco,TheValue);
38    setFlipAngle                (TheOrigAcqp,TheOrigReco,TheValue);
39    setLoopStamp                (TheOrigAcqp,TheOrigReco,TheValue);
40    setNA                       (TheOrigAcqp,TheOrigReco,TheValue);
41    setNR                       (TheOrigAcqp,TheOrigReco,TheValue);
42    setNAE                      (TheOrigAcqp,TheOrigReco,TheValue);
43    setDS                       (TheOrigAcqp,TheOrigReco,TheValue);
44    setACQ_phase_factor         (TheOrigAcqp,TheOrigReco,TheValue);
45    setRotationMatrixRPS2XYZ    (TheOrigAcqp,TheOrigReco,TheValue);
46    setTranslationVectorRPS2XYZ (TheOrigAcqp,TheOrigReco,TheValue);
47    setWordType                 (TheOrigAcqp,TheOrigReco,TheValue);
48    setImageType                (TheOrigAcqp,TheOrigReco,TheValue);
49    setDataEndianness           (TheOrigAcqp,TheOrigReco,TheValue);
50    setImageByteSize            (TheOrigAcqp,TheOrigReco,TheValue);
51    setBeginingOfImageInBytes   (TheOrigAcqp,TheOrigReco,TheValue);
52 }
53
54 /**
55  * @brief the constructor uses the BrukerDataSet's of the acqp and reco file
56  * @fn BrukerImage::BrukerImage(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco)
57  * @param TheOrigAcqp 
58  * @param TheOrigReco 
59  */
60 BrukerImage::BrukerImage(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco)
61 {
62 }
63
64 BrukerImage::~BrukerImage()
65 {
66 }
67
68 /**
69 * @fn int BrukerImage::getAbsoluteTimePosition() const
70  * @brief AbsoluteTimePosition is an integer number giving the time of the begining of the acquisition of the dataset
71  * @return AbsoluteTimePosition int
72  */
73 int BrukerImage::getAbsoluteTimePosition() const
74 {
75    return AbsoluteTimePosition;
76 }
77
78 /**
79 * @fn bool BrukerImage::setAbsoluteTimePosition (BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue )
80  * @brief AbsoluteTimePosition is an integer number giving the time of the begining of the acquisition of the dataset
81  * @param TheOrigAcqp
82  * @param TheOrigReco
83  * @param TheValue
84  * @return bool
85  */
86 bool BrukerImage::setAbsoluteTimePosition (BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue )
87 {
88    AbsoluteTimePosition = TheOrigAcqp.GetBrukerHeaderMap()[(std::string) "ACQ_abs_time"].GetIntValue()[0];
89    return true;
90 }
91
92
93 /**
94  * @brief RelativeTimePosition is the estimated time position of the time the k-space center was acquired
95  * This notion is very relative when dealing with long experiments and a line or object averaging (NA or NAE <> 1)
96  * @fn double BrukerImage::getRelativeTimePosition() const
97  * @return double
98  */
99 double BrukerImage::getRelativeTimePosition() const
100 {
101    return RelativeTimePosition;
102 }
103
104 /**
105  * @brief RelativeTimePosition is the estimated instant when the k-space center of each image was acquired
106
107      This notion is very relative when dealing with long experiments and a line or object averaging (NA or NAE <> 1)
108 * @fn bool BrukerImage::setRelativeTimePosition (BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco,  int TheValue )
109  * @param TheOrigAcqp 
110  * @param TheOrigReco 
111  * @param TheValue 
112  * @return  bool
113  */
114 bool BrukerImage::setRelativeTimePosition (BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco,  int TheValue )
115 {
116    long lTEMP = TheOrigAcqp.GetBrukerImageList()[TheValue].back();
117    RelativeTimePosition = TheOrigAcqp.ObjectVaryingProperties.getPositionTimePerNR(lTEMP);
118    return true;
119 }
120
121
122 /**
123  * @brief FOVpixels is a 1x2 integer vector. it's one of the view value we need to pick in the reco headermap
124  *  @fn bool BrukerImage::setFOVpixels(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
125  * @param TheOrigAcqp 
126  * @param TheOrigReco 
127  * @param TheValue 
128  * @return bool
129  */
130 bool BrukerImage::setFOVpixels(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
131 {
132    FOVpixels = TheOrigReco.GetBrukerHeaderMap()[(std::string) "RECO_size"].GetIntValue();
133    return true;
134 }
135
136 /**
137  * @brief FOVpixels is a 1x2 integer vector. it's one of the view value we need to pick in the reco headermap
138  * @fn std::vector <int > BrukerImage::getFOVpixels() const
139  * @return std::vector <int >
140  */
141 const std::vector<int > &BrukerImage::getFOVpixels() const
142 {
143    return FOVpixels;
144 }
145
146
147 /**
148  * @brief FOVcm is also picked in reco headermap
149  * @fn bool BrukerImage::setFOVcm(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
150  * @param TheOrigAcqp 
151  * @param TheOrigReco 
152  * @param TheValue 
153  * @return bool
154  */
155 bool BrukerImage::setFOVcm(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
156 {
157    FOVcm = TheOrigReco.GetBrukerHeaderMap()[(std::string) "RECO_fov"].GetDoubleValue();
158    return true;
159 }
160
161 /**
162  * @brief FOVcm is also picked in reco headermap
163  * @fn std::vector <double > BrukerImage::getFOVcm() const
164  * @return std::vector <double >
165  */
166 const std::vector <double > &BrukerImage::getFOVcm() const
167 {
168    return FOVcm;
169 }
170
171 /**
172  * @brief SliceThickness is in milimeter
173  * @fn bool BrukerImage::setSliceThickness( BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco,int TheValue)
174  * @param TheOrigAcqp 
175  * @param TheOrigReco 
176  * @param TheValue 
177  * @return bool
178  */
179 bool BrukerImage::setSliceThickness( BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco,int TheValue)
180 {
181    SliceThickness = TheOrigAcqp.GetBrukerHeaderMap()[(std::string) "ACQ_slice_thick"].GetDoubleValue()[0];
182    return true;
183 }
184
185 /**
186  * @brief SliceThickness is in milimeter
187  * @fn double  BrukerImage::getSliceThickness() const
188  * @return double
189  */
190 double  BrukerImage::getSliceThickness() const
191 {
192    return SliceThickness;
193 }
194
195 /**
196 *  @brief picks the echo time of the image number TheValue
197  * @fn bool BrukerImage::setTE( BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco,int TheValue)
198  * @param TheOrigAcqp 
199  * @param TheOrigReco 
200  * @param TheValue 
201  * @return bool
202  */
203 bool BrukerImage::setTE( BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco,int TheValue)
204 {
205    TE = TheOrigAcqp.ObjectVaryingProperties.getTE(TheOrigAcqp.GetBrukerImageList()[TheValue][0]);
206    return true;
207 }
208
209 /**
210  * @fn double BrukerImage::getTE() const
211  * @brief picks the echo time of the image number TheValue
212  * @return TE
213  */
214 double BrukerImage::getTE() const
215 {
216    return TE;
217 }
218
219
220 /**
221  *  @brief picks the repetition time of the image number TheValue
222  * @fn bool BrukerImage::setTR( BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco,int TheValue)
223  * @param TheOrigAcqp 
224  * @param TheOrigReco 
225  * @param TheValue 
226  * @return bool
227  */
228 bool BrukerImage::setTR(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
229 {
230    TR=TheOrigAcqp.GetBrukerHeaderMap()[(std::string) "ACQ_repetition_time"].GetDoubleValue()[0];
231    return true;
232 }
233
234  /**
235   * @fn double BrukerImage::getTR() const
236   * @brief picks the echo time of the image number TheValue
237   * @return TR
238   */
239 double BrukerImage::getTR() const
240 {
241    return TR;
242 }
243
244 /**
245 *  @brief picks the invertion time of the image number TheValue
246  * @fn bool BrukerImage::setTI( BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco,int TheValue)
247  * @param TheOrigAcqp 
248  * @param TheOrigReco 
249  * @param TheValue 
250  * @return bool
251  */
252 bool BrukerImage::setTI(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
253 {
254    TI = TheOrigAcqp.GetBrukerHeaderMap()[(std::string) "ACQ_inversion_time"].GetDoubleValue()[0];
255    return true;
256 }
257
258  /**
259   * @fn double BrukerImage::getTI() const
260   * @brief picks the invertion time of the image number TheValue
261   * @return TI
262   */
263 double BrukerImage::getTI() const
264 {
265    return TI;
266 }
267
268 /**
269 *  @brief picks the flip angle of the image number TheValue
270  * @fn bool BrukerImage::setFlipAngle( BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco,int TheValue)
271  * @param TheOrigAcqp 
272  * @param TheOrigReco 
273  * @param TheValue 
274  * @return bool
275  */
276 bool BrukerImage::setFlipAngle(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
277 {
278    FlipAngle = TheOrigAcqp.GetBrukerHeaderMap()[(std::string) "ACQ_flip_angle"].GetIntValue()[0];
279    return true;
280 }
281
282 /**
283  * @fn double BrukerImage::getFlipAngle() const
284  * @brief picks the flip angle of the image number TheValue
285  * @return FlipAngle
286 */
287 double BrukerImage::getFlipAngle() const
288 {
289    return FlipAngle;
290 }
291
292
293 /**
294  * @brief LoopStamp is a vector, copy of the values of all the loop for the image number TheValue
295
296  * The purpose of this "loopstamp" is to provide additionnal information if the methods provided by this class are not sufficient to singularize each image 
297  * @fn bool BrukerImage::setLoopStamp(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
298  * @param TheOrigAcqp 
299  * @param TheOrigReco 
300  * @param TheValue 
301  * @return bool
302  */
303 bool BrukerImage::setLoopStamp(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
304 {
305    LoopStamp = TheOrigAcqp.GetBrukerImageList()[TheValue];
306    return true;
307 }
308
309 /** 
310  * @brief LoopStamp is a vector, copy of the values of all the loop for the image number TheValue
311  * The purpose of this "loopstamp" is to provide additionnal information if the methods provided by this class are not sufficient to singularize each image 
312  * @fn std::vector<int> BrukerImage::getLoopStamp() const
313  * @return LoopStamp
314  */
315 const std::vector<int> &BrukerImage::getLoopStamp() const
316 {
317    return LoopStamp;
318 }
319
320
321 /**
322  * @brief NA number of accumulation is useful to track image quality
323  * @fn bool BrukerImage::setNA(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
324  * @param TheOrigAcqp 
325  * @param TheOrigReco 
326  * @param TheValue 
327  * @return 
328  */
329 bool BrukerImage::setNA(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
330 {
331    NA=TheOrigAcqp.GetBrukerHeaderMap()[(std::string) "NA"].GetIntValue()[0];
332    return true;
333 }
334
335 /**
336  * @brief NA number of accumulation is useful to track image quality
337  * @fn int BrukerImage::getNA() const
338  * 
339  * @return NA
340  */
341 int BrukerImage::getNA() const
342 {
343    return NA;
344 }
345
346 /**
347 @brief NAE number of object exterior accumulation is useful to track image quality and rather used than NA to average movement artefacts
348  * @fn bool BrukerImage::setNAE(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
349  * @param TheOrigAcqp 
350  * @param TheOrigReco 
351  * @param TheValue 
352  * @return bool
353  */
354 bool BrukerImage::setNAE(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
355 {
356    NAE=TheOrigAcqp.GetBrukerHeaderMap()[(std::string) "NAE"].GetIntValue()[0];
357    return true;
358 }
359
360 /**
361  @brief NAE number of object exterior accumulation is useful to track image quality and rather used than NA to average movement artefacts
362  * @fn int BrukerImage::getNAE() const
363  * @return NAE
364  */
365
366 int BrukerImage::getNAE() const
367 {
368    return NAE;
369 }
370
371 /**
372 @brief DS (dummy scan) is useful to establish a dynamic equilibrium or to know if one was used
373  * @fn bool BrukerImage::setDS(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
374  * @param TheOrigAcqp 
375  * @param TheOrigReco 
376  * @param TheValue 
377  * @return bool
378  */
379
380 bool BrukerImage::setDS(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
381 {
382    DS=TheOrigAcqp.GetBrukerHeaderMap()[(std::string) "DS"].GetIntValue()[0];
383    return true;
384 }
385
386 /**
387  @brief  DS (dummy scan) is useful to establish a dynamic equilibrium or to know if one was used
388  @fn int BrukerImage::get() const
389  @return DS
390 */
391 int BrukerImage::getDS() const
392 {
393    return DS;
394 }
395
396 /**
397 @brief Phase factor is the number of kspace line acquired in a single shot
398  * @fn bool BrukerImage::setACQ_phase_factor(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
399  * @param TheOrigAcqp 
400  * @param TheOrigReco 
401  * @param TheValue 
402  * @return bool
403  */
404 bool BrukerImage::setACQ_phase_factor(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
405 {
406    ACQ_phase_factor=TheOrigAcqp.GetBrukerHeaderMap()[(std::string) "ACQ_phase_factor"].GetIntValue()[0];
407    return true;
408 }
409
410 /**
411  @brief Phase factor is the number of kspace line acquired in a single shot
412  @fn int BrukerImage::getACQ_phase_factor() const
413  @return 
414 */
415 int BrukerImage::getACQ_phase_factor() const
416 {
417    return ACQ_phase_factor;
418 }
419
420
421 /**
422 @brief The number of repetition NR is used to repeat a full objects acquisition NR times with a given delay
423 * This method returns at which repetition belongs the image TheValue 
424  * @fn bool BrukerImage::NR(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
425  * @param TheOrigAcqp 
426  * @param TheOrigReco 
427  * @param TheValue 
428  * @return bool
429  */
430 bool BrukerImage::setNR(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
431 {
432    NR= TheOrigAcqp.GetBrukerImageList()[TheValue].back();
433    return true;
434 }
435
436        /**
437          @brief  The number of repetition NR is used to repeat a full objects acquisition NR times with a given delay
438          * This method returns at which repetition belongs the image TheValue 
439          @fn int BrukerImage::getNR() const
440          @return NR
441          */
442 int BrukerImage::getNR() const
443 {
444    return NR;
445 }
446
447
448
449 /**
450 @brief  RotationMatrixRPS2XYZ is a 3x3 rotation matrix  giving the orientation of the TheValue image
451  * @fn bool BrukerImage::setRotationMatrixRPS2XYZ(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
452  * @param TheOrigAcqp 
453  * @param TheOrigReco 
454  * @param TheValue 
455  * @return bool
456  */
457 bool BrukerImage::setRotationMatrixRPS2XYZ(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
458 {
459    RotationMatrixRPS2XYZ = TheOrigAcqp.ObjectVaryingProperties.getOrientation(TheOrigAcqp.GetBrukerImageList()[TheValue][2]);
460    return true;
461 }
462
463        /**
464          @brief   RotationMatrixRPS2XYZ is a 3x3 rotation matrix  giving the orientation of the TheValue image
465          @fn std::vector<std::vector<double> > BrukerImage::getRotationMatrixRPS2XYZ() const
466          @return RotationMatrixRPS2XYZ
467          */
468 const std::vector<std::vector<double> > &BrukerImage::getRotationMatrixRPS2XYZ() const
469 {
470    return RotationMatrixRPS2XYZ;
471 }
472
473
474
475 /**
476 @brief TranslationVectorRPS2XYZ is a 1x3 vector of the TheValue image position to the magnet center (in mm)
477  * @fn bool BrukerImage::setTranslationVectorRPS2XYZ(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
478  * @param TheOrigAcqp 
479  * @param TheOrigReco 
480  * @param TheValue 
481  * @return bool
482  */
483 bool BrukerImage::setTranslationVectorRPS2XYZ(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
484 {
485    TranslationVectorRPS2XYZ.clear();
486    TranslationVectorRPS2XYZ.push_back(TheOrigAcqp.ObjectVaryingProperties.getPositionR(TheOrigAcqp.GetBrukerImageList()[TheValue][2]));
487    TranslationVectorRPS2XYZ.push_back(TheOrigAcqp.ObjectVaryingProperties.getPositionP(TheOrigAcqp.GetBrukerImageList()[TheValue][2]));
488    TranslationVectorRPS2XYZ.push_back(TheOrigAcqp.ObjectVaryingProperties.getPositionS(TheOrigAcqp.GetBrukerImageList()[TheValue][2]));
489    return true;
490 }
491
492 /**
493  @brief  TranslationVectorRPS2XYZ is a 1x3 vector of the TheValue image position to the magnet center (in mm)
494  @fn std::vector<double> BrukerImage::getTranslationVectorRPS2XYZ() const
495  @return TranslationVectorRPS2XYZ
496 */
497 const std::vector<double>  &BrukerImage::getTranslationVectorRPS2XYZ() const
498 {
499    return TranslationVectorRPS2XYZ;
500 }
501
502 /**
503 @brief WordType returns the type of data to read int32_t, int16_t, uint8_t or float32_t
504  * @fn bool BrukerImage::setWordType(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
505  * @param TheOrigAcqp 
506  * @param TheOrigReco 
507  * @param TheValue 
508  * @return bool
509  */
510 bool BrukerImage::setWordType(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
511 {
512    WordType=TheOrigReco.GetBrukerHeaderMap()[(std::string) "RECO_wordtype"].GetStringValue()[0];
513    return true;
514 }
515
516        /**
517          @brief WordType returns the type of data to read int32_t, int16_t, uint8_t or float32_t
518          @fn std::string BrukerImage::getWordType() const
519          @return int32_t, int16_t, uint8_t or float32_t or UNKNOWN
520          */
521 std::string BrukerImage::getWordType() const
522
523    if(WordType == ((std::string) "_32BIT_SGN_INT"))  return ((std::string)"int32_t");
524    if(WordType == ((std::string) "_16BIT_SGN_INT"))  return ((std::string)"int16_t");
525    if(WordType == ((std::string) "_8BIT_UNSGN_INT")) return ((std::string)"uint8_t");
526    if(WordType == ((std::string) "_32BIT_FLOAT"))    return ((std::string)"float32_t");
527    return ((std::string)"UNKNOWN");
528 }
529
530 /**
531 @brief ImageType returns the type of image : values real for amplitude, real imaginary or phase images  and complex for complex images
532  * @fn bool BrukerImage::setImageType(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
533  * @param TheOrigAcqp 
534  * @param TheOrigReco 
535  * @param TheValue 
536  * @return bool
537  */
538 bool BrukerImage::setImageType(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
539 {
540    ImageType=TheOrigReco.GetBrukerHeaderMap()[(std::string) "RECO_image_type"].GetStringValue()[0];
541    return true;
542 }
543
544         /**
545          @brief  ImageType returns the type of image : values real for amplitude, real imaginary or phase images  and complex for complex images
546          @fn std::string BrukerImage::getImageType() const
547          @return complex or real
548          */
549 std::string BrukerImage::getImageType() const
550 {
551    if(ImageType == ((std::string) "COMPLEXE_IMAGE")) return ((std::string)"complex");
552    return ((std::string)"real");
553 }
554
555
556 /**
557 @brief DataEndianness gives information on how to swap or no the binary data to read
558  * @fn bool BrukerImage::setDataEndianness(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
559  * @param TheOrigAcqp 
560  * @param TheOrigReco 
561  * @param TheValue 
562  * @return bool
563  */
564 bool BrukerImage::setDataEndianness(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
565 {
566    DataEndianness=TheOrigReco.GetBrukerHeaderMap()[(std::string) "RECO_byte_order"].GetStringValue()[0];
567    return true;
568 }
569
570         /**
571          @brief  DataEndianness gives information on how to swap or no the binary data to read
572          @fn std::string BrukerImage::getDataEndianness() const
573          @return DataEndianness
574          */
575 const std::string &BrukerImage::getDataEndianness() const
576 {
577    return DataEndianness;
578 }
579
580 /**
581 @brief Information on the image size in byte, useful for offsets calculation
582  * @fn bool BrukerImage::setImageByteSize(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
583  * @param TheOrigAcqp 
584  * @param TheOrigReco 
585  * @param TheValue 
586  * @return bool
587  */
588 bool BrukerImage::setImageByteSize(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
589 {
590    int Dimension, WordSize;
591    if      (getImageType()==((std::string)"complex")) Dimension=2;
592    else if (getImageType()==((std::string)"real"))    Dimension=1;
593    else return false;
594    
595    if (getWordType()==((std::string)"int32_t")||getWordType()==((std::string)"float32_t")) WordSize=4;
596    else if (getWordType()==((std::string)"int16_t")) WordSize=2;
597    else if (getWordType()==((std::string)"uint8_t")) WordSize=1;
598    else /*if (getWordType()==((std::string)"UNKNOWN"))*/ return false;
599
600    ImageByteSize = Dimension*WordSize*getFOVpixels()[0]*getFOVpixels()[1];
601    return true;
602 }
603
604          /**
605          @brief  Information on the image size in byte, useful for offsets calculation
606          @fn size_t BrukerImage::getImageByteSize() const
607          @return ImageByteSize
608          */
609 size_t BrukerImage::getImageByteSize() const
610 {
611    return ImageByteSize;
612 }
613
614
615 /**
616  @brief BeginingOfImageInBytes is the offset of the image number TheValue to the begining of 2dseq file
617  @fn size_t BrukerImage::getBeginingOfImageInBytes() const
618  @return BeginingOfImageInBytes
619 */
620
621
622 size_t BrukerImage::getBeginingOfImageInBytes() const
623 {
624    return BeginingOfImageInBytes;
625 }
626
627
628 /**
629 @brief BeginingOfImageInBytes is the offset of the image number TheValue to the begining of 2dseq file
630  * @fn bool BrukerImage::setBeginingOfImageInBytes(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
631  * @param TheOrigAcqp 
632  * @param TheOrigReco 
633  * @param TheValue 
634  * @return bool
635  */
636 bool BrukerImage::setBeginingOfImageInBytes (BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
637 {
638    BeginingOfImageInBytes = TheValue*getImageByteSize();
639 }