regressors: Extract regressor set

View source: R/all_generic.R

regressorsR Documentation

Extract regressor set

Description

Extract a set of regressors from a model object. Regressors represent the predicted BOLD response for different experimental conditions or model components. For event-related designs, each regressor is typically a convolution of event onsets with an HRF. For baseline terms, regressors might represent drift or nuisance components.

Usage

regressors(x, ...)

Arguments

x

A model object that contains regressors (or can generate them)

...

Additional arguments passed to methods. Common arguments include:

condition

Character; specific condition to extract regressors for

block

Numeric; specific block/run to extract regressors from

basis

Character; type of basis functions to use

Value

A list of regressor objects, where each regressor contains:

  • values: Numeric vector of regressor values over time

  • onsets: Original event onset times

  • condition: Associated experimental condition

  • block: Associated run/block number

See Also

event_model(), HRF_SPMG1(), convolve()

Examples

# Create event data with two conditions
event_data <- data.frame(
  condition = factor(c("face", "house", "face", "house")),
  onsets = c(1, 10, 20, 30),
  run = c(1, 1, 1, 1)
)

# Create sampling frame
sframe <- sampling_frame(blocklens = 50, TR = 2)

# Create event model with canonical HRF
evmodel <- event_model(
  onsets ~ hrf(condition),
  data = event_data,
  block = ~run,
  sampling_frame = sframe
)

# Extract all regressors
reg_list <- regressors(evmodel)

# Create model with multiple basis functions
evmodel2 <- event_model(
  onsets ~ hrf(condition, basis = "fourier", nbasis = 2),
  data = event_data,
  block = ~run,
  sampling_frame = sframe
)

# Extract regressors with basis functions
reg_list2 <- regressors(evmodel2)

bbuchsbaum/fmrireg documentation built on March 1, 2025, 11:20 a.m.