Temporal resampling of nifti

Hi,

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.

Thanks!

Ok, I’ll simply use indexing, after reading the data- will add here code afterwards.

1 Like

Using FSL:

fslroi <input> <output> <tmin> <tsize>

Using python:

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>')
2 Likes