pythonimage-processingregistrationsimpleitktransformation-matrix

SimpleITK: apply inverse transformation


I have recently began to use SimpleITK for image registration. For my current project I need to register an X-Ray image and a CT image, and then apply the inverse matrix on a ROI mask traced on the X-Ray image.

I got the inverse matrix with this line:

inverse_transform = final_transform.GetInverse()

How can I apply the transform to the ROI mask?


Solution

  • Welcome to SimpleITK!

    Assuming your X-ray is the fixed image in the registration (CT is the moving) then the result of the registration is a transformation mapping points from the X-ray to the CT. All you need to do is re-sample your ROI mask image onto the CT using the inverse transformation.

    transformed_labels = sitk.Resample(xray_roi_mask, ct_image, inverse_transform, sitk.sitkNearestNeighbor, 0.0, #out of bounds pixel color xray_roi_mask.GetPixelID())

    The last cell of this Jupyter notebook does this.

    Two additional comments:

    1. Not sure what you mean by X-ray to CT registration. This is a 2D/3D registration which is currently not supported by SimpleITK, so I am assuming that your are either doing 2D/2D or 3D/3D registration.
    2. As you are new to SimpleITK I would recommend looking at our main Jupyter notebook repository or the more concise IEEE ISBI'18 tutorial to familiarize yourself with the toolkit.