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);
55 * @brief the constructor uses the BrukerDataSet's of the acqp and reco file
56 * @fn BrukerImage::BrukerImage(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco)
60 BrukerImage::BrukerImage(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco)
64 BrukerImage::~BrukerImage()
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
73 int BrukerImage::getAbsoluteTimePosition() const
75 return AbsoluteTimePosition;
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
86 bool BrukerImage::setAbsoluteTimePosition (BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue )
88 AbsoluteTimePosition = TheOrigAcqp.GetBrukerHeaderMap()[(std::string) "ACQ_abs_time"].GetIntValue()[0];
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
99 double BrukerImage::getRelativeTimePosition() const
101 return RelativeTimePosition;
105 * @brief RelativeTimePosition is the estimated instant when the k-space center of each image was acquired
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 )
114 bool BrukerImage::setRelativeTimePosition (BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue )
116 long lTEMP = TheOrigAcqp.GetBrukerImageList()[TheValue].back();
117 RelativeTimePosition = TheOrigAcqp.ObjectVaryingProperties.getPositionTimePerNR(lTEMP);
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)
130 bool BrukerImage::setFOVpixels(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
132 FOVpixels = TheOrigReco.GetBrukerHeaderMap()[(std::string) "RECO_size"].GetIntValue();
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 >
141 const std::vector<int > &BrukerImage::getFOVpixels() const
148 * @brief FOVcm is also picked in reco headermap
149 * @fn bool BrukerImage::setFOVcm(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
155 bool BrukerImage::setFOVcm(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
157 FOVcm = TheOrigReco.GetBrukerHeaderMap()[(std::string) "RECO_fov"].GetDoubleValue();
162 * @brief FOVcm is also picked in reco headermap
163 * @fn std::vector <double > BrukerImage::getFOVcm() const
164 * @return std::vector <double >
166 const std::vector <double > &BrukerImage::getFOVcm() const
172 * @brief SliceThickness is in milimeter
173 * @fn bool BrukerImage::setSliceThickness( BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco,int TheValue)
179 bool BrukerImage::setSliceThickness( BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco,int TheValue)
181 SliceThickness = TheOrigAcqp.GetBrukerHeaderMap()[(std::string) "ACQ_slice_thick"].GetDoubleValue()[0];
186 * @brief SliceThickness is in milimeter
187 * @fn double BrukerImage::getSliceThickness() const
190 double BrukerImage::getSliceThickness() const
192 return SliceThickness;
196 * @brief picks the echo time of the image number TheValue
197 * @fn bool BrukerImage::setTE( BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco,int TheValue)
203 bool BrukerImage::setTE( BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco,int TheValue)
205 TE = TheOrigAcqp.ObjectVaryingProperties.getTE(TheOrigAcqp.GetBrukerImageList()[TheValue][0]);
210 * @fn double BrukerImage::getTE() const
211 * @brief picks the echo time of the image number TheValue
214 double BrukerImage::getTE() const
221 * @brief picks the repetition time of the image number TheValue
222 * @fn bool BrukerImage::setTR( BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco,int TheValue)
228 bool BrukerImage::setTR(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
230 TR=TheOrigAcqp.GetBrukerHeaderMap()[(std::string) "ACQ_repetition_time"].GetDoubleValue()[0];
235 * @fn double BrukerImage::getTR() const
236 * @brief picks the echo time of the image number TheValue
239 double BrukerImage::getTR() const
245 * @brief picks the invertion time of the image number TheValue
246 * @fn bool BrukerImage::setTI( BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco,int TheValue)
252 bool BrukerImage::setTI(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
254 TI = TheOrigAcqp.GetBrukerHeaderMap()[(std::string) "ACQ_inversion_time"].GetDoubleValue()[0];
259 * @fn double BrukerImage::getTI() const
260 * @brief picks the invertion time of the image number TheValue
263 double BrukerImage::getTI() const
269 * @brief picks the flip angle of the image number TheValue
270 * @fn bool BrukerImage::setFlipAngle( BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco,int TheValue)
276 bool BrukerImage::setFlipAngle(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
278 FlipAngle = TheOrigAcqp.GetBrukerHeaderMap()[(std::string) "ACQ_flip_angle"].GetIntValue()[0];
283 * @fn double BrukerImage::getFlipAngle() const
284 * @brief picks the flip angle of the image number TheValue
287 double BrukerImage::getFlipAngle() const
294 * @brief LoopStamp is a vector, copy of the values of all the loop for the image number TheValue
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)
303 bool BrukerImage::setLoopStamp(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
305 LoopStamp = TheOrigAcqp.GetBrukerImageList()[TheValue];
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
315 const std::vector<int> &BrukerImage::getLoopStamp() const
322 * @brief NA number of accumulation is useful to track image quality
323 * @fn bool BrukerImage::setNA(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
329 bool BrukerImage::setNA(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
331 NA=TheOrigAcqp.GetBrukerHeaderMap()[(std::string) "NA"].GetIntValue()[0];
336 * @brief NA number of accumulation is useful to track image quality
337 * @fn int BrukerImage::getNA() const
341 int BrukerImage::getNA() const
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)
354 bool BrukerImage::setNAE(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
356 NAE=TheOrigAcqp.GetBrukerHeaderMap()[(std::string) "NAE"].GetIntValue()[0];
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
366 int BrukerImage::getNAE() const
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)
380 bool BrukerImage::setDS(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
382 DS=TheOrigAcqp.GetBrukerHeaderMap()[(std::string) "DS"].GetIntValue()[0];
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
391 int BrukerImage::getDS() const
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)
404 bool BrukerImage::setACQ_phase_factor(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
406 ACQ_phase_factor=TheOrigAcqp.GetBrukerHeaderMap()[(std::string) "ACQ_phase_factor"].GetIntValue()[0];
411 @brief Phase factor is the number of kspace line acquired in a single shot
412 @fn int BrukerImage::getACQ_phase_factor() const
415 int BrukerImage::getACQ_phase_factor() const
417 return ACQ_phase_factor;
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)
430 bool BrukerImage::setNR(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
432 NR= TheOrigAcqp.GetBrukerImageList()[TheValue].back();
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
442 int BrukerImage::getNR() const
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)
457 bool BrukerImage::setRotationMatrixRPS2XYZ(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
459 RotationMatrixRPS2XYZ = TheOrigAcqp.ObjectVaryingProperties.getOrientation(TheOrigAcqp.GetBrukerImageList()[TheValue][2]);
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
468 const std::vector<std::vector<double> > &BrukerImage::getRotationMatrixRPS2XYZ() const
470 return RotationMatrixRPS2XYZ;
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)
483 bool BrukerImage::setTranslationVectorRPS2XYZ(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
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]));
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
497 const std::vector<double> &BrukerImage::getTranslationVectorRPS2XYZ() const
499 return TranslationVectorRPS2XYZ;
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)
510 bool BrukerImage::setWordType(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
512 WordType=TheOrigReco.GetBrukerHeaderMap()[(std::string) "RECO_wordtype"].GetStringValue()[0];
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
521 std::string BrukerImage::getWordType() const
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");
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)
538 bool BrukerImage::setImageType(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
540 ImageType=TheOrigReco.GetBrukerHeaderMap()[(std::string) "RECO_image_type"].GetStringValue()[0];
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
549 std::string BrukerImage::getImageType() const
551 if(ImageType == ((std::string) "COMPLEXE_IMAGE")) return ((std::string)"complex");
552 return ((std::string)"real");
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)
564 bool BrukerImage::setDataEndianness(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
566 DataEndianness=TheOrigReco.GetBrukerHeaderMap()[(std::string) "RECO_byte_order"].GetStringValue()[0];
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
575 const std::string &BrukerImage::getDataEndianness() const
577 return DataEndianness;
581 @brief Information on the image size in byte, useful for offsets calculation
582 * @fn bool BrukerImage::setImageByteSize(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
588 bool BrukerImage::setImageByteSize(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
590 int Dimension, WordSize;
591 if (getImageType()==((std::string)"complex")) Dimension=2;
592 else if (getImageType()==((std::string)"real")) Dimension=1;
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;
600 ImageByteSize = Dimension*WordSize*getFOVpixels()[0]*getFOVpixels()[1];
605 @brief Information on the image size in byte, useful for offsets calculation
606 @fn size_t BrukerImage::getImageByteSize() const
607 @return ImageByteSize
609 size_t BrukerImage::getImageByteSize() const
611 return ImageByteSize;
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
622 size_t BrukerImage::getBeginingOfImageInBytes() const
624 return BeginingOfImageInBytes;
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)
636 bool BrukerImage::setBeginingOfImageInBytes (BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, int TheValue)
638 BeginingOfImageInBytes = TheValue*getImageByteSize();