<div dir="ltr">Hello all,<br><br>I am trying to apply some ITK filters to input DICOM images and I am writing DICOM back. However, there is an issue with the ImageOrientationPatient (IOP) tag. So, the way I am writing DICOM back is as follows:<br>
<br>typedef itk::NumericSeriesFileNames NamesGeneratorType;<br>NamesGeneratorType::Pointer namesGenerator = NamesGeneratorType::New();<br>std::string seriesFormat = current_out_dir + &quot;/&quot; + &quot;IM_%d.dcm&quot;;<br>
namesGenerator-&gt;SetSeriesFormat (seriesFormat.c_str());<br>namesGenerator-&gt;SetStartIndex(1);<br>namesGenerator-&gt;SetEndIndex(120);<br>typedef itk::Image&lt;VoxelType, 2&gt; OutputImageType;<br>typedef itk::ImageSeriesWriter&lt;ImageType, OutputImageType &gt; SeriesWriterType;<br>
<br>SeriesWriterType::Pointer seriesWriter = SeriesWriterType::New();<br>// Output is from the itkTileFilter object<br>seriesWriter-&gt;SetInput(tileFilter-&gt;GetOutput());<br>seriesWriter-&gt;SetImageIO(dicomIO); //GDCMImageIO<br>
seriesWriter-&gt;SetFileNames(namesGenerator-&gt;GetFileNames());<br><br>// Now I generate the metadatadictionary array<br><br>ReaderType::DictionaryRawPointer inputDict = (*(itkReaders[itkReaders.size()-1]-&gt;GetMetaDataDictionaryArray()))[0];<br>
ReaderType::DictionaryArrayType outputArray;<br><br><div>for (int d = 0; d &lt; 120; ++d) {<br><br>            ReaderType::DictionaryRawPointer dict = new ReaderType::DictionaryType;</div><div><br>            CopyDictionary(*inputDict, *dict);<br>
<br>            std::string test;<br><br>            itk::ExposeMetaData&lt;std::string&gt;(*dict, &quot;0020|0037&quot;, test);<br><br>            // This outputs the correct IOP (1/0/0/0/0/-1)<br>            std::cout &lt;&lt; test &lt;&lt; std::endl; <br>
<br>            outputArray.push_back(dict);<br><br>        }<br><br>        seriesWriter-&gt;SetMetaDataDictionaryArray(&amp;outputArray);</div><div>        <span style="color:rgb(0,0,0)">seriesWriter</span><span style="color:rgb(0,0,0)">-&gt;</span>Update<span style="color:rgb(0,0,0)">();</span></div>
<div><span style="color:rgb(0,0,0)"><br></span></div><div><span style="color:rgb(0,0,0)">Now, even though the metadata says the IOP should be 1/0/0/0/0/-1, the files that are generated by the last line have the IOP set to 1/0/0/0/1/0.</span></div>
<div><span style="color:rgb(0,0,0)"><br></span></div><div><font color="#000000">I am not sure what I need to do to get the IOP to the correct value. I will appreciate any help you can give me as I am quite stuck here!</font></div>
<div><font color="#000000"><br></font></div><div><font color="#000000">Many thanks,</font></div><div><font color="#000000"><br></font></div><div><font color="#000000">Luca</font></div>
<div>        </div></div>