1 /*=========================================================================
4 Module: $RCSfile: testBruker2Dicom.cxx,v $
6 Date: $Date: 2009/05/27 10:43:07 $
7 Version: $Revision: 1.4 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
20 * Transform private Bruker tree structure
21 * into the equivalent, with DICOM files *and/or* MHD files.
24 #include "bruker2dicom.h"
26 #include "gdcmCommon.h"
27 #include "gdcmDebug.h"
29 #include "gdcmDirList.h"
31 #include "gdcmArgMgr.h"
33 #include "bruker2dicom.h"
35 // ===================================================================================================
38 * - explores the given root directory e.g. :
51 * 1 // only 'native' images
58 * CreatisComputedCartoFile
59 * 2 // post processed images (if any)
67 * 3 // post processed images (if any)
82 * - fills a single level Directory with the MHD files,
86 int main(int argc, char *argv[])
89 " \n testBruker2Dicom : \n ",
90 " - explores the given directory, at the 3 levels, ",
91 " - fills an equivalent Directory with the MHD files or the DICOM files ",
92 " usage: testBruker2Dicom dirin=rootDirectoryName ",
93 " dirout=outputDirectoryName ",
95 " [{b|l}] b:BigEndian,l:LittleEndian default : l ",
96 " [debug] [verbose] [listonly] ",
98 " D : user wants to export as DICOM ",
99 " M : user wants to export as MHD ",
100 " debug : developper wants to run the program in 'debug mode' ",
103 // ------------ Initialize Arguments Manager ----------------
104 GDCM_NAME_SPACE::ArgMgr *am= new GDCM_NAME_SPACE::ArgMgr(argc, argv);
106 if (argc == 1 || am->ArgMgrDefined("usage") )
108 am->ArgMgrUsage(usage); // Display 'usage'
113 // create the devilish object!
116 const char *dirNamein;
117 dirNamein = am->ArgMgrGetString("dirin",".");
119 const char *dirNameout;
120 dirNameout = am->ArgMgrGetString("dirout",".");
122 // note : Big Endian / Little Endian pb not yet dealt with.
123 // not a great issue, since everybody (?) works on Intell procs
124 int b = am->ArgMgrDefined("b");
125 int l = am->ArgMgrDefined("l");
127 if (am->ArgMgrDefined("debug"))
128 GDCM_NAME_SPACE::Debug::DebugOn();
130 b2d.verbose = am->ArgMgrDefined("verbose");
131 int listonly = am->ArgMgrDefined("listonly");
133 int dicom = am->ArgMgrDefined("D");
134 int mhd = am->ArgMgrDefined("M");
137 b2d.SetConvertModeToDicom();
139 b2d.SetConvertModeToMhd();
141 /* if unused Param we give up */
142 if ( am->ArgMgrPrintUnusedLabels() )
144 am->ArgMgrUsage(usage);
149 // patientName : found in Bruker parameter files
150 // patientName = am->ArgMgrGetString("patientname", "Patient^Name");
152 // b2d.day : unused ...
153 b2d.day = am->ArgMgrGetString("day", "You_forget_the_Day");
157 // ----------- End Arguments Manager ---------
160 // ----- Begin Processing -----
162 b2d.SetInputDirectory(dirNamein);
163 b2d.SetOutputDirectory(dirNameout);
165 /// \TODO : *do* use exceptions in the methods!
172 std::cout << "Exception was thrown (" << i << ") " << std::endl;
175 catch (std::exception& e) {
176 std::cerr << "ERREUR: " << e.what() << "expected length: " << e.getExpectedLgt()
177 << " Found : " << e.getFoundLgt() << std::endl;
183 delete am; // we don't need Argument Manager any longer