2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------
28 /*=========================================================================
31 Module: $RCSfile: testBruker2Dicom.cxx,v $
33 Date: $Date: 2012/11/15 13:31:58 $
34 Version: $Revision: 1.12 $
37 This software is distributed WITHOUT ANY WARRANTY; without even
38 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
39 PURPOSE. See the above copyright notices for more information.
41 =========================================================================*/
44 * Transform private Bruker tree structure
45 * into the equivalent, with DICOM files *and/or* MHD files.
48 #include "bruker2dicom.h"
50 #include "gdcmCommon.h"
51 #include "gdcmDebug.h"
53 #include "gdcmDirList.h"
55 #include "gdcmArgMgr.h"
57 #include "bruker2dicom.h"
58 #include "brukerexception.h"
60 // ===================================================================================================
63 * - explores the given root directory e.g. :
76 * 1 // only 'native' images
83 * CreatisComputedCartoFile
84 * 2 // post processed images (if any)
92 * 3 // post processed images (if any)
107 * - fills an equivalent Directory with the MHD / DICOM files,
111 int main(int argc, char *argv[])
114 " \n testBruker2Dicom : \n ",
115 " - explores the given directory (holding a FULL Bruker exam), at the 3 levels,",
116 " - fills an equivalent Directory with the MHD files and/or the DICOM files",
117 " usage: testBruker2Dicom --dirin=rootDirectoryName ",
118 " --dirout=outputDirectoryName ",
120 " [{-b|-l}] b:BigEndian,l:LittleEndian default : l ",
121 " [--debug] [--verbose] [--listonly] [--usage] ",
123 " D : user wants to export as DICOM ",
124 " M : user wants to export as MHD ",
125 " debug : developper wants to run the program in 'debug mode' ",
128 " If you were supplied an *incomplete* Bruker exam ",
129 " (e.g. only the '2' serie) put it a 'root' directory, ",
130 " and run this test using this 'root' directory as 'dirin' ",
133 // ------------ Initialize Arguments Manager ----------------
134 GDCM_NAME_SPACE::ArgMgr *am= new GDCM_NAME_SPACE::ArgMgr(argc, argv);
136 if (argc == 1 || am->ArgMgrDefined("--usage") )
138 am->ArgMgrUsage(usage); // Display 'usage'
143 // create the devilish object!
146 const char *dirNamein;
147 dirNamein = am->ArgMgrGetString("--dirin",".");
149 const char *dirNameout;
150 dirNameout = am->ArgMgrGetString("--dirout",".");
152 // note : Big Endian / Little Endian pb not yet dealt with.
153 // not a great issue, since everybody (?) works on Intell procs
154 int b = am->ArgMgrDefined("-b");
155 int l = am->ArgMgrDefined("-l");
157 if (am->ArgMgrDefined("--debug"))
158 GDCM_NAME_SPACE::Debug::DebugOn();
160 b2d.verbose = am->ArgMgrDefined("--verbose");
161 int listonly = am->ArgMgrDefined("--listonly");
163 int dicom = am->ArgMgrDefined("-D");
164 int mhd = am->ArgMgrDefined("-M");
167 b2d.SetConvertModeToDicom();
169 b2d.SetConvertModeToMhd();
171 /* if unused Param we give up */
172 if ( am->ArgMgrPrintUnusedLabels() )
174 am->ArgMgrUsage(usage);
179 // patientName : found in Bruker parameter files
180 // patientName = am->ArgMgrGetString("patientname", "Patient^Name");
182 // b2d.day : unused ...
183 b2d.day = am->ArgMgrGetString("day", "You_forget_the_Day");
185 delete am; // we don't need Argument Manager any longer
187 // ----------- End Arguments Manager ---------
190 // ----- Begin Processing -----
192 b2d.SetInputDirectory(dirNamein);
193 b2d.SetOutputDirectory(dirNameout);
195 /// \TODO : *do* use exceptions in the methods!
202 std::cout << "Exception was thrown (" << i << ") " << std::endl;
205 catch (std::exception& e) {
206 std::cerr << "ERREUR: " << e.what() << "expected length: " << e.getExpectedLgt()
207 << " Found : " << e.getFoundLgt() << std::endl;
211 catch (BrukerHopelessException &e)
213 std::cout << "And Hopless Exception was thrown (" << e.what() << ") " << std::endl;