Skip to contents

This function creates an fMRI dataset object from a set of scans, design information, and other data. The dataset is a list containing information about the scans, mask, TR, number of runs, event table, base path, sampling frame, censor, mode, and preload.

Usage

fmri_dataset(
  scans,
  mask,
  TR,
  run_length,
  event_table = data.frame(),
  base_path = ".",
  censor = NULL,
  preload = FALSE,
  mode = c("normal", "bigvec", "mmap", "filebacked")
)

Arguments

scans

A vector of one or more file names of the images comprising the dataset.

mask

Name of the binary mask file indicating the voxels to include in the analysis.

TR

The repetition time in seconds of the scan-to-scan interval.

run_length

A vector of one or more integers indicating the number of scans in each run.

event_table

A data.frame containing the event onsets and experimental variables. Default is an empty data.frame.

base_path

The file path to be prepended to relative file names. Default is "." (current directory).

censor

A binary vector indicating which scans to remove. Default is NULL.

preload

Read image scans eagerly rather than on first access. Default is FALSE.

mode

The type of storage mode ('normal', 'bigvec', 'mmap', filebacked'). Default is 'normal'.

Value

An fMRI dataset object of class c("fmri_file_dataset", "volumetric_dataset", "fmri_dataset", "list").

Examples

# Create an fMRI dataset with 3 scans and a mask
dset <- fmri_dataset(c("scan1.nii", "scan2.nii", "scan3.nii"), 
  mask="mask.nii", TR=2, run_length=rep(300, 3), 
  event_table=data.frame(onsets=c(3, 20, 99, 3, 20, 99, 3, 20, 99), 
  run=c(1, 1, 1, 2, 2, 2, 3, 3, 3))
)

# Create an fMRI dataset with 1 scan and a mask
dset <- fmri_dataset("scan1.nii", mask="mask.nii", TR=2, 
  run_length=300, 
  event_table=data.frame(onsets=c(3, 20, 99), run=rep(1, 3))
)