Dicom to Nifti format using mimics scripting. Problem with affine transformation matrix

Hi Erica,

Unfortunately we don’t have much experience with the NiBabel package and required affine transformation ourselves so I’m afraid we might be very limited in how we can help as we want to avoid giving wrong information.

However, I can confirm that there is a difference between the DICOM tags and resulting Mimics project. The DICOM tags return “raw” dicom information (imported files stripped of pixel data) while Mimics projects contain a lot of transformations and calculations in order to create the coordinate system.

Because of this (and other reasons), it’s not advised to combine DICOM orientation tags (0020, 0037 and 0020,0032) obtained from get_dicom_tags with get_voxel_buffer/get_voxel_center/logical_dimensions API’s related to the Mimics project.

In order to get the image directions (in Mimics for your mask), I would advise using something like the following:

p0 = i.get_voxel_center([0, 0, 0])

b = i.get_voxel_buffer()

d = b.shape

x = i.get_voxel_center([d[0]-1, 0, 0])

y = i.get_voxel_center([0, d[1]-1, 0])

z = i.get_voxel_center([0, 0, d[2]-1])

Another route would be to use “mimics.file.export_dicom” and work from the dicom format rather than the image. Hope this helps!

Kind regards,

Marnic