This function creates a matrix dataset object, which is a list containing information about the data matrix, TR, number of runs, event table, sampling frame, and mask.
Usage
matrix_dataset(datamat, TR, run_length, event_table = data.frame())
Arguments
- datamat
A matrix where each column is a voxel time-series.
- TR
Repetition time (TR) of the fMRI acquisition.
- run_length
A numeric vector specifying the length of each run in the dataset.
- event_table
An optional data frame containing event information. Default is an empty data frame.
Examples
# A matrix with 100 rows and 100 columns (voxels)
X <- matrix(rnorm(100*100), 100, 100)
dset <- matrix_dataset(X, TR=2, run_length=100)
# An iterator with 5 chunks
iter <- data_chunks(dset, nchunks=5)
`%do%` <- foreach::`%do%`
y <- foreach::foreach(chunk = iter) %do% { colMeans(chunk$data) }
length(y) == 5
#> [1] TRUE
# An iterator with 100 chunks
iter <- data_chunks(dset, nchunks=100)
y <- foreach::foreach(chunk = iter) %do% { colMeans(chunk$data) }
length(y) == 100
#> [1] TRUE
# A matrix_dataset with 200 rows, 100 columns and 2 runs
X <- matrix(rnorm(200*100), 200, 100)
dset <- matrix_dataset(X, TR=2, run_length=c(100,100))
# Get a "runwise" iterator. For every iteration, an entire run's worth of data is returned.
iter <- data_chunks(dset, runwise=TRUE)
y <- foreach::foreach(chunk = iter) %do% { colMeans(chunk$data) }
length(y) == 2
#> [1] TRUE