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.

1 | ```
fmri.designG(hrf, subj = 1, runs = 1, group = NULL, XG = NULL)
``` |

`hrf` |
vector or matrix containing expected BOLD response(s)
for one session, typically a |

`subj` |
number of subjects in the study. |

`runs` |
number of repeated measures within subjects. |

`group` |
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 |

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.

A design matrix as a data frame, which contains the following variables:

`subj` |
consecutive subject number: 1 to |

`run` |
consecutive run number within the subjects: 1 to |

`scan` |
consecutive scan number: 1 to T within each session |

`session` |
consecutive experiment number: 1 to |

`group` |
grouping variable specified as factor, one group by default |

`hrf, hrf2, ...` |
replicated expected BOLD-response(s) |

`drift0, drift1, drift2` |
replicated polynomial drift terms
created with |

`...` |
further expanded between-subject factors and covariates |

Sibylle Dames

Polzehl, J. and Tabelow, K.(2007). *fmri: A Package for Analyzing fmri Data*, R News, 7:13-17.

`fmri.stimulus`

, `fmri.design`

, `fmri.lmePar`

1 2 3 4 5 6 7 8 9 10 | ```
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)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.