global_onsets | R Documentation |
Convert relative onset times to global (cumulative) onset times across runs. Global onsets are defined as cumulative time over runs, meaning they do not reset to zero for each run. This is useful for:
Converting run-specific onsets to experiment-wide timings
Aligning events across multiple runs
Computing temporal distances between events in different runs
global_onsets(x, onsets, ...)
x |
The object containing timing information (typically a sampling_frame) |
onsets |
A numeric vector of relative onset times within each run/block |
... |
Additional arguments passed to methods. Common arguments include:
|
A numeric vector of global onset times where:
Each onset is adjusted by the cumulative duration of previous runs
Times are in the same units as the input onsets (typically seconds)
NA is returned for onsets that exceed their block duration
sampling_frame()
, event_model()
Other timing:
durations()
,
onsets()
,
samples()
# Create a sampling frame with three runs
sframe <- sampling_frame(
blocklens = c(100, 100, 100), # 100 scans per run
TR = 2 # 2 seconds per scan
)
# Define events in each run
run_onsets <- c(10, 20, 30) # Events at 10s, 20s, 30s
run_ids <- c(1, 2, 3) # One event per run
# Convert to global onsets
global_times <- global_onsets(
sframe,
onsets = run_onsets,
blockids = run_ids
)
# Returns: c(10, 220, 430)
# Because:
# - Run 1: 10s
# - Run 2: 20s + (100 scans * 2s) = 220s
# - Run 3: 30s + (200 scans * 2s) = 430s
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.