]> Creatis software - creaBruker.git/blob - lib/src1/bruker2dicom.h
Added CMake configuration to enable CDash tests.
[creaBruker.git] / lib / src1 / bruker2dicom.h
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 #ifndef BRUKER2DICOM_H
28 #define BRUKER2DICOM_H
29
30
31 #include "gdcmFile.h"
32 #include "gdcmFileHelper.h"
33 #include "gdcmCommon.h"
34 #include "gdcmDebug.h"
35 #include "gdcmUtil.h"
36 #include "gdcmDirList.h"
37
38 #include "gdcmArgMgr.h"
39 #include "brukerSystem.h"
40 #include "brukerdataset.h"
41 #include "brukerkspaceobject.h"
42 #include "brukerimage.h"
43
44 #include <iostream>
45 #include <sstream>
46
47
48
49 class /*creaBruker_EXPORT*/ Bruker2Dicom {
50
51 public:
52  /*! \brief Constructor
53 */
54   Bruker2Dicom () /* : verbose(0), mhd(0), dicom(0), day(O)*/ {};
55 /*! \brief Destructor
56 */
57   ~Bruker2Dicom (){};
58
59   void SetInputDirectory (const std::string &i) { InputDirName   = i;}
60   void SetOutputDirectory(const std::string &o) { OutputDirName  = o;}
61   void SetConvertModeToDicom()                  { dicom = 1; mhd = 0;}
62   void SetConvertModeToMhd()                    { dicom = 0; mhd = 1;}  
63   bool Execute();
64   
65   /* 
66   // For debugging pupose only.
67   //Don't need accessors : Attributes are 'public' 
68   
69   void SetVerbose(int v) { verbose = v;}
70   void SetMhd(int m)     { mhd = m;    }
71   void SetDicom(int d)   { dicom = d;  }
72   */     
73
74 private :
75
76 void MakeDicomImage(unsigned char *tabPixels, 
77               int X, 
78               int Y,
79               int nbFrames,
80               int pixelSize,
81               double spacingX, double spacingY, double sliceDistance, 
82               std::string dcmImageName,
83               const std::string &patientName,
84               const char *day,
85               std::string &studyUID,
86               std::string &serieUID,
87               std::string &studyDescr,
88               std::string &serieDescr,
89               std::string &strStudyTimeDate,
90               int imgNum,
91               GDCM_NAME_SPACE::ImageContentType contentType 
92       );
93       
94 std::vector<BrukerImage> CreateImageSet ( int dimension);
95
96 void getImhDataType(BrukerFieldData &bDPT, 
97                     std::string &mhdDataPixelType, 
98                     int &pixelSize);
99                     
100 void cleanString(std::string &s);
101
102 bool CreateDirectory(std::string &dirNameout);
103
104 int CheckUserDirectory(std::string &userDirName);
105 void DealWithMultiStudyDirectory(GDCM_NAME_SPACE::DirListType &fileNames,int dimension);
106 void DealWithSingleStudyDirectory(GDCM_NAME_SPACE::DirListType &fileNames, int dimension);
107 void DealWithNiveau1(std::string &level1Directory, std::string &currentOutputDirName, int dimension);
108 void DealWithNiveau2(std::string &level2Directory, std::string &currentOutputDirName, int dimension);
109 void DealWithNiveau3(std::string &level3Directory, std::string &currentOutputDirName, int dimension);
110                     
111 void dealWithCarto(GDCM_NAME_SPACE::DirListType &fileNames, int NX, int NY, int nbSlices, 
112                    double fovX, double fovY, double sliceDistance,
113                    char *copyFile, std::string &currentOutputDirName, 
114                    char *outputMhdFileName, char *output2dseqCartoName);
115 public:
116
117 // these ones are for debugging only
118 // don't bbfy the accessors.
119
120    int verbose;
121    const char *day;
122        
123 private :
124    std::string InputDirName;
125    std::string OutputDirName;
126
127    bool subjectFound;
128    bool acqpFound;
129    
130    std::string subject_entry;
131    std::string subject_position;
132    std::string subject_date;
133    std::string subject_study_name;
134  
135    int mhd;
136    int dicom;
137      
138    int nbSlices;
139    BrukerDataSet br_subject;
140    BrukerDataSet br_acqp;
141    BrukerDataSet br_method;
142    BrukerDataSet br_d3proc;
143    BrukerDataSet br_isa;
144    BrukerDataSet br_reco;
145
146    std::vector<BrukerImage> imageSet;
147
148 // For DICOM images.
149
150    std::string strStudyUID; 
151    std::string strSerieUID; 
152    std::string strStudyDescr; 
153    std::string strSerieDescr;
154    std::string strStudyTimeDate;
155    std::string strPatientName;
156    std::string subject_name; // cleaned strPatientName
157  
158    int serieNumber;
159    int instanceNumber;      
160 };
161
162 #endif