I've tested "DicomImageReadChangeHeaderWrite" with the code :<br><font face="courier new,monospace"><br> std::string entryId("008|103e");<br> std::string value("NEW VALUE"); <br><br style="font-family: arial,helvetica,sans-serif;">
<span style="font-family: arial,helvetica,sans-serif;">and it works...</span><br style="font-family: arial,helvetica,sans-serif;"><br style="font-family: arial,helvetica,sans-serif;"><br style="font-family: arial,helvetica,sans-serif;">
<span style="font-family: arial,helvetica,sans-serif;">I think the origin of the problem could be the dictionary :<br><br>In the code :<br style="font-family: arial,helvetica,sans-serif;"></span></font><br><font face="courier new,monospace">ImageType::Pointer inputImage = reader->GetOutput(); <br>
DictionaryType & dictionary = inputImage->GetMetaDataDictionary(); <br>[...]<br>itk::EncapsulateMetaData<std::string>( dictionary, entryId, value ); <br><br><br><font face="arial,helvetica,sans-serif">I don't really now what represents the variable "dictionary". Because the "reader" is a reader of a SERIE and of an IMAGE...<br>
<br>Then what returns </font></font><font face="courier new,monospace">GetMetaDataDictionary() <font face="arial,helvetica,sans-serif">of a DICOM serie ?<br><br>Do I have to find a way to iterate on the dictionaries of each image of the serie ? <br>
<span style="font-family: arial,helvetica,sans-serif;">(Because I want to modify the header of each DICOM image...)</span><br style="font-family: arial,helvetica,sans-serif;"></font></font><font face="courier new,monospace"><font style="font-family: arial,helvetica,sans-serif;" face="arial,helvetica,sans-serif"><br>
</font><br style="font-family: arial,helvetica,sans-serif;"><br style="font-family: arial,helvetica,sans-serif;"><span style="font-family: arial,helvetica,sans-serif;">Thank you,</span><br style="font-family: arial,helvetica,sans-serif;">
<br style="font-family: arial,helvetica,sans-serif;"><br style="font-family: arial,helvetica,sans-serif;"><span style="font-family: arial,helvetica,sans-serif;">Stéphane</span><br style="font-family: arial,helvetica,sans-serif;">
<br><br><br style="font-family: arial,helvetica,sans-serif;"><br></font><br><div class="gmail_quote">2008/11/19 Stéphane CALANDE <span dir="ltr"><<a href="mailto:scalande@gmail.com">scalande@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Oh sorry, there was a mistake in the entry...<br><br>But the field is still not modified... :-(<br>
<br><br>Any other idea ?<br><br><br>Thank you Bill ;-)<br><br><br><br><br>Stéphane<br><br><br> <br><br><div class="gmail_quote">
2008/11/19 Bill Lorensen <span dir="ltr"><<a href="mailto:bill.lorensen@gmail.com" target="_blank">bill.lorensen@gmail.com</a>></span><div><div></div><div class="Wj3C7c"><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Try<br>
std::string entryId("0008|103e");<br>
instead of<br>
<div> std::string entryId("008|103e");<br>
<br>
</div>Bill<br>
<div><div></div><div><br>
On Wed, Nov 19, 2008 at 6:53 AM, Stéphane CALANDE <<a href="mailto:scalande@gmail.com" target="_blank">scalande@gmail.com</a>> wrote:<br>
> Hi itk-list,<br>
><br>
><br>
> I'm using the example of "DicomSeriesReadSeriesWrite", but I'd like to<br>
> modify one DICOM header field before writing the Series.<br>
><br>
> Then I had a look in "DicomImageReadChangeHeaderWrite" and I tried to apply<br>
> the part of the code that change the header field into the code of<br>
> "DicomSeriesReadSeriesWrite".<br>
><br>
><br>
> But it doesn't seem to work. The field I want to change has not changed in<br>
> the output files. Could you have a look in the (simplified) following code<br>
> to help me ?<br>
><br>
><br>
><br>
> typedef signed short PixelType;<br>
> const unsigned int Dimension = 3;<br>
> typedef itk::Image< PixelType, Dimension > ImageType;<br>
> typedef itk::ImageSeriesReader< ImageType > ReaderType;<br>
> typedef itk::ImageFileReader< ImageType > ReaderMHDType;<br>
> typedef itk::GDCMImageIO ImageIOType;<br>
> typedef itk::GDCMSeriesFileNames NamesGeneratorType;<br>
><br>
> ImageIOType::Pointer gdcmIO = ImageIOType::New();<br>
> NamesGeneratorType::Pointer namesGenerator = NamesGeneratorType::New();<br>
><br>
> namesGenerator->SetInputDirectory( [...DIRECTORY...] );<br>
><br>
> const ReaderType::FileNamesContainer & filenames =<br>
> namesGenerator->GetInputFileNames();<br>
><br>
> ReaderType::Pointer reader = ReaderType::New();<br>
><br>
> reader->SetImageIO( gdcmIO );<br>
> reader->SetFileNames( filenames );<br>
><br>
> reader->Update();<br>
><br>
> // BEGIN => I'm trying to modify one DICOM Header field <<<<br>
><br>
> typedef itk::MetaDataDictionary DictionaryType;<br>
><br>
> ImageType::Pointer inputImage = reader->GetOutput();<br>
> DictionaryType & dictionary = inputImage->GetMetaDataDictionary();<br>
><br>
> std::string entryId("008|103e");<br>
> std::string value("NEW VALUE");<br>
><br>
> itk::EncapsulateMetaData<std::string>( dictionary, entryId, value );<br>
><br>
> // END<br>
><br>
> [...]<br>
><br>
> typedef signed short OutputPixelType;<br>
> const unsigned int OutputDimension = 2;<br>
><br>
> typedef itk::Image< OutputPixelType, OutputDimension > Image2DType;<br>
><br>
> typedef itk::ImageSeriesWriter< ImageType, Image2DType ><br>
> SeriesWriterType;<br>
><br>
> SeriesWriterType::Pointer seriesWriter = SeriesWriterType::New();<br>
><br>
> seriesWriter->SetInput( [...VOLUME...] );<br>
> seriesWriter->SetImageIO( gdcmIO );<br>
><br>
> namesGenerator->SetOutputDirectory( outputDirectory );<br>
><br>
> seriesWriter->SetFileNames( namesGenerator->GetOutputFileNames() );<br>
><br>
> seriesWriter->SetMetaDataDictionaryArray(<br>
> reader->GetMetaDataDictionaryArray() );<br>
><br>
> seriesWriter->Update();<br>
><br>
><br>
><br>
><br>
> I would be very grateful if you could help me.<br>
><br>
><br>
> Thank you very much,<br>
><br>
><br>
><br>
> Stéphane<br>
><br>
</div></div>> _______________________________________________<br>
> Insight-users mailing list<br>
> <a href="mailto:Insight-users@itk.org" target="_blank">Insight-users@itk.org</a><br>
> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
><br>
><br>
</blockquote></div></div></div><br>
</blockquote></div><br>