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
592 stars 160 forks source link

fix issue with plotting negative-sum images #562

Closed ncullen93 closed 4 months ago

ncullen93 commented 4 months ago

If an image has a sum less than zero, then ants.plot rejects it. This is due to code that incorrectly identifies whether an image is all-zero.

This should work:

import ants
img = ants.image_read(ants.get_ants_data('r16'))
img2 = (img - img.mean()) / img.std()
img2.plot()
stnava commented 4 months ago

thanks for working on this - it has been on my todo list for several years

stnava commented 4 months ago

also - I dont this this should raise an error but instead fail "gracefully"

cookpa commented 4 months ago

@stnava you changed it to output a warning instead, which I think is the right call. #562 is just improving the test. It just needs to reduce to a scalar true / false to avoid ambiguity

stnava commented 4 months ago

ok

cookpa commented 4 months ago

@ncullen93 I can fix this real quick, now it looks like all the other runners are done

cookpa commented 4 months ago

566

ncullen93 commented 4 months ago

Yes, thanks. Can you consider reducing the number of python versions tested in the CI to 1 or 2 instead of 5? It takes so long otherwise and doesn't add much. I will try to wait for it to finish going forward though.

cookpa commented 4 months ago

Yeah, it can get painful when there's a lot of activity. I will have a think about how we can do better.

One option might be to put branch protection on master, and insist that all changes go through PR, and then build a couple of wheels in the PR. That would avoid duplication where PR builds pass and then the same wheels get built again on merge