Affine Transformation


I am trying to get the affine transformation to export masks into nifti format. I can get the data for the masks in an array format, and then I would also need the affine transformation. Therefore, I need the following dicom tags

  1. Image Position (0020, 0032)
  2. Image Orientation (0020, 0037)
  3. Pixel Spacing (0028, 0030)
  4. Spacing

However, there seems to be some information missing in my files and Image Position (0020, 0032) is missing. I am wondering if there is something I could do to obtain that information? Could I somehow use the “.get_voxel_center(0,0,0)” to get that position? Would that correspond to the same origin?

Thank you!

Hi Erica,

The Image Position Dicom tag (0020, 0032) corresponds to the x,y and z coordinates of the upper left hand corner of the image (,with%20respect%20to%20the%20patient.)

I’ve tried it out on 1 scan and the “.get_voxel_center([0,0,0])” seems to correspond to the above definition thus this should give you the value for (0020, 0032)

Kind regards,


Just to confirm, I did something similar and confirmed that what Marnic is recommending will work by loading the DICOM files directly with python.