<p class="MsoNormal"><span style="font-family:"Verdana","sans-serif"">I have an
source 3D image of MR (sagittal, with image orientation: 0\1\0\0\0\-1) and I’ve
created a new 3D image by duplicating it or using it as a template. Then,
I write a 2D DICOM series out. I expect the same image orientation but instead
it is 1\0\0\0\1\0 (axial). Why?</span></p>
<p class="MsoNormal"><span style="font-family:"Verdana","sans-serif""> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Verdana","sans-serif"">I
tried to override the tag of the DICOM with image orientation: 0\1\0\0\0\-1, it
did not work. Then I use itk::</span><span style="font-family:"Verdana","sans-serif";color:windowtext">OrientImageFilter to change to coronal but the image
orientation tag is still </span><span style="font-family:"Verdana","sans-serif"">1\0\0\0\1\0
(axial) even though the image orientation has changed. </span><span style="font-family:"Verdana","sans-serif";color:windowtext"></span></p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">Why can I change the value of the DICOM tag: image
orientation (patient)? I need to match the image orientation (patient)
with the real orientation of the 3D image( the image is sagittal, the
head of dicom has to be sagittal, not axial).<br></p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">Please help! Thanks. </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">----------------------------------------------------------------------------------------------</p>
<p class="MsoNormal">The code samples</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">//create a new 3D image from an existing one</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">ImageType_SignedShort::Pointer ctImage =
ImageType_SignedShort::New();</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">pImage->SetRegions(m_vMRScanClass[0].Reader->GetOutput()->GetRequestedRegion());</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">pImage->SetSpacing(m_vMRScanClass[0].Reader->GetOutput()->GetSpacing());</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">pImage->SetDirection(m_vMRScanClass[0].Reader->GetOutput()->GetDirection());</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">pImage->SetMetaDataDictionary(m_vMRScanClass[0].Reader->GetOutput()->GetMetaDataDictionary());</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">pImage->Allocate();</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">pImage->FillBuffer(0);</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">//duplicate an exsing 3D image</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">ImageType_SignedShort::Pointer
ctImageTest = ImageType_SignedShort::New();</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">typedef itk::ImageDuplicator<
ImageType_SignedShort > DuplicatorType;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">DuplicatorType::Pointer duplicator =
DuplicatorType::New();</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">duplicator->SetInputImage(m_vMRScanClass[0].Reader->GetOutput());</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">duplicator->Update();</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">ctImageTest =
duplicator->GetOutput();</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">ctImageTest->FillBuffer(0);</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">//However, if I write it out as CT image
with the following code, </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">typedef</span><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">
itk::NumericSeriesFileNames
NamesGeneratorType;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">ImageIOType::Pointer gdcmIO =
ImageIOType::New();</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">itksys::SystemTools::MakeDirectory(
outputDirectory.c_str() );</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">typedef</span><span style="font-size:9.5pt;font-family:Consolas;color:windowtext"> </span><span style="font-size:9.5pt;font-family:Consolas;color:blue">signed</span><span style="font-size:9.5pt;font-family:Consolas;color:windowtext"> </span><span style="font-size:9.5pt;font-family:Consolas;color:blue">short</span><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">
PixelType_UnsignedChar;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">const</span><span style="font-size:9.5pt;font-family:Consolas;color:windowtext"> </span><span style="font-size:9.5pt;font-family:Consolas;color:blue">unsigned</span><span style="font-size:9.5pt;font-family:Consolas;color:windowtext"> </span><span style="font-size:9.5pt;font-family:Consolas;color:blue">int</span><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">
OutputDimension = 2;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">typedef</span><span style="font-size:9.5pt;font-family:Consolas;color:windowtext"> itk::Image< PixelType_UnsignedChar,
OutputDimension > Image2DType;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">typedef</span><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">
itk::ImageSeriesWriter<ImageType_SignedShort, Image2DType >
SeriesWriterType;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">NamesGeneratorType::Pointer
namesGenerator = NamesGeneratorType::New();</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">itk::MetaDataDictionary & dict =
gdcmIO->GetMetaDataDictionary();</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">itk::EncapsulateMetaData<std::string>(dict,
"0008|0060", "CT");</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">itk::EncapsulateMetaData<std::string>(dict,
"0008|0008", "ORIGINAL\\PRIMARY\\SAGITTAL");</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">
</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">//does not work, why? itk issue?</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">itk::EncapsulateMetaData<std::string>(dict,
"0020|0037", "0\\1\\0\\0\\0\\-1 ");</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">SeriesWriterType::Pointer seriesWriter =
SeriesWriterType::New();</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">seriesWriter->SetInput( inputImage );</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">seriesWriter->SetImageIO( gdcmIO );</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">ImageType_SignedShort::RegionType region
= inputImage->GetLargestPossibleRegion();</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">ImageType_SignedShort::IndexType start =
region.GetIndex();</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">ImageType_SignedShort::SizeType
size = region.GetSize();</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">std::string format = outputDirectory;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">format += </span><span style="font-size:9.5pt;font-family:Consolas;color:#a31515">"/image%03d.dcm"</span><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">namesGenerator->SetSeriesFormat(
format.c_str() );</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">namesGenerator->SetStartIndex(
start[2] );</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">namesGenerator->SetEndIndex( start[2]
+ size[2] - 1 );</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">namesGenerator->SetIncrementIndex( 1
);</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">seriesWriter->SetFileNames(
namesGenerator->GetFileNames() );</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">try</span><span style="font-size:9.5pt;font-family:Consolas;color:windowtext"></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">{</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">
seriesWriter->Update();</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">}</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">catch</span><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">( itk::ExceptionObject & ex )</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">{</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">
std::cerr << ex << std::endl;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext"> </span><span style="font-size:9.5pt;font-family:Consolas;color:blue">throw</span><span style="font-size:9.5pt;font-family:Consolas;color:windowtext"> ex;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">}</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext">The Image orientation (patient) still is
1\0\0\0\1\0 instead of 0\1\0\0\0\-1 </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:windowtext"> </span></p>