I noticed with sct_crop_image that it’s not possible to crop an image using a mask that’s in a different resolution. The image is still cropped but just not in the correct place. I think it could be a good additional functionality if the mask could be resampled in the background (perhaps with a warning). Or it would be good to at least throw an error if a given input image and mask have different resolutions to make the issue more explicit for users who are trying to do this.
Example using SCTv6.1, with the data that comes with the installation in data/sct_testing_data/t2/ :
sct_create_mask -i t2.nii.gz -p centerline,t2_centerline-optic.nii.gz -o t2_mask_orig_space.nii.gz -size 28
sct_resample -i t2.nii.gz -o t2_resampled.nii.gz -mm 0.5x0.5x0.5
sct_crop_image -i t2_resampled.nii.gz -o t2_resampled_cropped.nii.gz -m t2_mask_orig_space.nii.gz
Crop mask shown in red, t2_resampled_cropped shown in yellow.
Sorry about the duplicate post, nothing showed in the previous one as I put everything inside the comment tags…