1 /*=========================================================================
4 Module: $RCSfile: testBruker2Dicom.cxx,v $
6 Date: $Date: 2009/06/19 15:51:44 $
7 Version: $Revision: 1.5 $
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"
34 #include "brukerexception.h"
36 // ===================================================================================================
39 * - explores the given root directory e.g. :
52 * 1 // only 'native' images
59 * CreatisComputedCartoFile
60 * 2 // post processed images (if any)
68 * 3 // post processed images (if any)
83 * - fills a single level Directory with the MHD files,
87 int main(int argc, char *argv[])
90 " \n testBruker2Dicom : \n ",
91 " - explores the given directory, at the 3 levels, ",
92 " - fills an equivalent Directory with the MHD files or the DICOM files ",
93 " usage: testBruker2Dicom dirin=rootDirectoryName ",
94 " dirout=outputDirectoryName ",
96 " [{b|l}] b:BigEndian,l:LittleEndian default : l ",
97 " [debug] [verbose] [listonly] ",
99 " D : user wants to export as DICOM ",
100 " M : user wants to export as MHD ",
101 " debug : developper wants to run the program in 'debug mode' ",
104 // ------------ Initialize Arguments Manager ----------------
105 GDCM_NAME_SPACE::ArgMgr *am= new GDCM_NAME_SPACE::ArgMgr(argc, argv);
107 if (argc == 1 || am->ArgMgrDefined("usage") )
109 am->ArgMgrUsage(usage); // Display 'usage'
114 // create the devilish object!
117 const char *dirNamein;
118 dirNamein = am->ArgMgrGetString("dirin",".");
120 const char *dirNameout;
121 dirNameout = am->ArgMgrGetString("dirout",".");
123 // note : Big Endian / Little Endian pb not yet dealt with.
124 // not a great issue, since everybody (?) works on Intell procs
125 int b = am->ArgMgrDefined("b");
126 int l = am->ArgMgrDefined("l");
128 if (am->ArgMgrDefined("debug"))
129 GDCM_NAME_SPACE::Debug::DebugOn();
131 b2d.verbose = am->ArgMgrDefined("verbose");
132 int listonly = am->ArgMgrDefined("listonly");
134 int dicom = am->ArgMgrDefined("D");
135 int mhd = am->ArgMgrDefined("M");
138 b2d.SetConvertModeToDicom();
140 b2d.SetConvertModeToMhd();
142 /* if unused Param we give up */
143 if ( am->ArgMgrPrintUnusedLabels() )
145 am->ArgMgrUsage(usage);
150 // patientName : found in Bruker parameter files
151 // patientName = am->ArgMgrGetString("patientname", "Patient^Name");
153 // b2d.day : unused ...
154 b2d.day = am->ArgMgrGetString("day", "You_forget_the_Day");
156 delete am; // we don't need Argument Manager any longer
158 // ----------- End Arguments Manager ---------
161 // ----- Begin Processing -----
163 b2d.SetInputDirectory(dirNamein);
164 b2d.SetOutputDirectory(dirNameout);
166 /// \TODO : *do* use exceptions in the methods!
173 std::cout << "Exception was thrown (" << i << ") " << std::endl;
176 catch (std::exception& e) {
177 std::cerr << "ERREUR: " << e.what() << "expected length: " << e.getExpectedLgt()
178 << " Found : " << e.getFoundLgt() << std::endl;
182 catch (BrukerHopelessException &e)
184 std::cout << "And Hopless Exception was thrown (" << e.what() << ") " << std::endl;