]> Creatis software - creaBruker.git/blob - appli/essaiDenis/essaiDenis.cpp
Initial revision
[creaBruker.git] / appli / essaiDenis / essaiDenis.cpp
1 #ifdef HAVE_CONFIG_H
2 #include <config.h>
3 #endif
4
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include "brukerdataset.h"
8 #include "brukerkspaceobject.h"
9 #include "brukerimage.h"
10
11
12 int main(int argc, char *argv[])
13 {
14    BrukerDataSet acqp1, reco1;
15    std::string file2Read1("/home/denis/TestDicom/kiwidicom.QZ1/3/acqp");
16    std::string file2Read2("/home/denis/TestDicom/kiwidicom.QZ1/3/pdata/1/reco");
17    //std::string file2Read("/home/denis/TestDicom/mcao31a.pc1-exam_fabien/6/acqp");
18    //std::string file2Read("/home/denis/TestDicom/mcao31a.pc1-exam_fabien/6/pdata/1/reco");
19    //std::string file2Read("/home/denis/TestDicom/mcao31a.pc1-exam_fabien/6/acqp");
20    acqp1.LoadFile(file2Read1);
21    reco1.LoadFile(file2Read2);
22    std::cout << "=============== acqp1 FillMap =================" << std::endl;
23    acqp1.FillMap();
24    acqp1.PrintSelf();
25    std::cout << "=============== End acqp1 FillMap =================" << std::endl;
26    std::cout << "=============== reco1 FillMap =================" << std::endl;
27    reco1.FillMap();
28    reco1.PrintSelf();
29    std::cout << "=============== End reco1 FillMap =================" << std::endl;
30
31
32
33    std::cout << "=============== BuildLoopStructure =================" << std::endl;
34    
35 // LoopStructure is used to control the way the loops can be unrolled (in ObjectsLineList)
36    acqp1.SetLoopStructure();
37    std::vector<int> TempVect = acqp1.GetLoopStructure() ;
38    for(int i=0;i<TempVect.size();i++){
39       std::cout<<"GenericLoopStructure["<<i<<"]="<<TempVect[i]<<std::endl;
40    }
41    std::cout << "=============== End BuildLoopStructure =================" << std::endl;
42
43    std::cout << "=============== SetBrukerObjectsLineStructure =================" << std::endl;
44
45 // ObjectsLineList is a matrix containing for each line acquired which was its position in the acquisition loop
46 // This position do not take into account an eventual slice interleaved acquisition
47
48    acqp1.SetBrukerObjectsLineList();
49    std::vector<std::vector<int> > TempMat=acqp1.GetBrukerObjectsLineList();
50    std::map<std::string, BrukerFieldData> Map=acqp1.GetBrukerHeaderMap();
51    
52 //ObjectVaryingProperties is a method centralizing the access to "all" the varying properties of images like position, orientation, echo time, .....
53 //It needs the BrukerHeaderMap and the LoopStructure as input
54
55    bool result=acqp1.ObjectVaryingProperties.init(Map,TempVect);
56    int  Reordered,i,j,k,l;
57    std::vector<std::vector<double> > TempMat2;
58   for(int i=0;i<TempMat.size();i++){
59       std::cout<<std::endl<<"["<<i<<"] ";
60       for (int j=0;j<TempMat[0].size();j++)  
61          std::cout<< "["<<TempMat[i][j]<<"] ";
62 // fugly trick but sofar the eventual interleaved information applies to the slice loop =>BrukerObjectsLineList[*][2]
63       Reordered=acqp1.ObjectVaryingProperties.getAcquisitionOrder(TempMat[i][2]);
64       std::cout<<" TE = "<<acqp1.ObjectVaryingProperties.getTE(TempMat[i][0]);
65 // And the Reordering applies to values "constructed" exterior to the slice loop (ie : BrukerObjectsLineList[*][>=2])
66       std::cout<<"   [R,P,S]xyz = ["<<acqp1.ObjectVaryingProperties.getPositionR(Reordered);
67       std::cout<<" , "<<acqp1.ObjectVaryingProperties.getPositionP(Reordered);
68       std::cout<<" , "<<acqp1.ObjectVaryingProperties.getPositionS(Reordered)<<"]  ";
69       TempMat2=acqp1.ObjectVaryingProperties.getOrientation(Reordered);
70       std::cout<<"   [R,P,S]orient = [";
71       for (k=0;k<=2;k++){ 
72          std::cout << "[";
73          for (l=0;l<=2;l++) std::cout<< TempMat2[k][l]<<"  ";
74             std::cout<<"]";
75       }
76       std::cout<<"]";
77       std::cout<<"    Slice Number = "<<Reordered<<"  ";
78       std::cout<<" TimePositionPerNR = "<<acqp1.ObjectVaryingProperties.getPositionTimePerNR(TempMat[i].back());
79    }
80    std::cout<<std::endl;
81    std::cout << "=============== End SetBrukerObjectsLineStructure =================" << std::endl;
82
83 //Same routine as above but instead of scruting the loop structure of raw data
84 //we deal with an image structure so the loops used to construct an image do not appear anymore 
85 //but apparently the interleaveness stand still
86
87    std::cout << "=============== Begin BrukerImageStructure=================" << std::endl;
88    acqp1.SetImageLoopStructure();
89    acqp1.SetBrukerImageList();
90    std::vector<std::vector<int> > BrukerImageList=acqp1.GetBrukerImageList();
91    std::vector<std::vector<double> > BrukerImageList2;
92    for(int i=0;i<BrukerImageList.size();i++){
93  
94
95       std::cout<<std::endl<<"["<<i<<"] ";
96       for (int j=0;j<BrukerImageList[0].size();j++)  
97          std::cout<< "["<<BrukerImageList[i][j]<<"] ";
98       Reordered=acqp1.ObjectVaryingProperties.getAcquisitionOrder(BrukerImageList[i][2]);
99       std::cout<<" TE = "<<acqp1.ObjectVaryingProperties.getTE(BrukerImageList[i][0]);
100       std::cout<<"   [R,P,S]xyz = ["<<acqp1.ObjectVaryingProperties.getPositionR(Reordered);
101       std::cout<<" , "<<acqp1.ObjectVaryingProperties.getPositionP(Reordered);
102       std::cout<<" , "<<acqp1.ObjectVaryingProperties.getPositionS(Reordered)<<"]  ";
103       BrukerImageList2=acqp1.ObjectVaryingProperties.getOrientation(Reordered);
104       std::cout<<"   [R,P,S]orient = [";
105       for (k=0;k<=2;k++){ 
106          std::cout << "[";
107          for (l=0;l<=2;l++) 
108             std::cout<< BrukerImageList2[k][l]<<"  ";
109          std::cout<<"]";
110       }
111       std::cout<<"]";
112       std::cout<<"    Slice Number = "<<Reordered<<"  ";
113       std::cout<<" TimePositionPerNR = "<<acqp1.ObjectVaryingProperties.getPositionTimePerNR(BrukerImageList[i].back());
114    }
115    std::cout<<std::endl;
116    std::cout << "=============== End  BrukerImageStructure=============" << std::endl;
117
118
119    BrukerImage Image(acqp1,reco1);
120    Image.Init(acqp1,reco1,1);
121    std::vector<BrukerImage> ImageSet;
122
123    for(int i=0;i<BrukerImageList.size();i++){
124       Image.Init(acqp1,reco1,i);
125       ImageSet.push_back(Image);
126    }
127
128    std::string fid("/home/denis/TestDicom/kiwidicom.QZ1/3/fid");
129    std::cout << "=============== Getkspace =================" << std::endl;
130    acqp1.Getkspace(fid); 
131    std::cout << "=============== End Getkspace =================" << std::endl;
132    return EXIT_SUCCESS;
133 }
134