[Insight-users] ITK DICOM series reading
John Drescher
drescherjm at gmail.com
Thu Jul 19 11:53:42 EDT 2012
> class BoneSegment
> {
> public:
> BoneSegment();
> void readDirectory(QString dirName);
> vtkImageData* getImageData()const;
> typedef signed short PixelType;
> typedef itk::Image< PixelType, 3 >ImageType;
> typedef itk::ImageSeriesReader< ImageType > ReaderType;
> ReaderType::Pointer reader;
> typedef itk::GDCMImageIO ImageIOType;
> ImageIOType::Pointer dicomIO;
> typedef itk::GDCMSeriesFileNames NamesGeneratorType;
> NamesGeneratorType::Pointer nameGenerator;
> typedef std::vector< std::string > SeriesIdContainer;
> typedef std::vector< std::string > FileNamesContainer;
> typedef itk::ImageToVTKImageFilter<ImageType> ConnectorType;
> };
> BoneSegment::BoneSegment(){
>
> }
>
> void BoneSegment::readDirectory(QString dirName){
> reader = ReaderType::New();
> dicomIO = ImageIOType::New();
> reader->SetImageIO( dicomIO );
> nameGenerator = NamesGeneratorType::New();
>
> nameGenerator->SetUseSeriesDetails( true );
> nameGenerator->AddSeriesRestriction("0008|0021" );
> nameGenerator->SetDirectory( dirName.toStdString().c_str());
> const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs();
> std::string seriesIdentifier;
> seriesIdentifier = seriesUID.begin()->c_str();
> FileNamesContainer fileNames;
> fileNames = nameGenerator->GetFileNames( seriesIdentifier );
> reader->SetFileNames( fileNames );
> try
> {
> reader->Update();
> }
> catch (itk::ExceptionObject &ex)
> {
> std::cout << ex << std::endl;
> }
>
> }
>
> Best
>
Are there any series found? The reader will not be happy if fileNames is empty.
John
More information about the Insight-users
mailing list