Remove volumes with index list

Hello! I am curious if there is a command to remove select volumes from a timeseries in fsl by using a temporal mask in the form of an index list, such that a list of [0 1 1 1 0 1] will remove the first and fifth volumes. Is this possible using fslroi or another command?

Hi @kgodfrey, and welcome to Neurostars!

Not sure about in FSL, but you may have better luck in Nilearn in Python. For example, if you get an image’s data with

image = nilearn.image.load_img('my_img.nii.gz')
image_data = image.get_fdata()

you can then index into it with a boolean

inds_to_keep = [0, 1, 1, 1, 0, 1]
inds_to_keep_bool = inds_to_keep.astype(bool)
image_data_kept = [:,:,:,inds_to_keep]

Does this make sense?