2 // C++ Implementation: brukerobjectvaryingproperties
7 // Author: denis grenier <denis.grenier@creatis.univ-lyon1.fr>, (C) 2009
9 // Copyright: See COPYING file that comes with this distribution
12 #include "brukerobjectvaryingproperties.h"
13 #include "brukerexception.h"
16 BrukerObjectVaryingProperties::BrukerObjectVaryingProperties()
21 BrukerObjectVaryingProperties::~BrukerObjectVaryingProperties()
27 void BrukerObjectVaryingProperties::computePositionS(std::map<std::string, BrukerFieldData> & BrukerHM){
28 std::vector<double> PosiS =BrukerHM[(std::string) "ACQ_slice_offset"].GetDoubleValue();
32 void BrukerObjectVaryingProperties::computePositionR(std::map<std::string, BrukerFieldData> & BrukerHM){
33 PositionR =BrukerHM[(std::string) "ACQ_read_offset"].GetDoubleValue() ;
36 void BrukerObjectVaryingProperties::computePositionP(std::map<std::string, BrukerFieldData> & BrukerHM){
37 PositionP =BrukerHM[(std::string) "ACQ_phase1_offset"].GetDoubleValue();
40 void BrukerObjectVaryingProperties::computeTE(std::map<std::string, BrukerFieldData> & BrukerHM){
41 TE = BrukerHM[(std::string) "ACQ_echo_time"].GetDoubleValue();
44 double BrukerObjectVaryingProperties::getTE(unsigned int theValue) const{
45 if (theValue < TE.size() ) {return TE[theValue];}
47 else throw BrukerSizeException("TE", theValue, TE.size() );
50 /*void BrukerObjectVaryingProperties::computeTE(const std::vector< double >& theValue)
55 double BrukerObjectVaryingProperties::getPositionP(unsigned int theValue) const{
56 if (theValue < PositionP.size() ) return PositionP[theValue];
58 else throw BrukerSizeException("PositionP", theValue, PositionP.size() );
61 /*void BrukerObjectVaryingProperties::computePositionP(const std::vector< double >& theValue)
66 double BrukerObjectVaryingProperties::getPositionR(unsigned int theValue) const{
67 if (theValue < PositionR.size() ) return PositionR[theValue];
69 else throw BrukerSizeException("PositionR", theValue, PositionR.size() );
72 /*void BrukerObjectVaryingProperties::computePositionR(const std::vector< double >& theValue)
77 double BrukerObjectVaryingProperties::getPositionS(unsigned int theValue) const{
78 if (theValue < PositionS.size() ) return PositionS[theValue];
80 else throw BrukerSizeException("PositionS", theValue, PositionS.size() );
83 /*void BrukerObjectVaryingProperties::computePositionS(const std::vector< double >& theValue)
88 int BrukerObjectVaryingProperties::getAcquisitionOrder(unsigned int theValue) const{
89 if (theValue <AcquisitionOrder.size()) return AcquisitionOrder[theValue];
91 else throw BrukerSizeException("AcquisitionOrder", theValue, AcquisitionOrder.size() );
94 /*void BrukerObjectVaryingProperties::computeAcquisitionOrder(const std::vector< int >& theValue1, const std::vector< int >& theValue2)
96 AcquisitionOrder.clear();
97 if (theValue1.size() != theValue2[3]*theValue2[1]) throw 5;
98 if (theValue2.size() < 4 ) throw 6;
99 for (int i =0 ;i<theValue2[3];i++)AcquisitionOrder.push_back()=(int) theValue1[i*theValue2[1]]/theValue2[1];
102 void BrukerObjectVaryingProperties::computeAcquisitionOrder(std::map<std::string, BrukerFieldData> & BrukerHM, std::vector<int> & LoopStruct){
103 std::vector<int> AcqOrder;
104 if (BrukerHM[(std::string) "ACQ_obj_order"].GetIntValue().size() != LoopStruct[3]*LoopStruct[1]) throw 7;
105 if (LoopStruct.size() < 4 ) throw 8;
106 for (int i =0 ;i<LoopStruct[3];i++)
107 AcqOrder.push_back((int) BrukerHM[(std::string) "ACQ_obj_order"].GetIntValue()[i*LoopStruct[1]]/LoopStruct[1]);
108 AcquisitionOrder=AcqOrder;
111 std :: vector < std :: vector < double > > BrukerObjectVaryingProperties::getOrientation(unsigned int theValue) const{
112 if (theValue < Orientation.size())return Orientation[theValue];
114 else throw BrukerSizeException("Orientation", theValue, Orientation.size() );
117 /*void BrukerObjectVaryingProperties::computeOrientation( std :: vector < double > & theValue1,const std::vector< int >& theValue2)
119 if (theValue1.size() != theValue2[3]*9) throw 10;
120 if (theValue2.size() < 4 ) throw 11;
122 for(int i=0;i<theValue2[3];i++){
123 for(int j=0;j<3;j++){
124 for(int k=0;k<3;k++){
125 Orientation[i][j][k]=theValue1[counter];
132 void BrukerObjectVaryingProperties::computeOrientation(std::map<std::string, BrukerFieldData> & BrukerHM, std::vector<int> & LoopStruct){
133 if (BrukerHM[(std::string) "ACQ_grad_matrix"].GetDoubleValue().size() != LoopStruct[3]*9) throw 12;
134 if (LoopStruct.size() < 4 )
136 throw BrukerSizeException("LoopStruct", 4, LoopStruct.size() );
138 std::vector<double> Temp1D(3,0.0);
139 std::vector<std::vector<double> > Temp2D;
140 std::vector<std::vector<std::vector<double> > > Temp3D;
144 Temp2D.push_back(Temp1D);
145 for (i=0;i<LoopStruct[3];i++)
146 Temp3D.push_back(Temp2D);
149 for(i=0;i<LoopStruct[3];i++){
152 Temp3D[i][j][k]=BrukerHM[(std::string) "ACQ_grad_matrix"].GetDoubleValue()[counter];
160 double BrukerObjectVaryingProperties::getPositionTimePerNR(unsigned int theValue) const{
161 if (theValue <PositionTimePerNR.size() ) return PositionTimePerNR[theValue];
165 void BrukerObjectVaryingProperties::computePositionTimePerNR(std::map<std::string, BrukerFieldData> & BrukerHM, std::vector<int> & LoopStruct){
166 double FloatPositionTimePerNR=BrukerHM[(std::string) "ACQ_repetition_time"].GetDoubleValue()[0];
168 int NA=BrukerHM[(std::string) "NA"].GetIntValue()[0];
169 int NAE=BrukerHM[(std::string) "NAE"].GetIntValue()[0];
173 les loop de 0 a 3 ne sont pas concernes par le temps car ils creent presque systematiquement
174 un melange temporel des donnees, c'est pour cela que je ne calcule qu'un temps moyen a partir de celles -ci
176 for (i=4; i<(LoopStruct.size()-1);i++)
178 FloatPositionTimePerNR=FloatPositionTimePerNR*LoopStruct[i];
180 FloatPositionTimePerNR=FloatPositionTimePerNR*NA*NAE/2000.0;
181 if (BrukerHM[(std::string) "ACQ_temporal_delay"].GetDoubleValue().size()==1)
183 temp=BrukerHM[(std::string)"ACQ_temporal_delay"].GetDoubleValue()[0]/1000.0;
184 for (i=1; i<=LoopStruct.back();i++)
186 PositionTimePerNR.push_back(FloatPositionTimePerNR+ (2*FloatPositionTimePerNR+temp)*(i-1));
190 if (BrukerHM[(std::string) "ACQ_temporal_delay"].GetDoubleValue().size()!=1&& BrukerHM[(std::string) "ACQ_temporal_delay"].GetDoubleValue().size()!=(LoopStruct.back()-1))
194 if (BrukerHM[(std::string) "ACQ_temporal_delay"].GetDoubleValue().size()!=1&& BrukerHM[(std::string) "ACQ_temporal_delay"].GetDoubleValue().size()==(LoopStruct.back()-1))
196 PositionTimePerNR[0] = FloatPositionTimePerNR;
197 for (int i=1; i<=LoopStruct.back();i++)
199 PositionTimePerNR[i] = PositionTimePerNR[i-1]+ (2*FloatPositionTimePerNR+BrukerHM[(std::string) "ACQ_temporal_delay"].GetDoubleValue()[i-1]/1000.0);
206 \fn BrukerObjectVaryingProperties::init(std::map<std::string, BrukerFieldData> BrukerHM,std::vector<int> LoopStruct)
208 bool BrukerObjectVaryingProperties::init(std::map<std::string, BrukerFieldData> & BrukerHM, std::vector<int> & LoopStruct)
211 computeAcquisitionOrder (BrukerHM, LoopStruct);
212 computeOrientation (BrukerHM, LoopStruct);
213 computePositionP (BrukerHM);
214 computePositionR (BrukerHM);
215 computePositionS (BrukerHM);
216 computePositionTimePerNR(BrukerHM, LoopStruct);
217 computeTE (BrukerHM);
222 std::cout << "Failure during BrukerObjectVaryingProperties::init " << std::endl;