This function returns a design matrix for multi-subject fMRI data to fit a Linear Mixed-effects Model (one-stage procedure) with given stimuli, polynomial drift terms and a set of known population parameters.
fmri.designG(hrf, subj = 1, runs = 1, group = NULL, XG = NULL)
A design matrix as a data frame, which contains the following variables:
consecutive subject number: 1 to subj
specified as factor
consecutive run number within the subjects: 1 to runs
specified as factor
consecutive scan number: 1 to T within each session
consecutive experiment number: 1 to (subj*runs)
specified as factor
grouping variable specified as factor, one group by default
replicated expected BOLD-response(s)
replicated polynomial drift terms
created with fmri.design(hrf, order = 2)
orthogonal to the stimuli
given in hrf
further expanded between-subject factors and covariates
vector or matrix containing expected BOLD response(s)
for one session, typically a fmri.stimulus
object.
number of subjects in the study.
number of repeated measures within subjects.
optional vector to define groups.
It is expected one value per subject. A grouping factor can also be part of XG
.
optionally, a group-level design matrix of class "data.frame"
, which contains population parameters such as ages or gender corresponding to the subjects. It is expected one value per subject.
Sibylle Dames
Based on the dimensionality of the hrf
object, which provides the total number of scans (time-points) within each session, the entered number of subjects and repeated measures the auxiliary variables: "subj", "run", "scan" and "session" are generated as first part of the returned design matrix.
If no group
argument is specified, only one population will be assumed; otherwise group labels are replicated within sessions of the same subject.
First a design matrix for a single run is created by calling: x <- fmri.design(hrf, order = 2)
. Hence the polynomial drift terms are defined orthogonal to the stimuli (see fmri.design
). This matrix is replicated blockwise to all sessions assuming the same experimental design for all runs. The first drift term, a column of ones, is called "drift0" and models an intercept.
If given, further subject characteristics are filled in the design matrix.
Polzehl, J. and Tabelow, K.(2007). fmri: A Package for Analyzing fmri Data, R News, 7:13-17.
fmri.stimulus
, fmri.design
, fmri.lmePar
subj <- 6
runs <- 1
scans <- 121
times <- c(12, 48, 84, 120, 156, 192, 228, 264)
duration <- 24
tr <- 2.5
hrf <- fmri.stimulus(scans, times, duration, tr, times = TRUE)
x.group <- fmri.designG(hrf, subj = subj, runs = runs)
# View(x.group)
Run the code above in your browser using DataLab