baseline_terms: Extract baseline terms from a model

View source: R/all_generic.R

baseline_termsR Documentation

Extract baseline terms from a model

Description

Extract the baseline and nuisance terms from a model object, separating them from experimental event terms. Baseline terms represent non-experimental components of the fMRI signal, such as:

  • Drift terms (modeling scanner drift)

  • Block terms (modeling run-specific baselines)

  • Nuisance terms (e.g., motion parameters, physiological noise)

Usage

baseline_terms(x)

Arguments

x

The model object (typically an fmri_model)

Value

A list of baseline_term objects. Each baseline_term represents a different component of the non-experimental signal and contains:

  • varname: Name of the term (e.g., "drift", "block", "motion")

  • design_matrix: Matrix of baseline regressors

  • term_type: Type of baseline term ("drift", "block", or "nuisance")

See Also

event_terms(), fmri_model(), baseline_model()

Other model_components: event_terms(), term_indices()

Examples

# Create a model with both event and baseline terms
event_data <- data.frame(
  stimulus = 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
evmodel <- event_model(
  onsets ~ hrf(stimulus),
  data = event_data,
  block = ~run,
  sampling_frame = sframe
)

# Create baseline model with drift and block terms
bmodel <- baseline_model(
  basis = "bs",    # B-spline basis for drift
  degree = 3,      # Cubic drift model
  sframe = sframe
)

# Combine into full model
fmodel <- fmri_model(evmodel, bmodel)

# Extract only the baseline terms
baseline_terms(fmodel)  # Returns list with drift and block terms

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