split_onsets: Split Event Onsets into Lists by Factor Levels or Blocks

View source: R/all_generic.R

split_onsetsR Documentation

Split Event Onsets into Lists by Factor Levels or Blocks

Description

Split a vector of event onsets into separate lists based on factor levels and/or block IDs. This is useful for:

Usage

split_onsets(x, ...)

Arguments

x

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

...

Additional arguments passed to methods. Common arguments include:

sframe

A sampling_frame object defining the temporal structure

global

Logical; if TRUE, convert to global onset times

blocksplit

Logical; if TRUE, further split by block IDs

Details

separation

Separating events by experimental conditions

organization

Organizing onsets by scanning runs/blocks

preparation

Preparing onset times for AFNI analysis

analysis

Analyzing timing patterns within conditions

Value

A list of numeric vectors where:

Elements

Each element contains onsets for one condition/block

Names

Names correspond to condition labels

Nested Structure

If blocksplit=TRUE, each condition contains a nested list of blocks

See Also

event_term(), sampling_frame(), global_onsets()

Examples

# Create example data with multiple conditions and blocks
event_data <- data.frame(
  condition = factor(c("A", "B", "A", "B", "A", "B")),
  onsets = c(1, 10, 30, 40, 70, 80),
  run = c(1, 1, 2, 2, 3, 3)
)

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

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

# Split onsets by condition
split_by_cond <- split_onsets(eterm, sframe)
# Returns list with onsets for conditions A and B

# Split by condition and block
split_by_block <- split_onsets(eterm, sframe, blocksplit = TRUE)
# Returns nested list: conditions -> blocks -> onsets

# Get global onset times
split_global <- split_onsets(eterm, sframe, global = TRUE)
# Returns onsets adjusted for block timing

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