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 # ------------------------------------------------------------------------ */
27 #include "bbgdcmvtkGetInfoGdcmReader.h"
28 #include "bbgdcmvtkPackage.h"
32 #include "gdcmFileHelper.h"
33 #include "vtkImageData.h"
34 #include "vtkGdcmReader.h"
37 #include <gdcmReader.h>
38 // #include "vtkImageData.h"
39 #include <gdcmImageHelper.h>
40 #include <vtkGDCMImageReader.h>
42 #include <vtkIndent.h>
47 BBTK_ADD_BLACK_BOX_TO_PACKAGE(gdcmvtk,GetInfoGdcmReader)
48 BBTK_BLACK_BOX_IMPLEMENTATION(GetInfoGdcmReader,bbtk::AtomicBlackBox);
51 void GetInfoGdcmReader::Process()
54 bbUserFinalizeProcessing();
56 f = GDCM_NAME_SPACE::File::New();
57 f->SetFileName( bbGetInputIn() );
65 // Get info from THE image file (only *one* as input)
67 std::vector<double> v_iop;
69 f->GetImageOrientationPatient(iop);
72 v_iop.push_back(iop[i]);
73 bbSetOutputIOP(v_iop );
75 std::vector<double> v_ipp;
77 f->GetImagePositionPatient(ipp);
81 v_ipp.push_back(ipp[i]);
83 bbSetOutputIPP(v_ipp );
85 std::vector<double> v_pixelspacing;
86 v_pixelspacing.push_back(f->GetXSpacing());
87 v_pixelspacing.push_back(f->GetYSpacing());
89 if (f->GetZSize() != 1)
91 v_pixelspacing.push_back(f->GetZSpacing());
93 bbSetOutputPixelSpacing(v_pixelspacing);
96 bbSetOutputInterSlice(f->GetZSpacing());
98 reader = vtkGdcmReader::New();
99 reader->SetFileName( bbGetInputIn().c_str() );
100 reader->SetFlipY(true);
104 // vtkIndent indent ;
105 // reader->GetOutput()->PrintSelf(std::cout, indent);
106 bbSetOutputOut( reader->GetOutput() );
110 #if defined USE_GDCM2
111 void GetInfoGdcmReader::Process()
113 // Reset de reader, f
114 bbUserFinalizeProcessing();
115 gdcm::Reader *read = new gdcm::Reader();
116 read->SetFileName( bbGetInputIn().c_str());
118 bool res = read->Read();
126 // Get info from THE image file (only *one* as input)
127 const gdcm::File &f = read->GetFile();
129 // Image Orientation (Patient)
131 std::vector<double> v_iop;
132 const gdcm::DataElement &deIop = f.GetDataSet().GetDataElement(gdcm::Tag(0x0020, 0x0037));
133 std::stringstream ss;
134 deIop.GetValue().Print(ss);
135 gdcm::Element<gdcm::VR::DS,gdcm::VM::VM6> iop;
139 v_iop.push_back((float)(iop[i]));
141 bbSetOutputIOP(v_iop );
143 // Image Position (Patient)
144 std::vector<double> v_ipp;
145 const gdcm::DataElement &deIpp = f.GetDataSet().GetDataElement(gdcm::Tag((0x0020,0x0032)));
146 deIpp.GetValue().Print(ss);
147 gdcm::Element<gdcm::VR::DS,gdcm::VM::VM3> ipp;
151 v_ipp.push_back((float)(ipp[i]));
153 bbSetOutputIPP(v_ipp );
155 std::vector<double> v_pixelspacing = gdcm::ImageHelper::GetSpacingValue(f);
156 bbSetOutputPixelSpacing(v_pixelspacing);
158 //double interslice; ?? ==1 NO?
159 bbSetOutputInterSlice(v_pixelspacing[2]);
161 reader = vtkGDCMImageReader::New();
162 reader->SetFileName( bbGetInputIn().c_str() );
166 reader->GetOutput()->PrintSelf(std::cout, indent);
167 bbSetOutputOut( reader->GetOutput() );
172 void GetInfoGdcmReader::bbUserSetDefaultValues()
174 #if defined USE_GDCM2
185 void GetInfoGdcmReader::bbUserInitializeProcessing()
190 void GetInfoGdcmReader::bbUserFinalizeProcessing()
192 #if defined USE_GDCM2
216 // EO namespace bbgdcmvtk