matrix_dataset | R Documentation |
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.
matrix_dataset(datamat, TR, run_length, event_table = data.frame())
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. |
A matrix dataset object of class c("matrix_dataset", "fmri_dataset", "list").
# 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
# An iterator with 100 chunks
iter <- data_chunks(dset, nchunks=100)
y <- foreach::foreach(chunk = iter) %do% { colMeans(chunk$data) }
length(y) == 100
# 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.