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);
80 v_ipp.push_back(ipp[i]);
81 bbSetOutputIPP(v_ipp );
83 std::vector<double> v_pixelspacing;
84 v_pixelspacing.push_back(f->GetXSpacing());
85 v_pixelspacing.push_back(f->GetYSpacing());
87 if (f->GetZSize() != 1)
89 v_pixelspacing.push_back(f->GetZSpacing());
91 bbSetOutputPixelSpacing(v_pixelspacing);
94 bbSetOutputInterSlice(f->GetZSpacing());
96 reader = vtkGdcmReader::New();
97 reader->SetFileName( bbGetInputIn().c_str() );
102 reader->GetOutput()->PrintSelf(std::cout, indent);
103 bbSetOutputOut( reader->GetOutput() );
107 #if defined USE_GDCM2
108 void GetInfoGdcmReader::Process()
110 // Reset de reader, f
111 bbUserFinalizeProcessing();
112 gdcm::Reader *read = new gdcm::Reader();
113 read->SetFileName( bbGetInputIn().c_str());
115 bool res = read->Read();
123 // Get info from THE image file (only *one* as input)
124 const gdcm::File &f = read->GetFile();
126 // Image Orientation (Patient)
128 std::vector<double> v_iop;
129 const gdcm::DataElement &deIop = f.GetDataSet().GetDataElement(gdcm::Tag(0x0020, 0x0037));
130 std::stringstream ss;
131 deIop.GetValue().Print(ss);
132 gdcm::Element<gdcm::VR::DS,gdcm::VM::VM6> iop;
135 v_iop.push_back((float)(iop[i]));
136 bbSetOutputIOP(v_iop );
138 // Image Position (Patient)
139 std::vector<double> v_ipp;
140 const gdcm::DataElement &deIpp = f.GetDataSet().GetDataElement(gdcm::Tag((0x0020,0x0032)));
141 deIpp.GetValue().Print(ss);
142 gdcm::Element<gdcm::VR::DS,gdcm::VM::VM3> ipp;
145 v_ipp.push_back((float)(ipp[i]));
146 bbSetOutputIPP(v_ipp );
148 std::vector<double> v_pixelspacing = gdcm::ImageHelper::GetSpacingValue(f);
149 bbSetOutputPixelSpacing(v_pixelspacing);
151 //double interslice; ?? ==1 NO?
152 bbSetOutputInterSlice(v_pixelspacing[2]);
154 reader = vtkGDCMImageReader::New();
155 reader->SetFileName( bbGetInputIn().c_str() );
159 reader->GetOutput()->PrintSelf(std::cout, indent);
160 bbSetOutputOut( reader->GetOutput() );
165 void GetInfoGdcmReader::bbUserSetDefaultValues()
167 #if defined USE_GDCM2
178 void GetInfoGdcmReader::bbUserInitializeProcessing()
183 void GetInfoGdcmReader::bbUserFinalizeProcessing()
185 #if defined USE_GDCM2
209 // EO namespace bbgdcmvtk