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"))
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) 
image_from_dcm = reader.Execute() 
Out[92]: 'PIR'

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()
Out[8]: (-1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, -1.0)
Out[9]: 'RPI'


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

but the dicom orientation tag was

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?