Reference

class gpype.backend.transform.reference.Reference[source]

Bases: IONode

Re-references the signal channels against a chosen reference.

An EEG channel is a voltage difference, and the electrode it is measured against is part of what the number means. Re-referencing chooses that electrode after the fact.

Three forms, in the order they are usually reached for:

  • a common average, the mean over the referenced channels;

  • a single or linked electrode, e.g. one mastoid or the mean of both;

  • explicit bipolar pairs, each output being one difference.

Only measured-signal channels are referenced. Everything else is carried through untouched, so a trigger or an in-band index is not quietly turned into a difference against an average.

AT_MOST_ONE_OF = (('reference', 'pairs'),)

At most one of these – “Give either ‘reference’ or ‘pairs’, not both”. Both may be absent.

class Configuration[source]

Bases: Configuration

Configuration class for Reference parameters.

class Keys[source]

Bases: Keys

Configuration keys for Reference settings.

class OptionalKeys[source]

Bases: OptionalKeys

Optional configuration keys.

REFERENCE = 'reference'

Channels forming the reference, by label or index

PAIRS = 'pairs'

Explicit (active, reference) pairs for bipolar montages

__init__(reference=None, pairs=None, **kwargs)[source]

Initialize the reference node.

Parameters:
  • reference (Union[str, int, list, None]) – Channels to reference against, each a label or an index. None means the common average over every signal channel. A single entry is a single electrode; two are a linked pair.

  • pairs (Optional[list]) – Explicit [active, reference] pairs, each entry a label or an index. One output channel per pair.

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

Raises:

ValueError – If both reference and pairs are given, if either is given but empty, or if an entry is neither a label nor an index.

setup(data, port_context_in)[source]

Resolve the reference and describe the output channels.

Parameters:
Return type:

dict[str, dict]

Returns:

Output port contexts.

step(data)[source]

Subtract the reference from the signal channels.

Parameters:

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

Return type:

dict[str, ndarray]

Returns:

The re-referenced frame.