event_table: Extract event table from a term or model

View source: R/all_generic.R

event_tableR Documentation

Extract event table from a term or model

Description

Extract the event table from a term or model as a data frame. The event table contains the experimental design information, with one row per event and columns for different variables (e.g., conditions, onsets, durations). For event terms, this returns the raw event data. For convolved terms, this includes any basis function expansions.

Usage

event_table(x)

## S3 method for class 'convolved_term'
event_table(x)

Arguments

x

The object to extract events from (typically an event_term, convolved_term, or event_model)

Value

A tibble containing the event information with columns for:

  • Factor variables (e.g., condition, stimulus type)

  • Continuous variables (e.g., reaction times, intensities)

  • Basis function expansions (if applicable)

See Also

event_term(), event_model()

Examples

# Create an event term with multiple variables
event_data <- data.frame(
  condition = factor(c("face", "house", "face", "house")),
  rt = c(0.8, 1.2, 0.9, 1.1),
  onsets = c(1, 10, 20, 30),
  run = c(1, 1, 1, 1)
)

# Create event term
eterm <- event_term(
  list(
    condition = event_data$condition,
    rt = event_data$rt
  ),
  onsets = event_data$onsets,
  blockids = event_data$run
)

# Extract event table
etable <- event_table(eterm)

# Create and extract from convolved term
sframe <- sampling_frame(blocklens = 50, TR = 2)
evmodel <- event_model(
  onsets ~ hrf(condition) + hrf(rt),
  data = event_data,
  block = ~run,
  sampling_frame = sframe
)

# Get event table with basis expansions
model_events <- event_table(evmodel)

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