Data Structures: Arrays, Units and Timestamps

Everything g.Pype hands you, in a scope, a file or a Result, has the same shape, the same precision and the same meaning of time. This page states them once; the pages it links say why.

Shape and precision

What

How it is

A frame, a block, a result

(time, channel): samples down, channels across. MNE-Python uses the transpose, (channel, time); the MNE workflow transposes.

Epochs

(time, channel, trial), one trial per event, from a Trigger in a realtime pipeline or an Epochs node in a batch run.

dtype

float32 (Constants.DATA_TYPE), live and in a Result. The .mat and .h5 writers store float64, so a file is exact and the pipeline’s precision is the ceiling: about one part in ten million, far below EEG noise.

A frame’s length

About 16 ms by default: 4 samples at 250 Hz, 16 at 1000 Hz. A GDS amplifier delivers what its driver chooses; frame_size= on the source changes it. See Real-Time Performance.

Channels

What

How it is

Order

The EEG channels first, in the order of the montage; then what the device adds, where enabled: a Unicorn’s accelerometer, gyroscope and auxiliary channels, a g.Nautilus’s digital input and extras in its driver’s order, a g.USBamp’s trigger input. A device’s own counter and validity flag carry the index and quality roles and are consumed with the arrival stamp, so no node you connect sees them. Each amplifier’s SDK page lists its own.

Label

The electrode name, from the montage you pass or the device’s default; None where nothing named the channel. A .csv or .edf file names every column, so a reader of those returns Ch01, Ch02 and so on where no name was recorded.

Role

signal, trigger, index, quality, auxiliary or timestamp. A filter touches signal channels and leaves the rest alone. See Channel Metadata.

Unit

uV for EEG from every amplifier, g for an accelerometer, deg/s for a gyroscope, None where the source records no unit, which is not the same as dimensionless. Result.to_si() scales to volts and SI.

The arrival stamp

Every live source appends one channel carrying the host instant each block was seen. It is found by its timestamp role and stripped before any node you connect, so you never see it; a source’s declared channel count is the device’s width.

Timestamps

Every stamp g.Pype takes is read from time.perf_counter(), the host’s monotonic clock, at the instant a block was first seen on the host. That is a delivery instant, not an acquisition instant: the device’s own latency is not subtracted. Time and Synchronisation says how samples and events are placed on one timeline; this table says what time means in each place you read it.

Where

What the time means

Result.times

Seconds from the first sample of the result, arange(n) / rate.

Result.start_time

The absolute time of the first sample, where the source recorded one; None otherwise.

Result.events

Markers as sample positions relative to the first sample.

A .csv file

A Time column in seconds from the first sample.

A .mat or .h5 file

A time row in seconds from the first sample, first in the dataset; has_time_row=False reads a file without one.

An .edf file

The rate from the header and markers as EDF+ annotations; the header’s start time is the moment the file was opened, and the reader does not publish it.

An LSL outlet

Each chunk is pushed with the pipeline timeline’s host time at the moment of the push, in seconds of the host’s monotonic clock, consistent with every other stamp in the pipeline: the last sample’s own time when the stream is the master’s and nothing upstream holds frames back. Before the timeline has a relation, LSL stamps at push time.

LslReceiver

Samples are timed by arrival on this host, not by the stream’s own stamps.

A save_as run

The arrival instant of every block, kept so a replay places the same samples at the same positions.

Events

An event, a key, a marker or a datagram, carries the host instant it was first seen and is placed on the sample whose period contains that instant. Placing nodes hold every frame back by a 40 ms margin so that a late event still finds its sample, 0 ms when OSCAR runs; the measured placements are in Benchmarks.

Buffering

A source emits a frame once it is full; nothing is buffered beyond that except where a node says so: a MovingAverage holds its window, a Trigger its pre-stimulus span, a placing node its margin. A Collector in a realtime pipeline keeps every frame it receives and grows for as long as the run lasts. A pipeline that cannot keep up does not buffer without bound: the backlog is reported, and the run is stopped, as Season 6, Episode 3 shows.