Martin, you were very helpful !<br><br><br>I give the solution :<br><br><br><br><font face="courier new,monospace">&nbsp; typedef signed short&nbsp;&nbsp;&nbsp; PixelType;<br>
&nbsp; const unsigned int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dimension = 3;<br>&nbsp; typedef itk::Image&lt; PixelType, Dimension &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ImageType;<br>&nbsp; typedef itk::ImageSeriesReader&lt; ImageType &gt;&nbsp;&nbsp;&nbsp;&nbsp; ReaderType;<br>&nbsp; typedef itk::ImageFileReader&lt; ImageType &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ReaderMHDType;<br>

&nbsp; typedef itk::GDCMImageIO&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ImageIOType;<br>&nbsp; typedef itk::GDCMSeriesFileNames&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NamesGeneratorType;&nbsp; <br><br>&nbsp; ImageIOType::Pointer gdcmIO = ImageIOType::New();<br>&nbsp; NamesGeneratorType::Pointer namesGenerator = NamesGeneratorType::New();<br>

&nbsp; <br>&nbsp; namesGenerator-&gt;SetInputDirectory( [...DIRECTORY...] );<br><br>&nbsp; const ReaderType::FileNamesContainer &amp; filenames = <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; namesGenerator-&gt;GetInputFileNames();<br>&nbsp;<br>&nbsp; ReaderType::Pointer reader = ReaderType::New();<br>

<br>&nbsp; reader-&gt;SetImageIO( gdcmIO );<br>&nbsp; reader-&gt;SetFileNames( filenames );<br><br>&nbsp; reader-&gt;Update();<br><br>&nbsp; <b>// BEGIN IMPORTANT CODE</b><br>&nbsp; <br><b>&nbsp; unsigned int nbSlices = filenames.size();<br>&nbsp; <br>&nbsp; ReaderType::DictionaryRawPointer dictionary[nbSlices]; <br>
&nbsp; ReaderType::DictionaryArrayType outputArray;&nbsp; <br>&nbsp; <br>&nbsp; for (unsigned int i = 0; i &lt; nbSlices; i++)<br>&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; dictionary[i] = (*(reader-&gt;GetMetaDataDictionaryArray()))[i];&nbsp;&nbsp; <br><br>&nbsp;&nbsp;&nbsp; std::string entryId(&quot;0008|103e&quot;);<br>
&nbsp;&nbsp;&nbsp; std::string value(&quot;MARTIN IS THE BEST&quot;); </b>// it was just a test ;-)<b><br>&nbsp;&nbsp;&nbsp; itk::EncapsulateMetaData&lt;std::string&gt;( *dictionary[i], entryId, value );&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; outputArray.push_back(dictionary[i]);<br>
&nbsp;&nbsp;&nbsp; }&nbsp; </b><br>&nbsp;&nbsp; <br>&nbsp;&nbsp; <b>// END</b><br>&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; [...]<br>&nbsp;&nbsp;&nbsp; <br>&nbsp; typedef signed short&nbsp;&nbsp;&nbsp; OutputPixelType;<br>&nbsp; const unsigned int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OutputDimension = 2;<br>
<br>&nbsp; typedef itk::Image&lt; OutputPixelType, OutputDimension &gt;&nbsp;&nbsp;&nbsp; Image2DType;<br><br>&nbsp; typedef itk::ImageSeriesWriter&lt; ImageType, Image2DType &gt;&nbsp; SeriesWriterType;<br><br>&nbsp; SeriesWriterType::Pointer seriesWriter = SeriesWriterType::New();<br>

<br>&nbsp; seriesWriter-&gt;SetInput( [...VOLUME...] );<br>&nbsp; seriesWriter-&gt;SetImageIO( gdcmIO );<br><br>&nbsp; namesGenerator-&gt;SetOutputDirectory( outputDirectory );<br><br>&nbsp; seriesWriter-&gt;SetFileNames( namesGenerator-&gt;GetOutputFileNames() );&nbsp; <br>
&nbsp;
<br></font><font face="courier new,monospace">&nbsp; <b>// BEGIN IMPORTANT CODE</b></font><font face="courier new,monospace"><br>&nbsp; <b>seriesWriter-&gt;SetMetaDataDictionaryArray( &amp;outputArray );</b> <br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp; // instead of </span></font><font style="font-family: courier new,monospace;" face="courier new,monospace">:</font><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp; // seriesWriter-&gt;SetMetaDataDictionaryArray( reader-&gt;GetMetaDataDictionaryArray() );</span><br style="font-family: courier new,monospace;">
<font face="courier new,monospace"><b style="font-family: courier new,monospace;">&nbsp; // END</b><br><br>&nbsp; seriesWriter-&gt;Update(); </font><br><br><br><br><br><br>Thank you again Martin ;-)<br><br><br><br><br>Stéphane<br><br>
<br><br><br><br><br><div class="gmail_quote">2008/11/19 Martin Kavec <span dir="ltr">&lt;<a href="mailto:martin.kavec@gmail.com">martin.kavec@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Stephane,<br>
<br>
I was on the same issue two days ago with the same results. The problem is<br>
that each slice in your input series has unique MetaDataDictionary, so you<br>
have to change the field you desire in all of them.<br>
<br>
I have found in the ITK mailing list archives a post from Bill (I guess) where<br>
he send attached a file DicomResample which does what you need. Just google<br>
for DicomResample and the very first reference is what you need.<br>
<br>
Regards,<br>
<font color="#888888"><br>
Martin<br>
</font><div><div></div><div class="Wj3C7c"><br>
On Wednesday 19 November 2008 13:38:06 Stéphane CALANDE wrote:<br>
&gt; Oh sorry, there was a mistake in the entry...<br>
&gt;<br>
&gt; But the field is still not modified... :-(<br>
&gt;<br>
&gt;<br>
&gt; Any other idea ?<br>
&gt;<br>
&gt;<br>
&gt; Thank you Bill ;-)<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; Stéphane<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; 2008/11/19 Bill Lorensen &lt;<a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>&gt;<br>
&gt;<br>
&gt; &gt; Try<br>
&gt; &gt; &nbsp;std::string entryId(&quot;0008|103e&quot;);<br>
&gt; &gt; instead of<br>
&gt; &gt; &nbsp;std::string entryId(&quot;008|103e&quot;);<br>
&gt; &gt;<br>
&gt; &gt; Bill<br>
&gt; &gt;<br>
&gt; &gt; On Wed, Nov 19, 2008 at 6:53 AM, Stéphane CALANDE &lt;<a href="mailto:scalande@gmail.com">scalande@gmail.com</a>&gt;<br>
&gt; &gt;<br>
&gt; &gt; wrote:<br>
&gt; &gt; &gt; Hi itk-list,<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; I&#39;m using the example of &quot;DicomSeriesReadSeriesWrite&quot;, but I&#39;d like to<br>
&gt; &gt; &gt; modify one DICOM header field before writing the Series.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Then I had a look in &quot;DicomImageReadChangeHeaderWrite&quot; and I tried to<br>
&gt; &gt;<br>
&gt; &gt; apply<br>
&gt; &gt;<br>
&gt; &gt; &gt; the part of the code that change the header field into the code of<br>
&gt; &gt; &gt; &quot;DicomSeriesReadSeriesWrite&quot;.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; But it doesn&#39;t seem to work. The field I want to change has not changed<br>
&gt; &gt;<br>
&gt; &gt; in<br>
&gt; &gt;<br>
&gt; &gt; &gt; the output files. Could you have a look in the (simplified) following<br>
&gt; &gt;<br>
&gt; &gt; code<br>
&gt; &gt;<br>
&gt; &gt; &gt; to help me ?<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &nbsp; typedef signed short &nbsp; &nbsp;PixelType;<br>
&gt; &gt; &gt; &nbsp; const unsigned int &nbsp; &nbsp; &nbsp;Dimension = 3;<br>
&gt; &gt; &gt; &nbsp; typedef itk::Image&lt; PixelType, Dimension &gt; &nbsp; &nbsp; &nbsp;ImageType;<br>
&gt; &gt; &gt; &nbsp; typedef itk::ImageSeriesReader&lt; ImageType &gt; &nbsp; &nbsp; ReaderType;<br>
&gt; &gt; &gt; &nbsp; typedef itk::ImageFileReader&lt; ImageType &gt; &nbsp; &nbsp; &nbsp; ReaderMHDType;<br>
&gt; &gt; &gt; &nbsp; typedef itk::GDCMImageIO &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ImageIOType;<br>
&gt; &gt; &gt; &nbsp; typedef itk::GDCMSeriesFileNames &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NamesGeneratorType;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &nbsp; ImageIOType::Pointer gdcmIO = ImageIOType::New();<br>
&gt; &gt; &gt; &nbsp; NamesGeneratorType::Pointer namesGenerator =<br>
&gt; &gt; &gt; NamesGeneratorType::New();<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &nbsp; namesGenerator-&gt;SetInputDirectory( [...DIRECTORY...] );<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &nbsp; const ReaderType::FileNamesContainer &amp; filenames =<br>
&gt; &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; namesGenerator-&gt;GetInputFileNames();<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &nbsp; ReaderType::Pointer reader = ReaderType::New();<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &nbsp; reader-&gt;SetImageIO( gdcmIO );<br>
&gt; &gt; &gt; &nbsp; reader-&gt;SetFileNames( filenames );<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &nbsp; reader-&gt;Update();<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &nbsp; // BEGIN =&gt; I&#39;m trying to modify one DICOM Header field &lt;&lt;&lt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &nbsp; typedef itk::MetaDataDictionary &nbsp; DictionaryType;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &nbsp; ImageType::Pointer inputImage = reader-&gt;GetOutput();<br>
&gt; &gt; &gt; &nbsp; DictionaryType &amp; dictionary = inputImage-&gt;GetMetaDataDictionary();<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &nbsp; std::string entryId(&quot;008|103e&quot;);<br>
&gt; &gt; &gt; &nbsp; std::string value(&quot;NEW VALUE&quot;);<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &nbsp; itk::EncapsulateMetaData&lt;std::string&gt;( dictionary, entryId, value );<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &nbsp; &nbsp;// END<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &nbsp; &nbsp; [...]<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &nbsp; typedef signed short &nbsp; &nbsp;OutputPixelType;<br>
&gt; &gt; &gt; &nbsp; const unsigned int &nbsp; &nbsp; &nbsp;OutputDimension = 2;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &nbsp; typedef itk::Image&lt; OutputPixelType, OutputDimension &gt;<br>
&gt; &gt; &gt; Image2DType;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &nbsp; typedef itk::ImageSeriesWriter&lt; ImageType, Image2DType &gt;<br>
&gt; &gt; &gt; SeriesWriterType;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &nbsp; SeriesWriterType::Pointer seriesWriter = SeriesWriterType::New();<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &nbsp; seriesWriter-&gt;SetInput( [...VOLUME...] );<br>
&gt; &gt; &gt; &nbsp; seriesWriter-&gt;SetImageIO( gdcmIO );<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &nbsp; namesGenerator-&gt;SetOutputDirectory( outputDirectory );<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &nbsp; seriesWriter-&gt;SetFileNames( namesGenerator-&gt;GetOutputFileNames() );<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &nbsp; seriesWriter-&gt;SetMetaDataDictionaryArray(<br>
&gt; &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reader-&gt;GetMetaDataDictionaryArray() );<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &nbsp; seriesWriter-&gt;Update();<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; I would be very grateful if you could help me.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Thank you very much,<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Stéphane<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; _______________________________________________<br>
&gt; &gt; &gt; Insight-users mailing list<br>
&gt; &gt; &gt; <a href="mailto:Insight-users@itk.org">Insight-users@itk.org</a><br>
&gt; &gt; &gt; <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
</div></div></blockquote></div><br>