platipy icon indicating copy to clipboard operation
platipy copied to clipboard

image registration check raises exception

Open bwheelz36 opened this issue 1 year ago • 3 comments

Hey, I wanted to check the image registration functionality.

  • I tried Bsplines with the script below, and got ITK ERROR: ResampleImageFilter(000001848246B530): Interpolator not set
  • The data I used is from synthRad and can be publicly downloaded

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)

bwheelz36 avatar Oct 27 '23 07:10 bwheelz36

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.

pchlap avatar Oct 31 '23 21:10 pchlap

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)

rnfinnegan avatar Oct 31 '23 21:10 rnfinnegan

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.

bwheelz36 avatar Nov 02 '23 09:11 bwheelz36