From Ohm

Dicom Series Loader with ITK

To load a dicom series from multiple files and not only a single one, we have to do a little more work:

The directory, in which the images reside, is assumed to be available as “series”:

#include "itkImage.h"
#include "itkGDCMImageIO.h"
#include "itkGDCMSeriesFileNames.h"
#include "itkImageSeriesReader.h"

// create name generator
typedef itk::GDCMSeriesFileNames NamesGeneratorType;
NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();
nameGenerator->SetDirectory(series);

// create dicom series reader
typedef itk::ImageSeriesReader<Image3DType> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
typedef itk::GDCMImageIO ImageIOType;
ImageIOType::Pointer dicomIO = ImageIOType::New();
reader->SetImageIO(dicomIO);

// get series IDs
typedef std::vector<std::string> SeriesIdContainer;
const SeriesIdContainer &seriesUID = nameGenerator->GetSeriesUIDs();

// get dicom series
typedef std::vector<std::string> FileNamesContainer;
FileNamesContainer fileNames;
fileNames=nameGenerator->GetFileNames(seriesUID.begin()->c_str());
reader->SetFileNames(fileNames);

// pull reader
reader->Update();

Retrieved from http://schorsch.efi.fh-nuernberg.de/roettger/index.php/MedicalVisualization/DicomSeriesLoaderWithITK

Page last modified on November 16, 2020, at 11:36 PM