Subset 4D images

afni_subset_4d(file, time_start = 0, time_end = "$", by = 1,
  retimg = FALSE)

Arguments

file

4-dimensional Filename or nifti object to subset

time_start

the time point to subset from. Remember timepoint numbering starts from 0

time_end

the last time point to subset

by

How should the subsetting be done. If you want to subset every second time point, use by = 2 for example

retimg

Should an image be returned (TRUE) or a filename?

Value

A nifti object or an output file depending on retimg

Examples

library(kirby21.fmri)
if (have_afni()) {
tdir = tempfile()
res = download_fmri_data(outdir = tdir)
file = kirby21.fmri::get_fmri_filenames(outdir = tdir)[1]
sub_file = afni_subset_4d(file, time_start = 0, time_end = 1)
dim(neurobase::readnii(sub_file))[4] == 2
}