Hi, All
Given an input nifti image, in.nii.gz, if I intend to crop it from 1/5 slices along z dimension and save the cropped image into a new nifti file with same header except dimensions, how can I do it.
I only figure out how to crop but am not sure about updating the header and save it. Can someone shed a light on this? Thanks.
img = nib.load('in.nii.gz')
data = img.get_data()
nbrSlces = data.shape[2]
nbrCrops = int(nbrSlces * 0.20)
crop = data[:, :, nbrCrops:]