[Insight-users] Changing a DICOM Header... in a DICOM Series

Martin Kavec martin.kavec at gmail.com
Wed Nov 19 08:01:07 EST 2008


Stephane,

I was on the same issue two days ago with the same results. The problem is 
that each slice in your input series has unique MetaDataDictionary, so you 
have to change the field you desire in all of them.

I have found in the ITK mailing list archives a post from Bill (I guess) where 
he send attached a file DicomResample which does what you need. Just google 
for DicomResample and the very first reference is what you need.

Regards,

Martin

On Wednesday 19 November 2008 13:38:06 Stéphane CALANDE wrote:
> Oh sorry, there was a mistake in the entry...
>
> But the field is still not modified... :-(
>
>
> Any other idea ?
>
>
> Thank you Bill ;-)
>
>
>
>
> Stéphane
>
>
>
>
> 2008/11/19 Bill Lorensen <bill.lorensen at gmail.com>
>
> > Try
> >  std::string entryId("0008|103e");
> > instead of
> >  std::string entryId("008|103e");
> >
> > Bill
> >
> > On Wed, Nov 19, 2008 at 6:53 AM, Stéphane CALANDE <scalande at gmail.com>
> >
> > wrote:
> > > Hi itk-list,
> > >
> > >
> > > I'm using the example of "DicomSeriesReadSeriesWrite", but I'd like to
> > > modify one DICOM header field before writing the Series.
> > >
> > > Then I had a look in "DicomImageReadChangeHeaderWrite" and I tried to
> >
> > apply
> >
> > > the part of the code that change the header field into the code of
> > > "DicomSeriesReadSeriesWrite".
> > >
> > >
> > > But it doesn't seem to work. The field I want to change has not changed
> >
> > in
> >
> > > the output files. Could you have a look in the (simplified) following
> >
> > code
> >
> > > to help me ?
> > >
> > >
> > >
> > >   typedef signed short    PixelType;
> > >   const unsigned int      Dimension = 3;
> > >   typedef itk::Image< PixelType, Dimension >      ImageType;
> > >   typedef itk::ImageSeriesReader< ImageType >     ReaderType;
> > >   typedef itk::ImageFileReader< ImageType >       ReaderMHDType;
> > >   typedef itk::GDCMImageIO                        ImageIOType;
> > >   typedef itk::GDCMSeriesFileNames                NamesGeneratorType;
> > >
> > >   ImageIOType::Pointer gdcmIO = ImageIOType::New();
> > >   NamesGeneratorType::Pointer namesGenerator =
> > > NamesGeneratorType::New();
> > >
> > >   namesGenerator->SetInputDirectory( [...DIRECTORY...] );
> > >
> > >   const ReaderType::FileNamesContainer & filenames =
> > >                             namesGenerator->GetInputFileNames();
> > >
> > >   ReaderType::Pointer reader = ReaderType::New();
> > >
> > >   reader->SetImageIO( gdcmIO );
> > >   reader->SetFileNames( filenames );
> > >
> > >   reader->Update();
> > >
> > >   // BEGIN => I'm trying to modify one DICOM Header field <<<
> > >
> > >   typedef itk::MetaDataDictionary   DictionaryType;
> > >
> > >   ImageType::Pointer inputImage = reader->GetOutput();
> > >   DictionaryType & dictionary = inputImage->GetMetaDataDictionary();
> > >
> > >   std::string entryId("008|103e");
> > >   std::string value("NEW VALUE");
> > >
> > >   itk::EncapsulateMetaData<std::string>( dictionary, entryId, value );
> > >
> > >    // END
> > >
> > >     [...]
> > >
> > >   typedef signed short    OutputPixelType;
> > >   const unsigned int      OutputDimension = 2;
> > >
> > >   typedef itk::Image< OutputPixelType, OutputDimension >   
> > > Image2DType;
> > >
> > >   typedef itk::ImageSeriesWriter< ImageType, Image2DType >
> > > SeriesWriterType;
> > >
> > >   SeriesWriterType::Pointer seriesWriter = SeriesWriterType::New();
> > >
> > >   seriesWriter->SetInput( [...VOLUME...] );
> > >   seriesWriter->SetImageIO( gdcmIO );
> > >
> > >   namesGenerator->SetOutputDirectory( outputDirectory );
> > >
> > >   seriesWriter->SetFileNames( namesGenerator->GetOutputFileNames() );
> > >
> > >   seriesWriter->SetMetaDataDictionaryArray(
> > >                         reader->GetMetaDataDictionaryArray() );
> > >
> > >   seriesWriter->Update();
> > >
> > >
> > >
> > >
> > > I would be very grateful if you could help me.
> > >
> > >
> > > Thank you very much,
> > >
> > >
> > >
> > > Stéphane
> > >
> > > _______________________________________________
> > > Insight-users mailing list
> > > Insight-users at itk.org
> > > http://www.itk.org/mailman/listinfo/insight-users


More information about the Insight-users mailing list