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