ANTsX / ANTsPy

A fast medical imaging analysis library in Python with algorithms for registration, segmentation, and more.
https://antspyx.readthedocs.io
Apache License 2.0
629 stars 161 forks source link

ANTsImage operators don't work on Windows for right-sided operations #549

Closed cookpa closed 2 months ago

cookpa commented 7 months ago

@ncullen93 looks like #547 is not working on Windows

Traceback (most recent call last):
  File "D:\a\ANTsPy\ANTsPy\tests\test_core_ants_image.py", line 239, in test__radd__
    img2 = 6.9 + img
TypeError: unsupported operand type(s) for +: 'float' and 'ANTsImage'
ncullen93 commented 7 months ago

Thanks, I saw the windows build was failing and didnt realize it would fail the build if the tests fail. Now I know to check! It's a weird issue but I have tried to at least fix the tests. Couldn't find any reason why those operations would fail only in windows.

cookpa commented 7 months ago

Yeah, it is a mystery to me as well. Works fine on Mac. As the error is with ANTsImage and not the numpy array, I infer that it's not finding the __radd__ function for some reason, rather than trying to run it and failing.

cookpa commented 7 months ago

This works on all platforms:

im = ants.image_read(ants.get_ants_data('r16'))
im2 = im + 1

This works on Mac and Linux, but fails on Windows:

im = ants.image_read(ants.get_ants_data('r16'))
im2 = 1 + im