What would be the best way to resample a nifti to a specific list of volums (given as volume indices)?
For example-
Say we have a nifti with 4 volumes, TR=3, and one wants to create a new nifti file consisting the first and the last volume.
The data is after fmriprep preprocessing.
import nibabel as nb
nii = nb.load('<input>')
data = nii.get_data()[tmin:tmin + tsize]
nb.Nifti1Image(data, nii.affine, nii.header).to_filename('<output>')