[Insight-users] Changing a DICOM Header... in a DICOM Series
Stéphane CALANDE
scalande at gmail.com
Wed Nov 19 06:53:12 EST 2008
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20081119/1e19a849/attachment-0001.htm>
More information about the Insight-users
mailing list