Closed ncullen93 closed 1 month ago
Also, indexing images with images works more as expected. The index image will act as a mask so any indexes in the image which are zero in the mask will be turned to zero.
Example:
import ants
img = ants.image_read(ants.get_data('r16'))
mask = img > 160
img2 = img[mask] # same shape as img but now values less than 160 have been set to 0
mask = img > 160 img2 = img[mask] # same shape as img but now values less than 160 have been set to 0
This one might cause some confusion, I do this to mean give me the voxels inside the mask.
Ok, thanks for letting me know because I was also very torn about this one. I guess that same effect can be achieved with img * mask so it makes sense to keep the original functionality. Should it always be a flattened array of values or should it maintain the dimensions?
I'd say flat array, but would also ask @stnava and @ntustison
That's the current behavior so it makes sense to keep it.
Currently if you index an ants image it always returns a numpy array. The intuitive response to indexing an image should instead be an image. And that image should retain the spatial properties of the original image.
If you index only one dimension, that should return a 1D numpy array. And if you index on one value then you get that value.
Example: