]> Creatis software - creaBruker.git/blob - lib/src1/bruker2dicom2.h
390ae1f9b35add93261bf33303fc2418d0176b59
[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 class creaBruker_EXPORT  Bruker2Dicom {
47
48 public:
49  /*! \brief Constructor
50 */
51   Bruker2Dicom () /* : verbose(0), mhd(0), dicom(0), day(O)*/ {};
52 /*! \brief Destructor
53 */
54   ~Bruker2Dicom (){};
55
56   void SetInputDirectory (const std::string &i) { InputDirName   = i;}
57   void SetOutputDirectory(const std::string &o) { OutputDirName  = o;}
58   void SetConvertModeToDicom()                  { dicom = 1; mhd = 0;}
59   void SetConvertModeToMhd()                    { dicom = 0; mhd = 1;}  
60   bool Execute();
61   
62   /* 
63   // For debugging pupose only.
64   //Don't need accessors : Attributes are 'public' 
65   
66   void SetVerbose(int v) { verbose = v;}
67   void SetMhd(int m)     { mhd = m;    }
68   void SetDicom(int d)   { dicom = d;  }
69   */     
70
71 private :
72
73 void MakeDicomImage(unsigned char *tabPixels, 
74               int X, 
75               int Y,
76               int nbFrames,
77               int pixelSize,
78               double spacingX, double spacingY, double sliceDistance, 
79               std::string dcmImageName,
80               const std::string &patientName,
81               const char *day,
82               std::string &studyUID,
83               std::string &serieUID,
84               std::string &studyDescr,
85               std::string &serieDescr,
86               std::string &strStudyTimeDate,
87               int imgNum, int  imagecontenttype//gdcm2 dont have such things, I think, as ImageContentTYpe 
88       );
89       
90 std::vector<BrukerImage> CreateImageSet ( );
91
92 void getImhDataType(BrukerFieldData &bDPT, 
93                     std::string &mhdDataPixelType, 
94                     int &pixelSize);
95                     
96 void cleanString(std::string &s);
97
98 bool CreateDirectory(const std::string &dirNameout);
99
100 int CheckUserDirectory(std::string &userDirName);
101 void DealWithMultiStudyDirectory(gdcm::Directory::FilenamesType &fileNames, const std::string &currentOutputDirName);
102 void DealWithSingleStudyDirectory (const std::string dirname,               const std::string currentOutputDirName) ;
103
104 void DealWithNiveau1(std::string level1Directory, std::string currentOutputDirName);
105 void DealWithNiveau2(std::string level2Directory, std::string currentOutputDirName);
106 void DealWithNiveau3(std::string &level3Directory, std::string &currentOutputDirName);
107                     
108 void dealWithCarto(gdcm::Directory::FilenamesType &fileNames, int NX, int NY, int nbSlices, 
109                    double fovX, double fovY, double sliceDistance,
110                    char *copyFile, std::string &currentOutputDirName, 
111                    char *outputMhdFileName, char *output2dseqCartoName);
112
113 const std::string createDirectory(const std::string &i_name,const std::string &i_dir);
114  std::string findFile(const std::string &i_dir, const std::string i_name);
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