1 # ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
26 #include "bbgdcmvtkGetInfoGdcmReader.h"
27 #include "bbgdcmvtkPackage.h"
31 #include "gdcmFileHelper.h"
32 #include "vtkImageData.h"
33 #include "vtkGdcmReader.h"
36 #include <gdcmReader.h>
37 // #include "vtkImageData.h"
38 #include <gdcmImageHelper.h>
39 #include <vtkGDCMImageReader.h>
41 #include <vtkIndent.h>
46 BBTK_ADD_BLACK_BOX_TO_PACKAGE(gdcmvtk,GetInfoGdcmReader)
47 BBTK_BLACK_BOX_IMPLEMENTATION(GetInfoGdcmReader,bbtk::AtomicBlackBox);
50 void GetInfoGdcmReader::Process()
53 bbUserFinalizeProcessing();
55 f = GDCM_NAME_SPACE::File::New();
56 f->SetFileName( bbGetInputIn() );
64 // Get info from THE image file (only *one* as input)
66 std::vector<double> v_iop;
68 f->GetImageOrientationPatient(iop);
71 v_iop.push_back(iop[i]);
72 bbSetOutputIOP(v_iop );
74 std::vector<double> v_ipp;
76 f->GetImagePositionPatient(ipp);
79 v_ipp.push_back(ipp[i]);
80 bbSetOutputIPP(v_ipp );
82 std::vector<double> v_pixelspacing;
83 v_pixelspacing.push_back(f->GetXSpacing());
84 v_pixelspacing.push_back(f->GetYSpacing());
86 if (f->GetZSize() != 1)
88 v_pixelspacing.push_back(f->GetZSpacing());
90 bbSetOutputPixelSpacing(v_pixelspacing);
93 bbSetOutputInterSlice(f->GetZSpacing());
95 reader = vtkGdcmReader::New();
96 reader->SetFileName( bbGetInputIn().c_str() );
101 reader->GetOutput()->PrintSelf(std::cout, indent);
102 bbSetOutputOut( reader->GetOutput() );
106 #if defined USE_GDCM2
107 void GetInfoGdcmReader::Process()
109 // Reset de reader, f
110 bbUserFinalizeProcessing();
111 gdcm::Reader *read = new gdcm::Reader();
112 read->SetFileName( bbGetInputIn().c_str());
114 bool res = read->Read();
122 // Get info from THE image file (only *one* as input)
123 const gdcm::File &f = read->GetFile();
125 // Image Orientation (Patient)
127 std::vector<double> v_iop;
128 const gdcm::DataElement &deIop = f.GetDataSet().GetDataElement(gdcm::Tag(0x0020, 0x0037));
129 std::stringstream ss;
130 deIop.GetValue().Print(ss);
131 gdcm::Element<gdcm::VR::DS,gdcm::VM::VM6> iop;
134 v_iop.push_back((float)(iop[i]));
135 bbSetOutputIOP(v_iop );
137 // Image Position (Patient)
138 std::vector<double> v_ipp;
139 const gdcm::DataElement &deIpp = f.GetDataSet().GetDataElement(gdcm::Tag((0x0020,0x0032)));
140 deIpp.GetValue().Print(ss);
141 gdcm::Element<gdcm::VR::DS,gdcm::VM::VM3> ipp;
144 v_ipp.push_back((float)(ipp[i]));
145 bbSetOutputIPP(v_ipp );
147 std::vector<double> v_pixelspacing = gdcm::ImageHelper::GetSpacingValue(f);
148 bbSetOutputPixelSpacing(v_pixelspacing);
150 //double interslice; ?? ==1 NO?
151 bbSetOutputInterSlice(v_pixelspacing[2]);
153 reader = vtkGDCMImageReader::New();
154 reader->SetFileName( bbGetInputIn().c_str() );
158 reader->GetOutput()->PrintSelf(std::cout, indent);
159 bbSetOutputOut( reader->GetOutput() );
164 void GetInfoGdcmReader::bbUserSetDefaultValues()
166 #if defined USE_GDCM2
177 void GetInfoGdcmReader::bbUserInitializeProcessing()
182 void GetInfoGdcmReader::bbUserFinalizeProcessing()
184 #if defined USE_GDCM2
208 // EO namespace bbgdcmvtk