Why sitk.GetDirection() is not the same with '0020|0037' ?

In my thought, I think both sitk.GetDirection() and ‘0020|0037’ indicate the patient orientation. However, I find they are different.

Firstly, I get the direction:

>>> sitkImage = sitk.ReadImage('IM_0177')
>>> sitkImage.GetDirection()

and the result is:

(0.9992892857549484, -0.01732918031560729, -0.03347570589180272, 0.017049019173889606, 0.9998173542043812, -0.008636502588384802, 0.03361925520551655, 0.008059636551358978, 0.9994022152957668)

Then, I obtain the ‘0020|0037’ tag:

>>> reader = sitk.ImageFileReader()
>>> reader.SetFileName('IM_0177')
>>> reader.LoadPrivateTagsOn()
>>> reader.ReadImageInformation()
>>> reader.GetMetaData('0020|0037')

and the result is:

'0.99928927421569\\0.01704902015626\\0.03361925482749\\-0.0173291806131\\0.9998173713684\\0.00805963668972'

Why they are different?
for x[0]: 0.9992892857549484 vs 0.99928927421569??

Image importers can choose direction of voxel coordinate system axes arbitrarily (for example, directions can be chosen si that voxels do not have to be reordered in memory after reading from files). Since all image processing operations happen in physical space, it typically does not matter what the voxel coordinate system is.

But, what if I want the voxel coordiante system? How can I get the direction which is the same from the ‘0020|0037’? Do I must use reader.GetMetaData?

Why would you like to know value of image position/orientation patient tags? Would you like to handle missing slices, varying slice spacing, or non-Cartesian (e.g., tilted-gantry) images?

Yes, if the field is available as metadata then you can use that. If the reader does not provide you this field (e.g., because the series is stored in enhanced multi-frame format, which contains image position/orientation patient in a sequence field) then you may need to go back to the original DICOM files and read the tags using pydicom.

1 Like