durations: Get event durations from an object

View source: R/all_generic.R

durationsR Documentation

Get event durations from an object

Description

Extract the duration of events from a model object. Durations represent how long each event lasts in an fMRI design, typically in seconds. These are important for:

  • Modeling block designs where stimuli have non-zero duration

  • Creating accurate HRF convolutions for extended events

  • Distinguishing between brief and sustained neural activity

Usage

durations(x)

## S3 method for class 'regressor'
durations(x)

Arguments

x

The object containing event information (typically an event_term or event_model)

Value

A numeric vector of durations in seconds, where:

  • Each value represents how long an event lasts

  • Zero values indicate instantaneous events

  • Order matches the corresponding event sequence

See Also

onsets(), event_term()

Other timing: global_onsets(), onsets(), samples()

Examples

# Create event data with varying durations
event_data <- data.frame(
  condition = factor(c("block", "event", "block", "event")),
  onsets = c(1, 10, 20, 30),
  durations = c(8, 0, 8, 0),  # 8s blocks and instantaneous events
  run = c(1, 1, 1, 1)
)

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

# Get durations from term
dur <- durations(eterm)  # Returns: c(8, 0, 8, 0)

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