Baseline

class gpype.backend.transform.baseline.Baseline[source]

Bases: IONode

Removes an epoch’s baseline level.

An evoked response is a deflection away from what the signal was doing beforehand, so the pre-stimulus level has to be subtracted for the number to mean anything. This is part of the definition of an ERP rather than an optional tidy-up.

The interval defaults to the whole pre-stimulus span, which the Trigger upstream already publishes, so in the usual case there is nothing to configure.

A high-pass filter is not a substitute: it is causal, it distorts the slow components that carry much of the response, and it removes a standing offset over its own time constant rather than exactly.

In SUBTRACT mode a channel keeps its input’s unit, since the corrected value is still that unit. In PERCENT mode the corrected value is a ratio, so every channel this node rescales declares ‘%’ – known even where the input’s own unit is not.

class Configuration[source]

Bases: Configuration

Configuration class for Baseline parameters.

class Keys[source]

Bases: Keys

Configuration keys for Baseline settings.

MODE = 'mode'

How the baseline is removed

class OptionalKeys[source]

Bases: OptionalKeys

Optional configuration keys.

START = 'start'

Interval start, in seconds relative to the trigger

STOP = 'stop'

Interval end, in seconds relative to the trigger

SUBTRACT = 'subtract'

Subtract the baseline level.

PERCENT = 'percent'

Express the epoch as a percentage change from the baseline.

__init__(start=None, stop=None, mode='subtract', **kwargs)[source]

Initialize the baseline node.

Parameters:
  • start (Optional[float]) – Interval start in seconds relative to the trigger, negative before it. Defaults to the start of the epoch.

  • stop (Optional[float]) – Interval end in seconds relative to the trigger. Defaults to the trigger itself, i.e. the whole pre-stimulus span.

  • mode (str) – SUBTRACT or PERCENT.

  • **kwargs – Additional arguments for the parent IONode.

Raises:

ValueError – If the mode is unknown or the interval is empty.

setup(data, port_context_in)[source]

Resolve the baseline interval against the epoch layout.

Parameters:
Return type:

dict[str, dict]

Returns:

Output port contexts.

Raises:

ValueError – If the epoch layout is unknown, or the interval falls outside the epoch.

step(data)[source]

Remove the baseline from one epoch.

Parameters:

data (dict[str, ndarray]) – Input epoch.

Return type:

dict[str, ndarray]

Returns:

The corrected epoch.