make_design: Make design matrix

View source: R/make_design.R

make_designR Documentation

Make design matrix

Description

Make the design matrix for the GLM, from the task information.

Usage

make_design(
  EVs,
  nTime,
  TR,
  dHRF = 0,
  upsample = 100,
  onset = NULL,
  offset = NULL,
  scale_design = TRUE,
  onsets_sep = FALSE,
  offsets_sep = FALSE,
  verbose = TRUE,
  ...
)

Arguments

EVs

The explanatory variables i.e. the task stimulus information, from which a design matrix will be constructed. This is a list where each entry represents a task as a matrix of onsets (first column) and durations (second column) for each stimuli (each row) of the task, in seconds. List names should be the task names. nTime and TR are required.

An example of a properly-formatted EVs is: on_s1 <- list(taskA=cbind(on=c(1,9,17), dr=rep(1,3)), taskB=cbind(on=c(3,27), dr=rep(5,2))). In this example, there are two tasks: the first has three 1s-long stimuli, while the second has two 5s-long stimuli.

nTime

the number of timepoints (volumes) in the task fMRI data.

TR

the temporal resolution of the data, in seconds.

dHRF

Controls the extent of HRF derivatives modeling.

Set to 0 to only model the main HRF regressor (default), and not include its derivatives; set to 1 to model the temporal derivative too; or, set to 2 to model both the temporal and dispersion derivatives. If dHRF==0, there is one design column (field) per task. If dHRF==1, there are two fields per task. And if dHRF==2, there are three fields per task.

If there are several tasks and dHRF>0, the total number of design matrix columns may exceed five, which may require large computation times with INLA. The analysis can be adjusted by modeling the derivatives as nuisance signals rather than as fields. To do so, move the corresponding columns from the design matrix to the nuisance argument for BayesGLM.

upsample

Upsample factor for convolving stimulus boxcar or stick function with canonical HRF. Default: 100.

onset, offset

Add task regressors indicating the onset and/or offset of each event block? Provide the names of the tasks as a character vector. All onsets (or offsets) across the specified tasks will be represented by one additional column in the design matrix. The task names must match the names of EVs. Can also be "all" to use all tasks.

Onsets/offset modeling is only compatible with a block design experiment. An error will be raised if the events in EVs do not have duration greater than one second.

scale_design

Scale the columns of the design matrix? Default: TRUE.

onsets_sep, offsets_sep

Model the onsets (onsets_sep) or offsets (offsets_sep) separately for each task? Default: FALSE, to model all onsets together, or all offsets together, as a single field in the design.

verbose

Print diagnostic messages? Default: TRUE.

...

Additional arguments to HRF_calc.

Value

A "BfMRI_design" object: a list with elements

design

The volumes by fields design matrix. Column names are field names.

field_names

The name of each task from the provided onsets.

dHRF

The input dHRF parameter.

HRF_info

Additional HRF modeling results.

Examples

EVs <- list(taskA=cbind(on=c(1,9,17), dr=rep(1,3)), taskB=cbind(on=c(3,27), dr=rep(5,2)))
TR <- .72
nTime <- ceiling(65/TR)
make_design(EVs, nTime, TR)


hrf documentation built on April 3, 2025, 10:36 p.m.