event_matrix: Create a continuous event set from a matrix.

View source: R/event-classes.R

event_matrixR Documentation

Create a continuous event set from a matrix.

Description

This is a user-facing wrapper around the internal event() constructor, specifically for creating continuous event sequences from numeric matrices.

Usage

event_matrix(mat, name, onsets, blockids = 1, durations = 0, subset = NULL)

Arguments

mat

A numeric matrix of continuous event values (one row per event).

name

Name of the event variable.

onsets

Numeric vector of event onsets (seconds).

blockids

Numeric vector of block IDs.

durations

Numeric vector of event durations (seconds), or a scalar.

subset

Optional logical vector indicating which events to keep. If provided, the vector must match onsets in length and contain no NA values.

If mat has column names and more than one column, those names are sanitized using .sanitizeName() before being stored. The sanitized column names are returned by levels() for the resulting event object.

Value

An S3 object of class event and event_seq.

Examples

mat <- matrix(rnorm(20), 10, 2, dimnames=list(NULL, c("Val1", "Val2")))
onsets <- seq(1, 100, length.out = 10)
durations <- rep(1, 10)
blockids <- rep(1, 10)
eset <- event_matrix(mat, "eset", onsets, blockids, durations)
print(eset)
columns(eset) # Alias for levels


bbuchsbaum/fmrireg documentation built on June 10, 2025, 8:18 p.m.