I was hoping to get some help with an issue I am experiencing when changing format from Dicom to Nifti. I am trying to export the masks in Mimics (Materialise) to nifti format, via the scripting module.
I tried using dicom2nifti function to get the affine transformation. First, I converted the whole Dicom image to Nifti using dicom2nifti. Then, I "get" the affine matrix using these commands:
image = nib.load (path to image)
affine_nifti = image.affine
Then, I get the masks of interest into an array format (via the Mimics scripting module) and use the following line to export the mask into nifti format:
mask_img = nib.nifti1.Nifti1Image(mask_array, affine_nifti)
However, when I view the resulting image in ITK-snap, the orientations are wrong (see image below). For reference, it is a mask of the vertebral column.
I am not sure what I am getting wrong here, but since the orientations are wrong, something is not working in my procedure. I was hoping to get some help to get the correct orientation for the mask in Nifti format. The image exported by dicom2nifti is correctly oriented when viewed in ITK-snap, so I am a bit confused.
Hi,
I was hoping to get some help with an issue I am experiencing when changing format from Dicom to Nifti. I am trying to export the masks in Mimics (Materialise) to nifti format, via the scripting module.
I tried using dicom2nifti function to get the affine transformation. First, I converted the whole Dicom image to Nifti using dicom2nifti. Then, I "get" the affine matrix using these commands: image = nib.load (path to image) affine_nifti = image.affine
Then, I get the masks of interest into an array format (via the Mimics scripting module) and use the following line to export the mask into nifti format: mask_img = nib.nifti1.Nifti1Image(mask_array, affine_nifti)
However, when I view the resulting image in ITK-snap, the orientations are wrong (see image below). For reference, it is a mask of the vertebral column.
I am not sure what I am getting wrong here, but since the orientations are wrong, something is not working in my procedure. I was hoping to get some help to get the correct orientation for the mask in Nifti format. The image exported by dicom2nifti is correctly oriented when viewed in ITK-snap, so I am a bit confused.
Please let me know if anything is not clear.
Thank you for your help,
Erica