ITK Image Direction vs DICOM Image Orientation (Patient)

I am working with a directory containing sagittal DICOM images.

Here is how I obtain Image Orientation (DICOM tag 0020,0037) using pydicom.

from pydicom import dcmread
import os
dcm_dir = r"path/to/dicom/dir/sagittal_acq"
ds = dcmread(os.path.join(dcm_dir,"000000.dcm"))
ds.ImageOrientationPatient
Out[88]: [0, 1, -1e-016, 0.05582152223083, 0, -0.9984407632183]

In the following code, I read the contents of this directory into an ITK Image and get the Direction. However, the Direction differs from original DICOM (0020,0037).

import SimpleITK as sitk
reader = sitk.ImageSeriesReader() 
dicom_names = reader.GetGDCMSeriesFileNames(dcm_dir) 
reader.SetFileNames(dicom_names) 
image_from_dcm = reader.Execute() 
sitk.DICOMOrientImageFilter_GetOrientationFromDirectionCosines(image_from_dcm.GetDirection())
Out[92]: 'PIR'
image_from_dcm.GetDirection()
Out[91]: 
(-5.573448326015114e-18,
 0.055821522230826974,
 -0.9984407632182459,
 1.0,
 -4.81482486096809e-35,
 -5.582152223082697e-18,
 -3.1160423441667093e-19,
 -0.9984407632182459,
 -0.055821522230826974)

Is there a way to get Direction from ITK Image that matches DICOM Orientation 0020,0037?

As Image row is oriented from A to P (as shown by DICOMOrientImageFilter_GetOrientationFromDirectionCosines), I expected the direction cosines of row (1st three elements) from ITK’s GetDirection to be [0,1,0], which is what I get with ds.ImageOrientationPatient[:3].

I tested the same with HFS and FFS oriented DICOM files and the Direction obtained from getDirection() matches DICOM.

For example, for FFS scan I get the following which matches DICOM Orientation 0020,0037

img_ori = image_from_dcm.GetDirection()
img_ori
Out[8]: (-1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, -1.0)
sitk.DICOMOrientImageFilter_GetOrientationFromDirectionCosines(img_ori)
Out[9]: 'RPI'

Thanks!

Hello @aditya,

The DICOM tag 0020,0037 “Image Orientation Patient” lists the x axis, first three numbers, followed by the y axis, last three numbers. These are the columns of the direction cosine matrix (see the standard). These correspond to the first two columns of the direction matrix returned by the GetDirection method, which returns the matrix in row major order (first three numbers are first row…). If you look at that matrix you will see that the first column is [0, 1.0, 0] and the second column is [0.055821522230826974, 0, -0.9984407632182459] which match the values in the DICOM tag.

Got it. Thank you so much @zivy

hi, I used getDirection method to get the returned direction was
Snipaste_2024-04-09_15-42-06

but the dicom orientation tag was
Snipaste_2024-04-09_15-43-58

it seems the direction maxtrix first colums was [1,0,0], why didn’t the orientation correspond to the first two columns of the direction matrix?