pyplati / platipy

Processing Library and Analysis Toolkit for Medical Imaging in Python
https://pyplati.github.io/platipy/
Apache License 2.0
103 stars 24 forks source link

image registration check raises exception #238

Open bwheelz36 opened 8 months ago

bwheelz36 commented 8 months ago

Hey, I wanted to check the image registration functionality.

Weirdly, if I comment out this SetInterpolator line the code runs. If I change interpolation order from the platipy default (3) to the SITK default (2) the code runs...

from pathlib import Path
from platipy.imaging.registration import deformable as df
import SimpleITK as sitk

fixed_image_loc = Path(r'X:\SynthRadChallenge\brain\2BA001\cbct.nii.gz')
moving_image_loc = Path(r'X:\SynthRadChallenge\brain\2BA002\ct.nii.gz')

assert fixed_image_loc.is_file()
assert moving_image_loc.is_file()

fixed_image = sitk.ReadImage(fixed_image_loc)
moving_image = sitk.ReadImage(moving_image_loc)

registered_image, output_transform = df.bspline_registration(fixed_image, moving_image, ncores=4)
pchlap commented 8 months ago

Hi @bwheelz36, thanks for reporting this. I imagine this is due to a new SimpleITK version. Seems like we have been discovering a few breaking changes since SimpleITK 2.3.0.

I will look into this and hopefully can rectify the issue. Thanks.

rnfinnegan commented 8 months ago

Hi @bwheelz36 and @pchlap - yes I believe this is due to a change in SimpleITK versions.

Previously, sitk.sitkBSpline was equal to 3 (see SimpleITK v2.1.0 code)

Now, sitk.sitkBSpline is equal to 23 (see SimpleITK v2.3.0 code)

I'm not sure why this has changed, but if we change the default interpolation in the BSplines registration code to sitk.sitkBSpline (rather than the actual integer value 3) this should solve the problem. In the meantime, you could also run the last line of code as:

registered_image, output_transform = df.bspline_registration(fixed_image, moving_image, ncores=4, interp_order=sitk.sitkBSpline)
bwheelz36 commented 8 months ago

guys, your library is really well written and helpful - thanks! it's nice just to see all the options cleanly documented, i'm struggling with the sitk docs.