<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco">I am trying to output post-processed data that preserves most of the DICOM metadata from the input DICOM files, but with a few fields modified. Unfortunately, while the data itself is output and appears correct, I can't seem to get ITK to include anything but what I guess is the default GDCM DICOM stuff. A snippet of the code that I'm using (InputType is Image<float,3>, OutputType is Image<short,3>) is below. The dumpITKMetadata function just prints all the tag/value pairs to std::cout - in this case, the first call includes altered/added fields, so my changes are propagating correctly into the gdcmImageIO variable, but don't seem to make it the rest of the way through the pipeline. Any suggestions on what I may be doing wrong?</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"><BR class="khtml-block-placeholder"></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco">Regards,</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"><BR class="khtml-block-placeholder"></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco">Matthias</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"><BR class="khtml-block-placeholder"></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"><BR class="khtml-block-placeholder"></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"><BR class="khtml-block-placeholder"></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" color="#236E25" face="Monaco">// set up ITK DICOM image series writer</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" color="#760F50" face="Monaco">typedef</FONT><FONT class="Apple-style-span" face="Monaco"> itk::ImageFileWriter<OutputType></FONT><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" face="Monaco">WriterType;</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">WriterType::Pointer</FONT><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" face="Monaco">writer = WriterType::New();</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" color="#760F50" face="Monaco">static</FONT><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" color="#760F50" face="Monaco">const</FONT><FONT class="Apple-style-span" face="Monaco"> std::string</FONT><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">output_name = </FONT><FONT class="Apple-style-span" color="#891315" face="Monaco">"/Users/matthiasschabel/Temporary/Ktrans.dcm"</FONT><FONT class="Apple-style-span" face="Monaco">;</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" color="#760F50" face="Monaco">typedef</FONT><FONT class="Apple-style-span" face="Monaco"> itk::GDCMImageIO</FONT><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">ImageIOType;</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">ImageIOType::Pointer</FONT><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">gdcmImageIO = ImageIOType::New();</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">metadata_type& </FONT><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">dict = gdcmImageIO->GetMetaDataDictionary();</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">copyITKMetadata(metadata(</FONT><FONT class="Apple-style-span" color="#0000FF" face="Monaco">0</FONT><FONT class="Apple-style-span" face="Monaco">),dict);</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" color="#236E25" face="Monaco">// DICOM dictionary values</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" color="#760F50" face="Monaco">static</FONT><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" color="#760F50" face="Monaco">const</FONT><FONT class="Apple-style-span" face="Monaco"> std::string</FONT><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" face="Monaco">modalityTag </FONT><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">= </FONT><FONT class="Apple-style-span" color="#891315" face="Monaco">"0008|0060"</FONT><FONT class="Apple-style-span" face="Monaco">,</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">seriesDescriptionTag</FONT><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">= </FONT><FONT class="Apple-style-span" color="#891315" face="Monaco">"0008|103e"</FONT><FONT class="Apple-style-span" face="Monaco">,</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">seriesNumberTag </FONT><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">= </FONT><FONT class="Apple-style-span" color="#891315" face="Monaco">"0020|0011"</FONT><FONT class="Apple-style-span" face="Monaco">,</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">windowCenterTag </FONT><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">= </FONT><FONT class="Apple-style-span" color="#891315" face="Monaco">"0028|1050"</FONT><FONT class="Apple-style-span" face="Monaco">,</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">windowWidthTag</FONT><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">= </FONT><FONT class="Apple-style-span" color="#891315" face="Monaco">"0028|1051"</FONT><FONT class="Apple-style-span" face="Monaco">,</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">rescaleInterceptTag </FONT><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">= </FONT><FONT class="Apple-style-span" color="#891315" face="Monaco">"0028|1052"</FONT><FONT class="Apple-style-span" face="Monaco">,</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">rescaleSlopeTag </FONT><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">= </FONT><FONT class="Apple-style-span" color="#891315" face="Monaco">"0028|1053"</FONT><FONT class="Apple-style-span" face="Monaco">;</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">itk::EncapsulateMetaData<std::string>(dict,modalityTag,</FONT><FONT class="Apple-style-span" color="#891315" face="Monaco">"MR"</FONT><FONT class="Apple-style-span" face="Monaco">);</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">itk::EncapsulateMetaData<std::string>(dict,seriesDescriptionTag,</FONT><FONT class="Apple-style-span" color="#891315" face="Monaco">"Ktrans"</FONT><FONT class="Apple-style-span" face="Monaco">);</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">itk::EncapsulateMetaData<std::string>(dict,windowCenterTag,</FONT><FONT class="Apple-style-span" color="#891315" face="Monaco">"500.0"</FONT><FONT class="Apple-style-span" face="Monaco">);</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">itk::EncapsulateMetaData<std::string>(dict,windowWidthTag,</FONT><FONT class="Apple-style-span" color="#891315" face="Monaco">"1000.0"</FONT><FONT class="Apple-style-span" face="Monaco">);</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">itk::EncapsulateMetaData<std::string>(dict,rescaleInterceptTag,</FONT><FONT class="Apple-style-span" color="#891315" face="Monaco">"0.0"</FONT><FONT class="Apple-style-span" face="Monaco">);</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">itk::EncapsulateMetaData<std::string>(dict,rescaleSlopeTag,</FONT><FONT class="Apple-style-span" color="#891315" face="Monaco">"1000.0"</FONT><FONT class="Apple-style-span" face="Monaco">);</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">dumpITKMetadata(dict,std::cout);</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">dumpITKMetadata(metadata(</FONT><FONT class="Apple-style-span" color="#0000FF" face="Monaco">0</FONT><FONT class="Apple-style-span" face="Monaco">),std::cout);</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">writer->SetInput(rescaler->GetOutput());</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">writer->SetFileName(output_name.c_str()); </FONT><FONT class="Apple-style-span" face="Monaco"> </FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">writer->SetImageIO(gdcmImageIO);</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" color="#760F50" face="Monaco">try</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">{</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">writer->Update();</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">}</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" color="#760F50" face="Monaco">catch</FONT><FONT class="Apple-style-span" face="Monaco"> (itk::ExceptionObject& e)</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">{</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">std::cerr << </FONT><FONT class="Apple-style-span" color="#891315" face="Monaco">"exception in file reader "</FONT><FONT class="Apple-style-span" face="Monaco"> << std::endl;</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">std::cerr << e << std::endl;</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" color="#760F50" face="Monaco">throw</FONT><FONT class="Apple-style-span" face="Monaco">;</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco"> </FONT><FONT class="Apple-style-span" face="Monaco">}</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco">}</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><BR><BR></BODY></HTML>