[Insight-users] Read a DICOM Series and write a volume

polys_poly at hotmail.com polys_poly at hotmail.com
Wed Apr 16 09:13:46 EDT 2008


I use the example Examples/IO/DicomSeriesReadImageWrite2.cxx 
to read a DICOM series and write the volume as a .mha. When i visualize the volume using vtk i get the following 

http://img122.imageshack.us/img122/718/vtkvolumeod4.jpg

When i visualize the volume brainweb1e1a10f20.mha that i get from ITK data the result is this

http://img59.imageshack.us/img59/8670/vtkvolumenormalco1.jpg

As you can see the first volume has not opacity at all. I mean i cannot see the brain inside the skull. Moreover the volume looks more like a cube to me cause of the images that compose it. The main problem is that i want to create a registration application and the registration will take hours if the volumes i create look like the first one, not to say that it will give me errors at the end. What am i doing wrong? Or is it chance a fault of the DICOM dataset i am using? 

Here is the code of DicomSeriesReadImageWrite2.cxx

{

typedef signed short    PixelType;
 const unsigned int      Dimension = 3;

 typedef itk::OrientedImage< PixelType, Dimension > ImageType;

 typedef itk::ImageSeriesReader< ImageType > ReaderType;
 ReaderType::Pointer reader = ReaderType::New();

 typedef itk::GDCMImageIO       ImageIOType;
 ImageIOType::Pointer dicomIO = ImageIOType::New();

 reader->SetImageIO( dicomIO );

 typedef itk::GDCMSeriesFileNames NamesGeneratorType;
 NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();

 nameGenerator->SetUseSeriesDetails( true );
 nameGenerator->AddSeriesRestriction("0008|0021" );

 nameGenerator->SetDirectory(directoryPath);
 
 std::cout << std::endl << "The directory: " << std::endl;
 std::cout << std::endl << directoryPath << std::endl << std::endl;
 std::cout << "Contains the following DICOM Series: ";
 std::cout << std::endl << std::endl;

 typedef std::vector< std::string >    SeriesIdContainer;

 const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs();

 SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();
 SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();
 while( seriesItr != seriesEnd ) {
  std::cout << seriesItr->c_str() << std::endl;
  seriesItr++;
 }

 std::string seriesIdentifier;
 seriesIdentifier = seriesUID.begin()->c_str();
 
 std::cout << std::endl << std::endl;
 std::cout << "Now reading series: " << std::endl << std::endl;
 std::cout << seriesIdentifier << std::endl;
 std::cout << std::endl << std::endl;

 typedef std::vector< std::string >   FileNamesContainer;
 FileNamesContainer fileNames;

 fileNames = nameGenerator->GetFileNames( seriesIdentifier );

 reader->SetFileNames( fileNames );  
 reader->Update();
  
 typedef itk::ImageFileWriter< ImageType > WriterType;
    WriterType::Pointer writer = WriterType::New();
    
    writer->SetFileName("output.mha");

    writer->SetInput(reader->GetOutput());

    std::cout  << "Writing the image as " << std::endl << std::endl;
    std::cout  << "output.mha" << std::endl << std::endl;

   writer->Update();

}

Thanks in advance.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20080416/10377e9a/attachment.htm>


More information about the Insight-users mailing list