[Insight-users] ITK DICOM series reading

Elhassan Abdou hassan.abdou at yahoo.com
Thu Jul 19 09:09:11 EDT 2012


Dear ALL

I am new to ITK and I am trying to read dicom series to ITK volume but the program usually crash at reader->update
I could not understand what is wrong
any advice is more than welcome


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
 
El-Hassan Mohamed 
Biomedical engineering
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120719/09e492ff/attachment.htm>


More information about the Insight-users mailing list