2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------
33 #include "brukerdataset.h"
34 #include "brukerkspaceobject.h"
35 #include "brukerimage.h"
38 int main(int argc, char *argv[])
40 BrukerDataSet acqp1, reco1;
41 std::string file2Read1("/home/denis/TestDicom/kiwidicom.QZ1/3/acqp");
42 std::string file2Read2("/home/denis/TestDicom/kiwidicom.QZ1/3/pdata/1/reco");
43 //std::string file2Read("/home/denis/TestDicom/mcao31a.pc1-exam_fabien/6/acqp");
44 //std::string file2Read("/home/denis/TestDicom/mcao31a.pc1-exam_fabien/6/pdata/1/reco");
45 //std::string file2Read("/home/denis/TestDicom/mcao31a.pc1-exam_fabien/6/acqp");
46 acqp1.LoadFile(file2Read1);
47 reco1.LoadFile(file2Read2);
48 std::cout << "=============== acqp1 FillMap =================" << std::endl;
51 std::cout << "=============== End acqp1 FillMap =================" << std::endl;
52 std::cout << "=============== reco1 FillMap =================" << std::endl;
55 std::cout << "=============== End reco1 FillMap =================" << std::endl;
59 std::cout << "=============== BuildLoopStructure =================" << std::endl;
61 // LoopStructure is used to control the way the loops can be unrolled (in ObjectsLineList)
62 acqp1.SetLoopStructure();
63 std::vector<int> TempVect = acqp1.GetLoopStructure() ;
64 for(int i=0;i<TempVect.size();i++){
65 std::cout<<"GenericLoopStructure["<<i<<"]="<<TempVect[i]<<std::endl;
67 std::cout << "=============== End BuildLoopStructure =================" << std::endl;
69 std::cout << "=============== SetBrukerObjectsLineStructure =================" << std::endl;
71 // ObjectsLineList is a matrix containing for each line acquired which was its position in the acquisition loop
72 // This position do not take into account an eventual slice interleaved acquisition
74 acqp1.SetBrukerObjectsLineList();
75 std::vector<std::vector<int> > TempMat=acqp1.GetBrukerObjectsLineList();
76 std::map<std::string, BrukerFieldData> Map=acqp1.GetBrukerHeaderMap();
78 //ObjectVaryingProperties is a method centralizing the access to "all" the varying properties of images like position, orientation, echo time, .....
79 //It needs the BrukerHeaderMap and the LoopStructure as input
81 bool result=acqp1.ObjectVaryingProperties.init(Map,TempVect);
82 int Reordered,i,j,k,l;
83 std::vector<std::vector<double> > TempMat2;
84 for(int i=0;i<TempMat.size();i++){
85 std::cout<<std::endl<<"["<<i<<"] ";
86 for (int j=0;j<TempMat[0].size();j++)
87 std::cout<< "["<<TempMat[i][j]<<"] ";
88 // fugly trick but sofar the eventual interleaved information applies to the slice loop =>BrukerObjectsLineList[*][2]
89 Reordered=acqp1.ObjectVaryingProperties.getAcquisitionOrder(TempMat[i][2]);
90 std::cout<<" TE = "<<acqp1.ObjectVaryingProperties.getTE(TempMat[i][0]);
91 // And the Reordering applies to values "constructed" exterior to the slice loop (ie : BrukerObjectsLineList[*][>=2])
92 std::cout<<" [R,P,S]xyz = ["<<acqp1.ObjectVaryingProperties.getPositionR(Reordered);
93 std::cout<<" , "<<acqp1.ObjectVaryingProperties.getPositionP(Reordered);
94 std::cout<<" , "<<acqp1.ObjectVaryingProperties.getPositionS(Reordered)<<"] ";
95 TempMat2=acqp1.ObjectVaryingProperties.getOrientation(Reordered);
96 std::cout<<" [R,P,S]orient = [";
99 for (l=0;l<=2;l++) std::cout<< TempMat2[k][l]<<" ";
103 std::cout<<" Slice Number = "<<Reordered<<" ";
104 std::cout<<" TimePositionPerNR = "<<acqp1.ObjectVaryingProperties.getPositionTimePerNR(TempMat[i].back());
106 std::cout<<std::endl;
107 std::cout << "=============== End SetBrukerObjectsLineStructure =================" << std::endl;
109 //Same routine as above but instead of scruting the loop structure of raw data
110 //we deal with an image structure so the loops used to construct an image do not appear anymore
111 //but apparently the interleaveness stand still
113 std::cout << "=============== Begin BrukerImageStructure=================" << std::endl;
114 acqp1.SetImageLoopStructure();
115 acqp1.SetBrukerImageList();
116 std::vector<std::vector<int> > BrukerImageList=acqp1.GetBrukerImageList();
117 std::vector<std::vector<double> > BrukerImageList2;
118 for(int i=0;i<BrukerImageList.size();i++){
119 std::cout<<std::endl<<"["<<i<<"] ";
120 for (int j=0;j<BrukerImageList[0].size();j++)
121 std::cout<< "["<<BrukerImageList[i][j]<<"] ";
122 Reordered=acqp1.ObjectVaryingProperties.getAcquisitionOrder(BrukerImageList[i][2]);
123 std::cout<<" TE = "<<acqp1.ObjectVaryingProperties.getTE(BrukerImageList[i][0]);
124 std::cout<<" [R,P,S]xyz = ["<<acqp1.ObjectVaryingProperties.getPositionR(Reordered);
125 std::cout<<" , "<<acqp1.ObjectVaryingProperties.getPositionP(Reordered);
126 std::cout<<" , "<<acqp1.ObjectVaryingProperties.getPositionS(Reordered)<<"] ";
127 BrukerImageList2=acqp1.ObjectVaryingProperties.getOrientation(Reordered);
128 std::cout<<" [R,P,S]orient = [";
132 std::cout<< BrukerImageList2[k][l]<<" ";
136 std::cout<<" Slice Number = "<<Reordered<<" ";
137 std::cout<<" TimePositionPerNR = "<<acqp1.ObjectVaryingProperties.getPositionTimePerNR(BrukerImageList[i].back());
139 std::cout<<std::endl;
140 std::cout << "=============== End BrukerImageStructure=============" << std::endl;
143 BrukerImage Image(acqp1,reco1);
144 Image.Init(acqp1,reco1,1);
145 std::vector<BrukerImage> ImageSet;
147 for(int i=0;i<BrukerImageList.size();i++){
148 Image.Init(acqp1,reco1,i);
149 ImageSet.push_back(Image);
152 std::string fid("/home/denis/TestDicom/kiwidicom.QZ1/3/fid");
153 std::cout << "=============== Getkspace =================" << std::endl;
154 acqp1.Getkspace(fid);
155 std::cout << "=============== End Getkspace =================" << std::endl;