SimpleElastix icon indicating copy to clipboard operation
SimpleElastix copied to clipboard

Rigid transformation warping with "TransformixImageFilter"

Open Joeycho opened this issue 2 years ago • 0 comments

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') 

Joeycho avatar Sep 06 '22 15:09 Joeycho