ANTsPy
ANTsPy copied to clipboard
Padding ---> Cropping: indices issue?
Describe the bug
Cropping following padding throws an error: Requested region is (at least partially) outside the largest possible region.
To Reproduce
import ants
image = ants.image_read(ants.get_ants_data('r16'))
padded_image = ants.pad_image(image, shape=(300,300))
cropped_image = ants.crop_indices(padded_image, (0, 0), (300, 300))
# This is where the error is thrown. Perhaps this is expected considering
# a behind-the-scenes changing of the indices of the image. The following
# two lines also throw the same error (just for completeness):
cropped_image = ants.crop_indices(padded_image*1, (0, 0), (300, 300))
cropped_image = ants.crop_indices(ants.image_clone(padded_image), (0, 0), (300, 300))
# However, if I do the following:
cropped_image = ants.crop_indices(ants.image_clone(padded_image)*1, (0, 0), (300, 300))
# the operation happens without issue. I don't know if this is a bug, per se,
# but it's quirky behavior. Is this an issue of ANTsPy/ANTsR not keeping
# track of the image indices?
I think this is a bug - I also expect something related in the recent padding functions that were added - noting different behavior from R - should confirm/address this later.