Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Rigid transformation warping with "TransformixImageFilter" #483

Open
Joeycho opened this issue Sep 6, 2022 · 0 comments
Open

Rigid transformation warping with "TransformixImageFilter" #483

Joeycho opened this issue Sep 6, 2022 · 0 comments

Comments

@Joeycho
Copy link

Joeycho commented Sep 6, 2022

Hello, all.

I started registration with SimpleITK and moved to SimpleElastix for expecting finding the best parameters automatically.

What I tried to do was registering two segmentation labels(CT, GT for the same lesion) via Rigid and warping CT image(moving) to MR image(Fixed) using deformation field from those labels. But the issue was CT image and MR image are bigger than labels. And I cannot set new FixedImage with "TransformixImageFilter". Therefore, moved image(warped image) was displeasingly cropped.

To overcome the issue, I pre-padded labels as MR image(larger fixed image later) and I warpped the CT image. It was slightly better, but it still lost part of the original image.

I go back to SimpleITK because of this warping issue. Anyone who has similar issue and overcome this in SimpleElastix?

The below code is simplified version of what I used.

# Elastix filter via sitk.  set fixed and moving image and setup for Rigid tranformation      
elastixImageFilter = sitk.ElastixImageFilter()
elastixImageFilter.SetFixedImage(image_t1_label)
elastixImageFilter.SetMovingImage(image_ct_label)
rigid = sitk.GetDefaultParameterMap("rigid")
rigid['Interpolator'] = ["NearestNeighborInterpolator"]
elastixImageFilter.SetParameterMap(rigid)
elastixImageFilter.Execute()

# postprocessing for labels(0 and 1)
reference = image_t1_label
segmentation = sitk.Cast(elastixImageFilter.GetResultImage()>0.5,sitk.sitkUInt8)
segmentation.SetOrigin(reference.GetOrigin())

# extract deformation field and set Interpolator as LinearInterpolator for images
transformParameterMap = elastixImageFilter.GetTransformParameterMap()
transformParameterMap[0]['ResampleInterpolator']=["FinalLinearInterpolator"]

# warping the CT image, failed to set T1 image as fixed image. T1 label is still fixed image and it is smaller than T1 image (size).
transformixImageFilter = sitk.TransformixImageFilter()
transformixImageFilter.SetTransformParameterMap(transformParameterMap)          
#transformixImageFilter.SetFixedImage(image_t1)# I wanted to set fixed image as image_t1 not image_t1_label for tackling different size and origin. Physical locations were correct(image_t1_label is overlapped to image_t1)
transformixImageFilter.SetMovingImage(image_ct)
transformixImageFilter.Execute()
sitk.WriteImage(transformixImageFilter.GetResultImage(), 'moved_ct_image.nii.gz') 
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant