This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the user guide for the big picture.

7.5.4. nilearn.image.crop_img

nilearn.image.crop_img(img, rtol=1e-08, copy=True)

Crops img as much as possible

Will crop img, removing as many zero entries as possible without touching non-zero entries. Will leave one voxel of zero padding around the obtained non-zero area in order to avoid sampling issues later on.


img: Niimg-like object

rtol: float

relative tolerance (with respect to maximal absolute value of the image), under which values are considered negligeable and thus croppable.

copy: boolean

Specifies whether cropped data is copied or not.


cropped_img: image

Cropped version of the input image