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