<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 + "/" + "IM_%d.dcm";<br>
namesGenerator->SetSeriesFormat (seriesFormat.c_str());<br>namesGenerator->SetStartIndex(1);<br>namesGenerator->SetEndIndex(120);<br>typedef itk::Image<VoxelType, 2> OutputImageType;<br>typedef itk::ImageSeriesWriter<ImageType, OutputImageType > SeriesWriterType;<br>
<br>SeriesWriterType::Pointer seriesWriter = SeriesWriterType::New();<br>// Output is from the itkTileFilter object<br>seriesWriter->SetInput(tileFilter->GetOutput());<br>seriesWriter->SetImageIO(dicomIO); //GDCMImageIO<br>
seriesWriter->SetFileNames(namesGenerator->GetFileNames());<br><br>// Now I generate the metadatadictionary array<br><br>ReaderType::DictionaryRawPointer inputDict = (*(itkReaders[itkReaders.size()-1]->GetMetaDataDictionaryArray()))[0];<br>
ReaderType::DictionaryArrayType outputArray;<br><br><div>for (int d = 0; d < 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<std::string>(*dict, "0020|0037", test);<br><br> // This outputs the correct IOP (1/0/0/0/0/-1)<br> std::cout << test << std::endl; <br>
<br> outputArray.push_back(dict);<br><br> }<br><br> seriesWriter->SetMetaDataDictionaryArray(&outputArray);</div><div> <span style="color:rgb(0,0,0)">seriesWriter</span><span style="color:rgb(0,0,0)">-></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>