Trigger
- class gpype.backend.flow.trigger.Trigger[source]
Bases:
IONodeEvent-triggered data extraction node for BCI applications.
Monitors trigger events and extracts time-locked data segments around trigger occurrences. Maintains a rolling buffer of input data and outputs complete data epochs when target trigger values are detected. Commonly used in event-related potential (ERP) analysis.
- DEFAULT_TIME_PRE = 0.7
Default pre-trigger window in seconds
- DEFAULT_TIME_POST = 0.2
Default post-trigger window in seconds
- PORT_TRIGGER = 'trigger'
Port name for trigger input
- __init__(time_pre=None, time_post=None, target=None, **kwargs)[source]
Initialize the Trigger node with timing and target configurations.
- Parameters:
time_pre (
float) – Time in seconds before trigger to include in epoch. Must be > 0. Defaults to 0.7 seconds.time_post (
float) – Time in seconds after trigger to include in epoch. Must be > 0. Defaults to 0.2 seconds.target (
float) – Trigger value(s) that cause epoch extraction. Can be single value or list. Defaults to [1].**kwargs – Additional configuration parameters passed to IONode.
- Raises:
ValueError – If time_pre or time_post is <= 0.
- setup(data, port_context_in)[source]
Set up the Trigger node and initialize internal buffers.
Validates input requirements, calculates buffer sizes based on sampling rate and timing parameters, and initializes the rolling input buffer for data collection.
- Parameters:
- Return type:
- Returns:
Output port context with updated frame size and timing information for the extracted epochs.
- Raises:
ValueError – If input frame size is not 1 or sampling rate is not provided.
- step(data)[source]
Process one frame of data and check for trigger events.
Updates the rolling input buffer with new data, monitors trigger changes, and extracts complete epochs when countdown timers expire. Multiple triggers can be active simultaneously.
- Parameters:
data (
dict[str,ndarray]) – Dictionary containing input data arrays. Must include both the main data port and trigger port data.- Return type:
- Returns:
Dictionary containing extracted epoch data when a trigger countdown completes, None otherwise. Epoch has shape (samples_pre + samples_post, channel_count).