1 /*=========================================================================
4 Module: $RCSfile: test4DSplitter.cxx,v $
6 Date: $Date: 2011/04/11 11:28:31 $
7 Version: $Revision: 1.6 $
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 =========================================================================*/
19 /* Raisons ne pas utiliser itkImageSeriesReader:
21 On Wed, Feb 16, 2011 at 11:51 AM, Roger Bramon Feixas <rogerbramon@gmail.com>
23 I'm developing with ITK 3.20 + GDCM 2.0.17 + VTK 5.6 and I've noticed
24 itkImageSeriesReader is ~2x slower than vtkGDCMImageReader (from GDCM2).
25 I compared both codes and I think the difference is the extra copy which
26 itkImageSeriesReader makes from ImageFileReader's output to its own output
27 (ImageSeriesReader::GenerateData() line 393). I've commented it just to test
28 the time needed without making the copy and now both readers take more or less
34 #include "gdcmSerieHelper.h"
35 #include <vtkImageData.h>
37 #include "vtkGdcmReader.h"
40 #include "vtkGdcm4DSplitter.h"
46 typedef std::map<std::string, GDCM_NAME_SPACE::File*> SortedFiles;
48 // Due to a deep C++ trouble in 'SortOnTag', we use 'SortOnUserFunction'
49 bool myCompareFunction(GDCM_NAME_SPACE::File *file1, GDCM_NAME_SPACE::File *file2)
51 return atof(file1->GetEntryString(0x0018,0x1060).c_str()) < atof(file2->GetEntryString(0x0018,0x1060).c_str());
54 int main(int argc, char *argv[])
58 std::cout << "... inside " << argv[0] << std::endl;
61 std::string strDirName("/home/jpr/Desktop/Patients_Emilie/Patient.3T/AUB Jos/AUBERTIN JOSEPH/PROSTATE - 305629373/dSSh_DWISENSE_602");
64 //std::string strDirName("/home/jpr/Desktop/Patients_Emilie/Patient.3T/AUB Jos/AUBERTIN JOSEPH/PROSTATE - 305629373/DYN7INJDYN6_901");
67 // ----- Begin Processing -----
69 unsigned short int grSplit;
70 unsigned short int elSplit;
72 unsigned short int grSort;
73 unsigned short int elSort;
75 // Pour un directory '4D'
76 // en sortie, chaque vtkImageData contiendra une coupe au cours du temps
79 std::vector<vtkImageData*> *output;
82 vtkGdcm4DSplitter *spl = new vtkGdcm4DSplitter();
83 spl->setDirName(strDirName);
84 spl->setRecursive(false);
85 spl->setSplitOnPosition();
86 //spl->setSplitOnOrientation();
87 // Time triger : 0018|1060
91 // ==> Big troubles with SortOnTag
92 //spl->setSortOnTag(grSort, elSort);
93 //spl->setSortConvertToFloat(true);
95 // ==> use SortOnUserFunction !
96 spl->setSortOnUserFunction(myCompareFunction);
98 std::cout << "Everything set" << std::endl;
101 std::cout << "GO() done, status " << res << std::endl;
104 std::cout << "plantage!" << std::endl;
107 output = spl->GetImageDataVector();
110 std::cout << "--------------------------------" << std::endl;
111 std::cout << "Vector size " << output->size() << std::endl;
112 std::cout << "--------------------------------" << std::endl;
114 // Print the first one (why not?)
115 //(*output)[0]->PrintSelf(std::cout, vtkIndent(2));
117 std::vector<vtkImageData*>::iterator it;
118 for(it=output->begin(); it!=output->end(); ++it) {
119 std::cout << "========================================" << std::endl;
120 (*it)->PrintSelf(std::cout, vtkIndent(2));
123 // Pour un directory '4D'
124 // en sortie, chaque vtkImageData contiendra un volume au cours du temps.