rotating an image after resampling to get the right slice direction

706 views Asked by At

I'm using simpleITK in python to do image registration between an atlas image and an MRI image. I'm doing a resampling to give the atlas the same metadata as the image (origin, direction, spacing etc...) here's the atlas 3D image : atlas this step will move the atlas physical frame to the image frame but will not move the actual atlas image and voxels, so I'm applying a centered transform initialiser function between the image and the atlas like the following :

initial_transform = sitk.CenteredTransformInitializer(
image,
atlas,
sitk.Similarity3DTransform(),
sitk.CenteredTransformInitializerFilter.GEOMETRY ,
)
atlas = sitk.Resample(atlas, size=(image.GetSize()),
                  transform=initial_transform,
                  interpolator=sitk.sitkLinear,
                  outputOrigin=image.GetOrigin(),
                  outputSpacing=image.GetSpacing(),
                  outputDirection=image.GetDirection(),
                  defaultPixelValue=0.0,
                  outputPixelType=image.GetPixelID())

this works fine if the atlas and the image are in the same anatomical plane (coronal plane in my case for the atlas), but if the image is in a different anatomical plane the atlas will moved to that specific plane, but the slices will be deformed : atlas deformed while I'm supposed to get this : what I'm supposed to achieve don't mind the grayscale difference, I'm doing an histogram matching that's why the atlas looks different.

I think that the problem is that when I'm applying the centered transform initializer function, the atlas is translated to the new image origin and center but since both images have different directions, I need to apply a rotation to get the right slices. How can I exploit the cosine direction matrices of both images (image.GetDirection()) to get the right rotation between both images so I can get the right slices? anyone faced this problem before ? Thank you

1

There are 1 answers

4
Dave Chen On

Is your MRI image in DICOM format? Perhaps the MRI and the atlas images are in different coordinate systems, i.e., LPS vs RAS.

If so, you can try using SimpleITK's DICOMOrientImageFilter class to reorient the images to match. Here's the documentation for the class:

https://simpleitk.org/doxygen/latest/html/classitk_1_1simple_1_1DICOMOrientImageFilter.html#details