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"
16 BrukerObjectVaryingProperties::BrukerObjectVaryingProperties()
21 BrukerObjectVaryingProperties::~BrukerObjectVaryingProperties()
27 void BrukerObjectVaryingProperties::setPositionS(std::map<std::string, BrukerFieldData> & BrukerHM){
28 std::vector<double> PosiS =BrukerHM[(std::string) "ACQ_slice_offset"].GetDoubleValue();
32 void BrukerObjectVaryingProperties::setPositionR(std::map<std::string, BrukerFieldData> & BrukerHM){
33 PositionR =BrukerHM[(std::string) "ACQ_read_offset"].GetDoubleValue() ;
36 void BrukerObjectVaryingProperties::setPositionP(std::map<std::string, BrukerFieldData> & BrukerHM){
37 PositionP =BrukerHM[(std::string) "ACQ_phase1_offset"].GetDoubleValue();
40 void BrukerObjectVaryingProperties::setTE(std::map<std::string, BrukerFieldData> & BrukerHM){
41 TE = BrukerHM[(std::string) "ACQ_echo_time"].GetDoubleValue();
44 double BrukerObjectVaryingProperties::getTE(int theValue) const{
45 if (theValue < TE.size() && theValue >=0) {return TE[theValue];}
49 /*void BrukerObjectVaryingProperties::setTE(const std::vector< double >& theValue)
54 double BrukerObjectVaryingProperties::getPositionP(int theValue) const{
55 if (theValue < PositionP.size() && theValue >=0) return PositionP[theValue];
59 /*void BrukerObjectVaryingProperties::setPositionP(const std::vector< double >& theValue)
64 double BrukerObjectVaryingProperties::getPositionR(int theValue) const{
65 if (theValue < PositionR.size() && theValue >=0) return PositionR[theValue];
69 /*void BrukerObjectVaryingProperties::setPositionR(const std::vector< double >& theValue)
74 double BrukerObjectVaryingProperties::getPositionS(int theValue) const{
75 if (theValue < PositionS.size() && theValue >=0) return PositionS[theValue];
79 /*void BrukerObjectVaryingProperties::setPositionS(const std::vector< double >& theValue)
84 int BrukerObjectVaryingProperties::getAcquisitionOrder(int theValue) const{
85 if (theValue <AcquisitionOrder.size() && theValue >=0) return AcquisitionOrder[theValue];
89 /*void BrukerObjectVaryingProperties::setAcquisitionOrder(const std::vector< int >& theValue1, const std::vector< int >& theValue2)
91 AcquisitionOrder.clear();
92 if (theValue1.size() != theValue2[3]*theValue2[1]) throw 0;
93 if (theValue2.size() < 4 ) throw 0;
94 for (int i =0 ;i<theValue2[3];i++)AcquisitionOrder.push_back()=(int) theValue1[i*theValue2[1]]/theValue2[1];
97 void BrukerObjectVaryingProperties::setAcquisitionOrder(std::map<std::string, BrukerFieldData> & BrukerHM, std::vector<int> & LoopStruct){
98 std::vector<int> AcqOrder;
99 if (BrukerHM[(std::string) "ACQ_obj_order"].GetIntValue().size() != LoopStruct[3]*LoopStruct[1]) throw 0;
100 if (LoopStruct.size() < 4 ) throw 0;
101 for (int i =0 ;i<LoopStruct[3];i++)
102 AcqOrder.push_back((int) BrukerHM[(std::string) "ACQ_obj_order"].GetIntValue()[i*LoopStruct[1]]/LoopStruct[1]);
103 AcquisitionOrder=AcqOrder;
106 std :: vector < std :: vector < double > > BrukerObjectVaryingProperties::getOrientation(int theValue) const{
107 if (theValue <Orientation.size() && theValue >=0)return Orientation[theValue];
111 /*void BrukerObjectVaryingProperties::setOrientation( std :: vector < double > & theValue1,const std::vector< int >& theValue2)
113 if (theValue1.size() != theValue2[3]*9) throw 0;
114 if (theValue2.size() < 4 ) throw 0;
116 for(int i=0;i<theValue2[3];i++){
117 for(int j=0;j<3;j++){
118 for(int k=0;k<3;k++){
119 Orientation[i][j][k]=theValue1[counter];
126 void BrukerObjectVaryingProperties::setOrientation(std::map<std::string, BrukerFieldData> & BrukerHM, std::vector<int> & LoopStruct){
127 if (BrukerHM[(std::string) "ACQ_grad_matrix"].GetDoubleValue().size() != LoopStruct[3]*9) throw 0;
128 if (LoopStruct.size() < 4 ) throw 0;
130 std::vector<double> Temp1D(3,0.0);
131 std::vector<std::vector<double> > Temp2D;
132 std::vector<std::vector<std::vector<double> > > Temp3D;
136 Temp2D.push_back(Temp1D);
137 for (i=0;i<LoopStruct[3];i++)
138 Temp3D.push_back(Temp2D);
141 for(i=0;i<LoopStruct[3];i++){
144 Temp3D[i][j][k]=BrukerHM[(std::string) "ACQ_grad_matrix"].GetDoubleValue()[counter];
152 double BrukerObjectVaryingProperties::getPositionTimePerNR(int theValue) const{
153 if (theValue <PositionTimePerNR.size() && theValue >=0) return PositionTimePerNR[theValue];
157 void BrukerObjectVaryingProperties::setPositionTimePerNR(std::map<std::string, BrukerFieldData> & BrukerHM, std::vector<int> & LoopStruct){
158 double FloatPositionTimePerNR=BrukerHM[(std::string) "ACQ_repetition_time"].GetDoubleValue()[0];
160 int NA=BrukerHM[(std::string) "NA"].GetIntValue()[0];
161 int NAE=BrukerHM[(std::string) "NAE"].GetIntValue()[0];
165 les loop de 0 a 3 ne sont pas conceres par le temps car ils creent presque systematiquement
166 un melange temporel des donnees, c'est pour cela que je ne calcule q'un temps moyen a partir de celles -ci
168 for (i=4; i<(LoopStruct.size()-1);i++)
170 FloatPositionTimePerNR=FloatPositionTimePerNR*LoopStruct[i];
172 FloatPositionTimePerNR=FloatPositionTimePerNR*NA*NAE/2000.0;
173 if (BrukerHM[(std::string) "ACQ_temporal_delay"].GetDoubleValue().size()==1)
175 temp=BrukerHM[(std::string)"ACQ_temporal_delay"].GetDoubleValue()[0]/1000.0;
176 for (i=1; i<=LoopStruct.back();i++)
178 PositionTimePerNR.push_back(FloatPositionTimePerNR+ (2*FloatPositionTimePerNR+temp)*(i-1));
182 if (BrukerHM[(std::string) "ACQ_temporal_delay"].GetDoubleValue().size()!=1&& BrukerHM[(std::string) "ACQ_temporal_delay"].GetDoubleValue().size()!=(LoopStruct.back()-1))
186 if (BrukerHM[(std::string) "ACQ_temporal_delay"].GetDoubleValue().size()!=1&& BrukerHM[(std::string) "ACQ_temporal_delay"].GetDoubleValue().size()==(LoopStruct.back()-1))
188 PositionTimePerNR[0] = FloatPositionTimePerNR;
189 for (int i=1; i<=LoopStruct.back();i++)
191 PositionTimePerNR[i] = PositionTimePerNR[i-1]+ (2*FloatPositionTimePerNR+BrukerHM[(std::string) "ACQ_temporal_delay"].GetDoubleValue()[i-1]/1000.0);
198 \fn BrukerObjectVaryingProperties::init(std::map<std::string, BrukerFieldData> BrukerHM,std::vector<int> LoopStruct)
200 bool BrukerObjectVaryingProperties::init(std::map<std::string, BrukerFieldData> & BrukerHM, std::vector<int> & LoopStruct)
202 setAcquisitionOrder( BrukerHM, LoopStruct);
203 setOrientation(BrukerHM, LoopStruct);
204 setPositionP(BrukerHM);
205 setPositionR(BrukerHM);
206 setPositionS(BrukerHM);
207 setPositionTimePerNR(BrukerHM, LoopStruct);