]> Creatis software - creaBruker.git/blob - appli/exObjectVaryingProperties/main.cxx
Added CMake configuration to enable CDash tests.
[creaBruker.git] / appli / exObjectVaryingProperties / main.cxx
1 /*
2         # ---------------------------------------------------------------------
3         #
4         # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
5         #                        pour la Santé)
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
9         #
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.
16         #
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
21         #  liability. 
22         #
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         # ------------------------------------------------------------------------
26 */
27 #ifdef HAVE_CONFIG_H
28 #include <config.h>
29 #endif
30
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include "brukerdataset.h"
34 #include "brukerkspaceobject.h"
35 #include "brukerimage.h"
36
37
38 int main(int argc, char *argv[])
39 {
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;
49    acqp1.FillMap();
50    acqp1.PrintSelf();
51    std::cout << "=============== End acqp1 FillMap =================" << std::endl;
52    std::cout << "=============== reco1 FillMap =================" << std::endl;
53    reco1.FillMap();
54    reco1.PrintSelf();
55    std::cout << "=============== End reco1 FillMap =================" << std::endl;
56
57
58
59    std::cout << "=============== BuildLoopStructure =================" << std::endl;
60    
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;
66    }
67    std::cout << "=============== End BuildLoopStructure =================" << std::endl;
68
69    std::cout << "=============== SetBrukerObjectsLineStructure =================" << std::endl;
70
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
73
74    acqp1.SetBrukerObjectsLineList();
75    std::vector<std::vector<int> > TempMat=acqp1.GetBrukerObjectsLineList();
76    std::map<std::string, BrukerFieldData> Map=acqp1.GetBrukerHeaderMap();
77    
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
80
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 = [";
97       for (k=0;k<=2;k++){ 
98          std::cout << "[";
99          for (l=0;l<=2;l++) std::cout<< TempMat2[k][l]<<"  ";
100             std::cout<<"]";
101       }
102       std::cout<<"]";
103       std::cout<<"    Slice Number = "<<Reordered<<"  ";
104       std::cout<<" TimePositionPerNR = "<<acqp1.ObjectVaryingProperties.getPositionTimePerNR(TempMat[i].back());
105    }
106    std::cout<<std::endl;
107    std::cout << "=============== End SetBrukerObjectsLineStructure =================" << std::endl;
108
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
112
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 = [";
129       for (k=0;k<=2;k++){ 
130          std::cout << "[";
131          for (l=0;l<=2;l++) 
132             std::cout<< BrukerImageList2[k][l]<<"  ";
133          std::cout<<"]";
134       }
135       std::cout<<"]";
136       std::cout<<"    Slice Number = "<<Reordered<<"  ";
137       std::cout<<" TimePositionPerNR = "<<acqp1.ObjectVaryingProperties.getPositionTimePerNR(BrukerImageList[i].back());
138    }
139    std::cout<<std::endl;
140    std::cout << "=============== End  BrukerImageStructure=============" << std::endl;
141
142
143    BrukerImage Image(acqp1,reco1);
144    Image.Init(acqp1,reco1,1);
145    std::vector<BrukerImage> ImageSet;
146
147    for(int i=0;i<BrukerImageList.size();i++){
148       Image.Init(acqp1,reco1,i);
149       ImageSet.push_back(Image);
150    };
151
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;
156    return EXIT_SUCCESS;
157 }