[Insight-users] difficulty to converter image to DICOM series

Luis Ibanez luis.ibanez at kitware.com
Fri Jun 25 15:56:16 EDT 2010


Hi Roberta,


               Welcome to ITK !


Please tell of more about what happens
when you run the code.

Do you get any error messages ?

What is the size of your image ?
(number of pixels along X, Y and Z)

You may want to try the example:

Insight/Examples/IO/
    ImageReadDicomSeriesWrite.cxx

(without any modifications) first,
and verify that it can read your image
and write it as a series of DICOM slices.


     Thanks


          Luis


-------------------------------------------------------
On Thu, Jun 24, 2010 at 5:59 AM, Roberta Beneduce <bluangel_br at hotmail.it>wrote:

>  Hi,
> I'm Roberta and I'm an biomedical engineer and a unskilled itk user. I have
> to converter and write an 3D image in a DICOM series. I' m following the itk
> guide exsamples. Even if the code compiles, the writing isn' t done. I wrote
> the following code, it's only a method in a project not implemented by me. I
> olso added the necessary typedef to understand the problem.
> I'm waiting for useful informations.
> Thank you for availability.
> (I'm sorry for my english and for my computer science knowledge).
>
> #define DataType unsigned short
>
> class MbElementConverter
> {
> public:
> //Itk Input Image
> typedef Image <DataType , 3 > DataImageType;
> .........
>
> class MbDifference : public MbProgrammableAlgo
> {
> protected:
> typedef unsigned short PixelType;
> typedef itk::Image< PixelType, Dimension2 > ImageType2D;
> typedef itk::Image< float, Dimension3 > ImageType3DF;
> typedef MbElementConverter::DataImageType ImageType3D;
> typedef MbElementConverter::DataImageType FixedImageType;
> typedef MbElementConverter::DataImageType MovingImageType;
> typedef itk::ImageFileWriter< ImageType3D > WriterType3D;
> typedef itk::ImageSeriesWriter<ImageType3D, ImageType2D >
> SeriesWriterType;
> typedef itk::ImageSeriesReader< ImageType3D > ReaderType3D;
> typedef OrientImageFilter<ImageType3D,ImageType3D> ImageOrienter;
> typedef itk::GDCMImageIO GDCMImageIOType;
> typedef itk::GDCMSeriesFileNames NamesGeneratorType;
> typedef itk::NumericSeriesFileNames NamesGeneratorType2;
> typedef std::vector< std::string > SeriesIdContainer;
> typedef std::vector< std::string > FileNamesContainer;
> typedef OrientImageFilter<ImageType3D,ImageType3D> tOrienter;
> ..........
>
>
>
> void MbDifference::writeImageDICOM(char* outputDirectory,
> ImageType3D::Pointer inputImage)
> {
>  itksys::SystemTools::MakeDirectory(outputDirectory);
>  GDCMImageIOType::Pointer gdcmIO = GDCMImageIOType::New();
>  SeriesWriterType::Pointer seriesWriter = SeriesWriterType::New();
>  NamesGeneratorType2::Pointer nameGenerator = NamesGeneratorType2::New();
>  FileNamesContainer fileNames;
>  std::string format = outputDirectory;
>  format += "/%08d";
>  // format += "dicom"; // filename extension
>  nameGenerator->SetSeriesFormat( format.c_str() );
>  ImageType3D::RegionType region = inputImage->GetLargestPossibleRegion();
>  ImageType3D::IndexType start = region.GetIndex();
>  ImageType3D::SizeType size = region.GetSize();
>  const unsigned int firstSlice = start[2];
>  const unsigned int lastSlice = start[2] + size[2] - 1;
>  nameGenerator->SetStartIndex( firstSlice );
>  nameGenerator->SetEndIndex( lastSlice );
>  nameGenerator->SetIncrementIndex( 1 );
>  fileNames = nameGenerator->GetFileNames();
>
>  seriesWriter->SetFileNames( nameGenerator->GetFileNames() );
>  seriesWriter->SetInput( inputImage );
>  gdcmIO->LoadPrivateTagsOn();
>  gdcmIO->GetLoadPrivateTags();
>  gdcmIO->KeepOriginalUIDOn();
>  seriesWriter->SetImageIO( gdcmIO );
>  //
> seriesWriter->SetMetaDataDictionaryArray(reader->GetMetaDataDictionaryArray());
>  try
>  {
>  seriesWriter->Update();
>  }
>  catch( itk::ExceptionObject & excp )
>  {
>  std::cerr << "Exception thrown while writing the series " << std::endl;
>
>  std::cerr << excp << std::endl;
>  }
> }
>
> ------------------------------
> Importa i tuoi contatti di Facebook. Chiacchiera su Messenger!<http://www.windowslive.it/importaAmici.aspx>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100625/d6e5a190/attachment-0001.htm>


More information about the Insight-users mailing list