2 // C++ Implementation: brukerimage
7 // Author: Denis Grenier, (C) 2009
9 // Copyright: See COPYING file that comes with this distribution
15 #include "brukerimage.h"
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)
25 bool BrukerImage::Init(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
28 // on devrait plutot les nommer 'computeXXX' (setXXX est d'habitude réservé aux accesseurs 'publics')
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);
57 * @brief the constructor uses the BrukerDataSet's of the acqp and reco file
58 * @fn BrukerImage::BrukerImage(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco)
62 BrukerImage::BrukerImage(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco)
66 BrukerImage::~BrukerImage()
71 * @fn int BrukerImage::getAbsoluteTimePosition() const
72 * @brief AbsoluteTimePosition is an integer number giving the time of the begining of the acquisition of the dataset
73 * @return AbsoluteTimePosition int
75 int BrukerImage::getAbsoluteTimePosition() const
77 return AbsoluteTimePosition;
81 * @fn bool BrukerImage::setAbsoluteTimePosition (BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue )
82 * @brief AbsoluteTimePosition is an integer number giving the time of the begining of the acquisition of the dataset
88 bool BrukerImage::setAbsoluteTimePosition (BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue )
90 AbsoluteTimePosition = TheOrigAcqp.GetBrukerHeaderMap()[(std::string) "ACQ_abs_time"].GetIntValue()[0];
96 * @brief RelativeTimePosition is the estimated time position of the time the k-space center was acquired
97 * This notion is very relative when dealing with long experiments and a line or object averaging (NA or NAE <> 1)
98 * @fn double BrukerImage::getRelativeTimePosition() const
101 double BrukerImage::getRelativeTimePosition() const
103 return RelativeTimePosition;
107 * @brief RelativeTimePosition is the estimated instant when the k-space center of each image was acquired
109 This notion is very relative when dealing with long experiments and a line or object averaging (NA or NAE <> 1)
110 * @fn bool BrukerImage::setRelativeTimePosition (BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue )
116 bool BrukerImage::setRelativeTimePosition (BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue )
118 long lTEMP = TheOrigAcqp.GetBrukerImageList()[TheValue].back();
119 RelativeTimePosition = TheOrigAcqp.ObjectVaryingProperties.getPositionTimePerNR(lTEMP);
125 * @brief FOVpixels is a 1x2 integer vector. it's one of the view value we need to pick in the reco headermap
126 * @fn bool BrukerImage::setFOVpixels(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
132 bool BrukerImage::setFOVpixels(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
134 FOVpixels = TheOrigReco.GetBrukerHeaderMap()[(std::string) "RECO_size"].GetIntValue();
139 * @brief FOVpixels is a 1x2 integer vector. it's one of the view value we need to pick in the reco headermap
140 * @fn std::vector <int > BrukerImage::getFOVpixels() const
141 * @return std::vector <int >
143 const std::vector<int > &BrukerImage::getFOVpixels() const
150 * @brief FOVcm is also picked in reco headermap
151 * @fn bool BrukerImage::setFOVcm(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
157 bool BrukerImage::setFOVcm(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
159 FOVcm = TheOrigReco.GetBrukerHeaderMap()[(std::string) "RECO_fov"].GetDoubleValue();
164 * @brief FOVcm is also picked in reco headermap
165 * @fn std::vector <double > BrukerImage::getFOVcm() const
166 * @return std::vector <double >
168 const std::vector <double > &BrukerImage::getFOVcm() const
174 * @brief SliceThickness is in milimeter
175 * @fn bool BrukerImage::setSliceThickness( BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco,int TheValue)
181 bool BrukerImage::setSliceThickness( BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco,int TheValue)
183 SliceThickness = TheOrigAcqp.GetBrukerHeaderMap()[(std::string) "ACQ_slice_thick"].GetDoubleValue()[0];
188 * @brief SliceThickness is in milimeter
189 * @fn double BrukerImage::getSliceThickness() const
192 double BrukerImage::getSliceThickness() const
194 return SliceThickness;
198 * @brief picks the echo time of the image number TheValue
199 * @fn bool BrukerImage::setTE( BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco,int TheValue)
205 bool BrukerImage::setTE( BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco,int TheValue)
207 TE = TheOrigAcqp.ObjectVaryingProperties.getTE(TheOrigAcqp.GetBrukerImageList()[TheValue][0]);
212 * @fn double BrukerImage::getTE() const
213 * @brief picks the echo time of the image number TheValue
216 double BrukerImage::getTE() const
223 * @brief picks the repetition time of the image number TheValue
224 * @fn bool BrukerImage::setTR( BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco,int TheValue)
230 bool BrukerImage::setTR(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
232 TR=TheOrigAcqp.GetBrukerHeaderMap()[(std::string) "ACQ_repetition_time"].GetDoubleValue()[0];
237 * @fn double BrukerImage::getTR() const
238 * @brief picks the echo time of the image number TheValue
241 double BrukerImage::getTR() const
247 * @brief picks the invertion time of the image number TheValue
248 * @fn bool BrukerImage::setTI( BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco,int TheValue)
254 bool BrukerImage::setTI(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
256 TI = TheOrigAcqp.GetBrukerHeaderMap()[(std::string) "ACQ_inversion_time"].GetDoubleValue()[0];
261 * @fn double BrukerImage::getTI() const
262 * @brief picks the invertion time of the image number TheValue
265 double BrukerImage::getTI() const
271 * @brief picks the flip angle of the image number TheValue
272 * @fn bool BrukerImage::setFlipAngle( BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco,int TheValue)
278 bool BrukerImage::setFlipAngle(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
280 FlipAngle = TheOrigAcqp.GetBrukerHeaderMap()[(std::string) "ACQ_flip_angle"].GetIntValue()[0];
285 * @fn double BrukerImage::getFlipAngle() const
286 * @brief picks the flip angle of the image number TheValue
289 double BrukerImage::getFlipAngle() const
296 * @brief LoopStamp is a vector, copy of the values of all the loop for the image number TheValue
298 * The purpose of this "loopstamp" is to provide additionnal information if the methods provided by this class are not sufficient to singularize each image
299 * @fn bool BrukerImage::setLoopStamp(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
305 bool BrukerImage::setLoopStamp(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
307 LoopStamp = TheOrigAcqp.GetBrukerImageList()[TheValue];
312 * @brief LoopStamp is a vector, copy of the values of all the loop for the image number TheValue
313 * The purpose of this "loopstamp" is to provide additionnal information if the methods provided by this class are not sufficient to singularize each image
314 * @fn std::vector<int> BrukerImage::getLoopStamp() const
317 const std::vector<int> &BrukerImage::getLoopStamp() const
324 * @brief NA number of accumulation is useful to track image quality
325 * @fn bool BrukerImage::setNA(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
331 bool BrukerImage::setNA(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
333 NA=TheOrigAcqp.GetBrukerHeaderMap()[(std::string) "NA"].GetIntValue()[0];
338 * @brief NA number of accumulation is useful to track image quality
339 * @fn int BrukerImage::getNA() const
343 int BrukerImage::getNA() const
349 @brief NAE number of object exterior accumulation is useful to track image quality and rather used than NA to average movement artefacts
350 * @fn bool BrukerImage::setNAE(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
356 bool BrukerImage::setNAE(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
358 NAE=TheOrigAcqp.GetBrukerHeaderMap()[(std::string) "NAE"].GetIntValue()[0];
363 @brief NAE number of object exterior accumulation is useful to track image quality and rather used than NA to average movement artefacts
364 * @fn int BrukerImage::getNAE() const
368 int BrukerImage::getNAE() const
374 @brief DS (dummy scan) is useful to establish a dynamic equilibrium or to know if one was used
375 * @fn bool BrukerImage::setDS(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
382 bool BrukerImage::setDS(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
384 DS=TheOrigAcqp.GetBrukerHeaderMap()[(std::string) "DS"].GetIntValue()[0];
389 @brief DS (dummy scan) is useful to establish a dynamic equilibrium or to know if one was used
390 @fn int BrukerImage::get() const
393 int BrukerImage::getDS() const
399 @brief Phase factor is the number of kspace line acquired in a single shot
400 * @fn bool BrukerImage::setACQ_phase_factor(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
406 bool BrukerImage::setACQ_phase_factor(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
408 ACQ_phase_factor=TheOrigAcqp.GetBrukerHeaderMap()[(std::string) "ACQ_phase_factor"].GetIntValue()[0];
413 @brief Phase factor is the number of kspace line acquired in a single shot
414 @fn int BrukerImage::getACQ_phase_factor() const
417 int BrukerImage::getACQ_phase_factor() const
419 return ACQ_phase_factor;
424 @brief The number of repetition NR is used to repeat a full objects acquisition NR times with a given delay
425 * This method returns at which repetition belongs the image TheValue
426 * @fn bool BrukerImage::NR(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
432 bool BrukerImage::setNR(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
434 NR= TheOrigAcqp.GetBrukerImageList()[TheValue].back();
439 @brief The number of repetition NR is used to repeat a full objects acquisition NR times with a given delay
440 * This method returns at which repetition belongs the image TheValue
441 @fn int BrukerImage::getNR() const
444 int BrukerImage::getNR() const
452 @brief RotationMatrixRPS2XYZ is a 3x3 rotation matrix giving the orientation of the TheValue image
453 * @fn bool BrukerImage::setRotationMatrixRPS2XYZ(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
459 bool BrukerImage::setRotationMatrixRPS2XYZ(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
461 RotationMatrixRPS2XYZ = TheOrigAcqp.ObjectVaryingProperties.getOrientation(TheOrigAcqp.GetBrukerImageList()[TheValue][2]);
466 @brief RotationMatrixRPS2XYZ is a 3x3 rotation matrix giving the orientation of the TheValue image
467 @fn std::vector<std::vector<double> > BrukerImage::getRotationMatrixRPS2XYZ() const
468 @return RotationMatrixRPS2XYZ
470 const std::vector<std::vector<double> > &BrukerImage::getRotationMatrixRPS2XYZ() const
472 return RotationMatrixRPS2XYZ;
478 @brief TranslationVectorRPS2XYZ is a 1x3 vector of the TheValue image position to the magnet center (in mm)
479 * @fn bool BrukerImage::setTranslationVectorRPS2XYZ(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
485 bool BrukerImage::setTranslationVectorRPS2XYZ(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
487 TranslationVectorRPS2XYZ.clear();
488 TranslationVectorRPS2XYZ.push_back(TheOrigAcqp.ObjectVaryingProperties.getPositionR(TheOrigAcqp.GetBrukerImageList()[TheValue][2]));
489 TranslationVectorRPS2XYZ.push_back(TheOrigAcqp.ObjectVaryingProperties.getPositionP(TheOrigAcqp.GetBrukerImageList()[TheValue][2]));
490 TranslationVectorRPS2XYZ.push_back(TheOrigAcqp.ObjectVaryingProperties.getPositionS(TheOrigAcqp.GetBrukerImageList()[TheValue][2]));
495 @brief TranslationVectorRPS2XYZ is a 1x3 vector of the TheValue image position to the magnet center (in mm)
496 @fn std::vector<double> BrukerImage::getTranslationVectorRPS2XYZ() const
497 @return TranslationVectorRPS2XYZ
499 const std::vector<double> &BrukerImage::getTranslationVectorRPS2XYZ() const
501 return TranslationVectorRPS2XYZ;
505 @brief WordType returns the type of data to read int32_t, int16_t, uint8_t or float32_t
506 * @fn bool BrukerImage::setWordType(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
512 bool BrukerImage::setWordType(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
514 WordType=TheOrigReco.GetBrukerHeaderMap()[(std::string) "RECO_wordtype"].GetStringValue()[0];
519 @brief WordType returns the type of data to read int32_t, int16_t, uint8_t or float32_t
520 @fn std::string BrukerImage::getWordType() const
521 @return int32_t, int16_t, uint8_t or float32_t or UNKNOWN
523 std::string BrukerImage::getWordType() const
525 if(WordType == ((std::string) "_32BIT_SGN_INT")) return ((std::string)"int32_t");
526 if(WordType == ((std::string) "_16BIT_SGN_INT")) return ((std::string)"int16_t");
527 if(WordType == ((std::string) "_8BIT_UNSGN_INT")) return ((std::string)"uint8_t");
528 if(WordType == ((std::string) "_32BIT_FLOAT")) return ((std::string)"float32_t");
529 return ((std::string)"UNKNOWN");
533 @brief ImageType returns the type of image : values real for amplitude, real imaginary or phase images and complex for complex images
534 * @fn bool BrukerImage::setImageType(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
540 bool BrukerImage::setImageType(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
542 ImageType=TheOrigReco.GetBrukerHeaderMap()[(std::string) "RECO_image_type"].GetStringValue()[0];
547 @brief ImageType returns the type of image : values real for amplitude, real imaginary or phase images and complex for complex images
548 @fn std::string BrukerImage::getImageType() const
549 @return complex or real
551 std::string BrukerImage::getImageType() const
553 if(ImageType == ((std::string) "COMPLEXE_IMAGE")) return ((std::string)"complex");
554 return ((std::string)"real");
559 @brief DataEndianness gives information on how to swap or no the binary data to read
560 * @fn bool BrukerImage::setDataEndianness(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
566 bool BrukerImage::setDataEndianness(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
568 DataEndianness=TheOrigReco.GetBrukerHeaderMap()[(std::string) "RECO_byte_order"].GetStringValue()[0];
573 @brief DataEndianness gives information on how to swap or no the binary data to read
574 @fn std::string BrukerImage::getDataEndianness() const
575 @return DataEndianness
577 const std::string &BrukerImage::getDataEndianness() const
579 return DataEndianness;
583 @brief Information on the image size in byte, useful for offsets calculation
584 * @fn bool BrukerImage::setImageByteSize(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
590 bool BrukerImage::setImageByteSize(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
592 int Dimension, WordSize;
593 if (getImageType()==((std::string)"complex")) Dimension=2;
594 else if (getImageType()==((std::string)"real")) Dimension=1;
597 if (getWordType()==((std::string)"int32_t")||getWordType()==((std::string)"float32_t")) WordSize=4;
598 else if (getWordType()==((std::string)"int16_t")) WordSize=2;
599 else if (getWordType()==((std::string)"uint8_t")) WordSize=1;
600 else /*if (getWordType()==((std::string)"UNKNOWN"))*/ return false;
602 ImageByteSize = Dimension*WordSize*getFOVpixels()[0]*getFOVpixels()[1];
607 @brief Information on the image size in byte, useful for offsets calculation
608 @fn size_t BrukerImage::getImageByteSize() const
609 @return ImageByteSize
611 size_t BrukerImage::getImageByteSize() const
613 return ImageByteSize;
618 @brief BeginingOfImageInBytes is the offset of the image number TheValue to the begining of 2dseq file
619 @fn size_t BrukerImage::getBeginingOfImageInBytes() const
620 @return BeginingOfImageInBytes
624 size_t BrukerImage::getBeginingOfImageInBytes() const
626 return BeginingOfImageInBytes;
631 @brief BeginingOfImageInBytes is the offset of the image number TheValue to the begining of 2dseq file
632 * @fn bool BrukerImage::setBeginingOfImageInBytes(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
638 bool BrukerImage::setBeginingOfImageInBytes (BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
640 BeginingOfImageInBytes = TheValue*getImageByteSize();