crop_image#
- petpal.preproc.image_operations_4d.crop_image(input_image_path: str, out_image_path: str, x_dim: int = 256, y_dim: int = 256)#
Crops an image in the X and Y axes to exclude voxels outside of the head. This is done to reduce the size of the image for faster processing, while preserving scientifically valuable information. Preserves dimension along Z and time axes.
The returned, cropped image is centered on the “center of mass” computed using
scipy.ndimage.center_of_mass(). If the image is 3D, the center of mass is computed directly on the image array. If the image is 4D, the image is first averaged over the time axis before computing the center of mass.- Parameters:
input_image_path (str) – Path to input image to be cropped.
out_image_path (str) – Path to which cropped image is saved.
x_dim (int) – Size of the X axis of the returned image. Default value 256.
y_dim (int) – Size of the Y axis of the returned image. Default value 256.
- Returns:
cropped_image (nibabel.nifti1.Nifti1Image) – The cropped image.