Hi, I would like to remove the first 10 timepoints from a 4d NIfTI using some python tool. I assume NiPy or Nilearn should have some way of easily doing so - but I was unable to find that via google.
import nibabel as nib
data = nib.load('/path/to/file.nii.gz').get_data()
data_wo_time_points = data[..., 10:]
Is there any way to do this without having to extract the data and the header separately, and then put them back together to an object to save again as a NIfTI?
Apparently there is (well, the header and affine are extracted, but it works inline):
img = nib.load(in_file)
img_ = nib.Nifti1Image(img.get_data()[...,delete_scans:], img.affine, img.header)