1 #include "bbgdcmvtkGetXCoherentInfoGdcmReader.h"
2 #include "bbgdcmvtkPackage.h"
5 #include "gdcmFileHelper.h"
6 #include "vtkImageData.h"
7 #include "vtkGdcmReader.h"
13 BBTK_ADD_BLACK_BOX_TO_PACKAGE(gdcmvtk,GetXCoherentInfoGdcmReader)
14 BBTK_BLACK_BOX_IMPLEMENTATION(GetXCoherentInfoGdcmReader,bbtk::AtomicBlackBox);
15 void GetXCoherentInfoGdcmReader::Process()
17 // Read the first image file
18 f = GDCM_NAME_SPACE::File::New();
19 f->SetFileName( bbGetInputIn()[0] );
27 // Get info from the first image file
29 std::vector<double> v_iop;
31 f->GetImageOrientationPatient(iop);
33 v_iop.push_back(iop[i]);
34 bbSetOutputIOP(v_iop );
36 std::vector<double> v_ipp;
38 f->GetImagePositionPatient(ipp);
40 v_ipp.push_back(ipp[i]);
41 bbSetOutputIPP(v_ipp );
43 std::vector<double> v_pixelspacing;
44 v_pixelspacing.push_back(f->GetXSpacing());
45 v_pixelspacing.push_back(f->GetYSpacing());
46 if (f->GetZSize() != 1) {
47 v_pixelspacing.push_back(f->GetZSpacing());
49 bbSetOutputPixelSpacing(v_pixelspacing);
51 // Add all the files to the SerieHelper
52 sh = GDCM_NAME_SPACE::SerieHelper::New();
53 std::vector<std::string> gii = bbGetInputIn();
54 for(std::vector<std::string>::iterator it = gii.begin();
61 GDCM_NAME_SPACE::FileList::const_iterator it;
62 GDCM_NAME_SPACE::FileList *l;
64 // ==================== Just to see ==============================
66 std::cout << std::endl << " ---------------------------------------- Recap"
68 l = sh->GetFirstSingleSerieUIDFileSet();
72 std::cout << "SerieUID [" << (*it)->GetEntryString(0x0020,0x000e) <<"] Serie Description ["
73 << (*it)->GetEntryString(0x0008,0x103e) << "] "
74 << " : " << l->size() << " files" << std::endl;
75 l = sh->GetNextSingleSerieUIDFileSet();
77 std::cout << " ----------------------------------------End Recap"
78 << std::endl << std::endl;
81 std::cout << " --------------------------- More than ONE Serie UID ?!?"
82 << std::endl << std::endl;
83 // ============================================================
85 // Should only contain one!
86 l = sh->GetFirstSingleSerieUIDFileSet();
92 zspacing = sh->GetZSpacing();
94 std::cout << "GetZSpacing() of sorted SingleSerieUIDFileSet "
95 << "from GDCM_NAME_SPACE::SerieHelper: " << zspacing << std::endl;
96 std::cout << " ('-1' means all the files have the same position)" << std::endl;
98 bbSetOutputInterSlice(zspacing);
101 reader = vtkGdcmReader::New();
102 //reader->SetFileName( bbGetInputIn().c_str() );
103 reader->SetCoherentFileList(l);
108 reader->GetOutput()->PrintSelf(std::cout, indent);
109 bbSetOutputOut( reader->GetOutput() );
112 void GetXCoherentInfoGdcmReader::bbUserConstructor()
114 std::vector<std::string> init;
119 void GetXCoherentInfoGdcmReader::bbUserCopyConstructor(bbtk::BlackBox::Pointer)
124 void GetXCoherentInfoGdcmReader::bbUserDestructor()
135 // EO namespace bbgdcmvtk