Channel Metadata
A stream carries more than numbers. Beside its sampling rate, channel count and frame size, every channel has a label that says what it is, a role that says how it must be treated, and a unit. Nodes read them, update them when they change the stream, and pass them on – which is how a filter knows which channels to leave alone, and a recording knows what its columns are.
Roles: how a channel must be treated
There are six, all in gp.Constants.ChannelRoles:
signal– a measured signal, what filters and spatial processing work ontrigger– an event or marker channel, never filteredauxiliary– another sensor, such as an accelerometer or the batteryquality– data validity, saturation or link qualityindex– a position on the master timelinetimestamp– the arrival stamp every live source adds
A channel with no role declared counts as a signal, so a Generator on
its own delivers signal channels only.
The role decides what nodes do with a channel. A filter processes signal
channels and passes every other one through untouched, because filtering a
trigger would smear the edges of its codes into ripples. The event sources –
Keyboard, Marker, UDPReceiver – declare their
channels triggers for that reason. A timestamp channel never reaches a node:
the pipeline strips it first (Time and Synchronisation).
Labels: what a channel is
Few sources can name their channels. The eight-channel BCI Core headset is
labelled Fz C3 Cz C4 Pz PO7 POz PO8; a generator or a g.Nautilus delivers no
labels at all. Name them once, near the source, and every node and recording
after it uses the names:
labeler = gp.ChannelLabeler(labels=["Fz", "Cz", "Pz", "Oz"])
p.connect(amplifier, labeler)
A Router keeps each channel’s label, role and unit when it selects or
merges. Selecting channels 1 and 3, counting from 0, of Fz Cz Pz TRG gives
Cz and TRG,
still a signal and a trigger. Merging a named stream with an unnamed one names
the unnamed channels after their position: C3 C4 beside two unnamed channels
becomes C3 C4 Ch03 Ch04. Labels end up in a CSV header, an LSL stream
description, the metadata of the other recording formats, and Result.labels.
An LSL stream carries each channel’s role as its type, labelled or not: two
unnamed signal channels and a Marker’s channel arrive at an
LslReceiver as signal signal trigger.
Units: what the numbers mean
Amplifiers declare their channels in µV, and a ChannelLabeler can set
units with units=. A Result hands them back as units and turns
them into si_scale – 1e-06 for µV – which to_si() multiplies by. A
missing unit stays missing: to_si() on a result with none refuses, because
“a missing unit is not taken to be microvolts”.
Montage
Montage names the signal channels of an acquisition device, which is
needed because amplifiers do not report where their electrodes sit:
m = gp.Montage(["Fz", "Cz", "Pz", "Oz"]). It covers the signal channels
only; the auxiliary channels a device streams beside them are labelled by the
source. Positions come from a built-in table of standard electrode names:
m.position_of("Fz") is (0.0, 0.5), on a flat head outline with Cz at
the centre and the nose towards positive y, and a name outside the table
simply has no position (None). Pass it to a BCICore as
montage=, and for any other amplifier to a ChannelLabeler.
Where it gets lost
Metadata survives only where something carries it:
CSV stores no roles. Read back, a trigger channel is a signal again, and a filter would smear it. The other recording formats keep them. After a CSV, a
ChannelLabelergives them back:roles=takes one per channel.A node of your own that changes the channel count must update the descriptions too. Left out of step, a
Resultreports no labels and no roles at all (Episode 1: Your First Node).