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
648 stars 164 forks source link

BUG: Fix slicing. More consistent with numpy #721

Closed cookpa closed 1 month ago

cookpa commented 1 month ago

Fixing slicing issues detailed in #719. The behavior of slicing should now be consistent with what you get on a numpy array, except that it returns an antsImage for slices with dimensions >= 2.

When slicing by indices, direction matrices are collapsed to identity. Users need to call the slice_image function to control that.

I added support for negative indices, so you can do something like im[:,:,0:-1] and it behaves as numpy does.

coveralls commented 1 month ago

Coverage Status

coverage: 85.341% (+0.003%) from 85.338% when pulling b5380b4c313faef84c1917983ea4a9106638f335 on fix_slicing into 88437eb4b8a9120df32b487216139eb35d379c74 on master.