32#include "DGtal/base/Common.h"
33#include "ConfigTest.h"
34#include "DGtalCatch.h"
35#include "DGtal/helpers/StdDefs.h"
36#include "DGtal/images/ImageContainerBySTLVector.h"
37#include "DGtal/images/ImageContainerByITKImage.h"
38#include "DGtal/io/readers/ITKDicomReader.h"
42#pragma clang diagnostic push
43#pragma clang diagnostic ignored "-Wdocumentation"
45#include <itkGDCMSeriesFileNames.h>
47#pragma clang diagnostic pop
60std::vector<std::string>
63 typedef itk::GDCMSeriesFileNames NamesGeneratorType;
64 NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();
65 nameGenerator->SetUseSeriesDetails(
true );
66 nameGenerator->SetDirectory( path );
68 typedef itk::GDCMSeriesFileNames::SeriesUIDContainerType SeriesIdContainer;
69 const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs();
71 if (! seriesUID.empty() )
73 return nameGenerator->GetFileNames( *(seriesUID.begin()) );
75 return std::vector<std::string>();
79template <
typename Image>
87 unsigned int nbVal=0, nbPos = 0;
92 if ( (*it) > 0 ) ++nbPos;
95 REQUIRE( ( nbVal==2130048 && nbPos==296030 ) );
98template <
typename PixelType>
105 typename DGtalImage::ITKImagePointer dgtal_itk = img.getITKImagePointer();
107 typedef itk::Image<PixelType, 3> ItkImage;
108 typedef itk::ImageSeriesReader<ItkImage> ItkReader;
109 typename ItkReader::Pointer reader = ItkReader::New();
110 reader->SetFileNames( fileNames );
114 typename ItkImage::Pointer itk = reader->GetOutput();
116 INFO(
"Checking spacing" )
117 REQUIRE( dgtal_itk->GetSpacing() == itk->GetSpacing() );
118 INFO(
"Checking origin" )
119 REQUIRE( dgtal_itk->GetOrigin() == itk->GetOrigin() );
120 INFO(
"Checking direction" )
121 REQUIRE( dgtal_itk->GetDirection() == itk->GetDirection() );
133 "Testing ITKDicomReader with 8 bits ImageContainerBySTLVector images" )
136 testImportDICOM<Image>();
140 "Testing ITKDicomReader with 8 bits ImageContainerByITKImage images" )
143 testImportDICOM<Image>();
147 "Testing ITKDicomReader with 16 bits ImageContainerBySTLVector images" )
150 testImportDICOM<Image>();
154 "Testing ITKDicomReader with 16 bits ImageContainerByITKImage images" )
157 testImportDICOM<Image>();
163 "Testing behavior of ITKDicomReader on empty filenames vector" )
166 std::vector<std::string> filenames;
167 bool caughtException =
false;
174 caughtException =
true;
175 trace.
info() <<
"Exception was correctly caught" << std::endl;
177 REQUIRE( caughtException ==
true);
181 "Testing ITKDicomReader with 8 bits ImageContainerByITKImage images keeps spatial information" )
183 testSpatialInformation<unsigned char>();
187 "Testing ITKDicomReader with 16 bits ImageContainerByITKImage images keeps spatial information" )
189 testSpatialInformation<int16_t>();
Aim: implements a model of CImageContainer using a ITK Image.
std::vector< Value >::const_iterator ConstIterator
Aim: implements association bewteen points lying in a digital domain and values.
Aim: model of CConstBidirectionalRangeFromPoint that adapts any range of elements bounded by two iter...
DGtal is the top-level namespace which contains all DGtal functions and types.
static Image importDICOM(const std::vector< std::string > &filenames, const TFunctor &aFunctor=TFunctor())
void testSpatialInformation()
std::vector< std::string > getFirstDicomSerieFileNames(const std::string &path)
TEST_CASE("Testing ITKReader")
SECTION("Testing constant forward iterators")
REQUIRE(domain.isInside(aPoint))