1 /*=========================================================================
4 Module: $RCSfile: testBruker2Dicom.cxx,v $
6 Date: $Date: 2011/04/07 10:16:59 $
7 Version: $Revision: 1.11 $
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 an equivalent Directory with the MHD / DICOM files,
87 int main(int argc, char *argv[])
90 " \n testBruker2Dicom : \n ",
91 " - explores the given directory (holding a FULL Bruker exam), at the 3 levels,",
92 " - fills an equivalent Directory with the MHD files and/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] [--usage] ",
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 " If you were supplied an *incomplete* Bruker exam ",
105 " (e.g. only the '2' serie) put it a 'root' directory, ",
106 " and run this test using this 'root' directory as 'dirin' ",
109 // ------------ Initialize Arguments Manager ----------------
110 GDCM_NAME_SPACE::ArgMgr *am= new GDCM_NAME_SPACE::ArgMgr(argc, argv);
112 if (argc == 1 || am->ArgMgrDefined("--usage") )
114 am->ArgMgrUsage(usage); // Display 'usage'
119 // create the devilish object!
122 const char *dirNamein;
123 dirNamein = am->ArgMgrGetString("--dirin",".");
125 const char *dirNameout;
126 dirNameout = am->ArgMgrGetString("--dirout",".");
128 // note : Big Endian / Little Endian pb not yet dealt with.
129 // not a great issue, since everybody (?) works on Intell procs
130 int b = am->ArgMgrDefined("-b");
131 int l = am->ArgMgrDefined("-l");
133 if (am->ArgMgrDefined("--debug"))
134 GDCM_NAME_SPACE::Debug::DebugOn();
136 b2d.verbose = am->ArgMgrDefined("--verbose");
137 int listonly = am->ArgMgrDefined("--listonly");
139 int dicom = am->ArgMgrDefined("-D");
140 int mhd = am->ArgMgrDefined("-M");
143 b2d.SetConvertModeToDicom();
145 b2d.SetConvertModeToMhd();
147 /* if unused Param we give up */
148 if ( am->ArgMgrPrintUnusedLabels() )
150 am->ArgMgrUsage(usage);
155 // patientName : found in Bruker parameter files
156 // patientName = am->ArgMgrGetString("patientname", "Patient^Name");
158 // b2d.day : unused ...
159 b2d.day = am->ArgMgrGetString("day", "You_forget_the_Day");
161 delete am; // we don't need Argument Manager any longer
163 // ----------- End Arguments Manager ---------
166 // ----- Begin Processing -----
168 b2d.SetInputDirectory(dirNamein);
169 b2d.SetOutputDirectory(dirNameout);
171 /// \TODO : *do* use exceptions in the methods!
178 std::cout << "Exception was thrown (" << i << ") " << std::endl;
181 catch (std::exception& e) {
182 std::cerr << "ERREUR: " << e.what() << "expected length: " << e.getExpectedLgt()
183 << " Found : " << e.getFoundLgt() << std::endl;
187 catch (BrukerHopelessException &e)
189 std::cout << "And Hopless Exception was thrown (" << e.what() << ") " << std::endl;