1 #include "bbgdcmvtkGetInfoGdcmReader.h"
2 #include "bbgdcmvtkPackage.h"
6 #include "gdcmFileHelper.h"
7 #include "vtkImageData.h"
8 #include "vtkGdcmReader.h"
11 #include <gdcmReader.h>
12 #include <gdcmImageHelper.h>
13 #include <vtkGDCMImageReader.h>
15 #include <vtkIndent.h>
20 BBTK_ADD_BLACK_BOX_TO_PACKAGE(gdcmvtk,GetInfoGdcmReader)
21 BBTK_BLACK_BOX_IMPLEMENTATION(GetInfoGdcmReader,bbtk::AtomicBlackBox);
24 void GetInfoGdcmReader::Process()
27 bbUserFinalizeProcessing();
29 f = GDCM_NAME_SPACE::File::New();
30 f->SetFileName( bbGetInputIn() );
38 // Get info from THE image file (only *one* as input)
40 std::vector<double> v_iop;
42 f->GetImageOrientationPatient(iop);
45 v_iop.push_back(iop[i]);
46 bbSetOutputIOP(v_iop );
48 std::vector<double> v_ipp;
50 f->GetImagePositionPatient(ipp);
53 v_ipp.push_back(ipp[i]);
54 bbSetOutputIPP(v_ipp );
56 std::vector<double> v_pixelspacing;
57 v_pixelspacing.push_back(f->GetXSpacing());
58 v_pixelspacing.push_back(f->GetYSpacing());
60 if (f->GetZSize() != 1)
62 v_pixelspacing.push_back(f->GetZSpacing());
64 bbSetOutputPixelSpacing(v_pixelspacing);
67 bbSetOutputInterSlice(f->GetZSpacing());
69 reader = vtkGdcmReader::New();
70 reader->SetFileName( bbGetInputIn().c_str() );
75 reader->GetOutput()->PrintSelf(std::cout, indent);
76 bbSetOutputOut( reader->GetOutput() );
81 void GetInfoGdcmReader::Process()
84 bbUserFinalizeProcessing();
85 gdcm::Reader *read = new gdcm::Reader();
86 read->SetFileName( bbGetInputIn().c_str());
88 bool res = read->Read();
96 // Get info from THE image file (only *one* as input)
97 const gdcm::File &f = read->GetFile();
99 // Image Orientation (Patient)
101 std::vector<double> v_iop;
102 const gdcm::DataElement &deIop = f.GetDataSet().GetDataElement(gdcm::Tag(0x0020, 0x0037));
103 std::stringstream ss;
104 deIop.GetValue().Print(ss);
105 gdcm::Element<gdcm::VR::DS,gdcm::VM::VM6> iop;
108 v_iop.push_back((float)(iop[i]));
109 bbSetOutputIOP(v_iop );
111 // Image Position (Patient)
112 std::vector<double> v_ipp;
113 const gdcm::DataElement &deIpp = f.GetDataSet().GetDataElement(gdcm::Tag((0x0020,0x0032)));
114 deIpp.GetValue().Print(ss);
115 gdcm::Element<gdcm::VR::DS,gdcm::VM::VM3> ipp;
118 v_ipp.push_back((float)(ipp[i]));
119 bbSetOutputIPP(v_ipp );
121 std::vector<double> v_pixelspacing = gdcm::ImageHelper::GetSpacingValue(f);
122 bbSetOutputPixelSpacing(v_pixelspacing);
124 //double interslice; ?? ==1 NO?
125 bbSetOutputInterSlice(v_pixelspacing[2]);
127 reader = vtkGDCMImageReader::New();
128 reader->SetFileName( bbGetInputIn().c_str() );
132 reader->GetOutput()->PrintSelf(std::cout, indent);
133 bbSetOutputOut( reader->GetOutput() );
138 void GetInfoGdcmReader::bbUserSetDefaultValues()
148 void GetInfoGdcmReader::bbUserInitializeProcessing()
153 void GetInfoGdcmReader::bbUserFinalizeProcessing()
170 // EO namespace bbgdcmvtk