Episode 1: BCI Core-4/8
Stream a BCI Core-4 or Core-8, g.tec’s Bluetooth Low Energy EEG amplifiers, into a filtered scope, and learn to tell real EEG from an electrode that is not touching skin.
The first real device. The pipeline is the one Season 2 taught; what is new is what the amplifier decides for you, and what its signal looks like when something is wrong.
Install the
devicesextra:pip install "gpype[devices]". It bringsgtec-ble, the amplifier’s driver, on Windows, macOS and Linux.Switch the amplifier on. There is nothing to pair: the node finds it by scanning. The USB cable only charges it.
On macOS, the application that runs Python (Terminal, VS Code, …) needs Bluetooth permission, under System Settings > Privacy & Security > Bluetooth. Without it, a scan finds nothing and says nothing about why, which reads exactly like an amplifier that is switched off.
gp.BCICore() takes the first amplifier it finds and adopts the sampling rate that amplifier reports. Pass serial= to pick one when several are in range. The channel count is not discovered: it defaults to 8, so a Core-4 needs channel_count=4 or a four-name Montage. Only the eight-channel headset gets electrode names by default: Fz C3 Cz C4 Pz PO7 POz PO8.
5# A Core-8's electrode names are known to g.Pype. A Core-4 needs its own
6# montage, or channel_count=4: the channel count is not discovered
7MONTAGE = None
8# MONTAGE = gp.Montage(["Fz", "Cz", "Pz", "Oz"]) # a Core-4
15 # The first amplifier found, at the rate it reports; serial= picks
16 # one when several are in range
17 source = gp.BCICore(montage=MONTAGE)
A Bandpass from 1 to 30 Hz keeps the brain rhythms and drops the drift below and the muscle activity above; two Bandstop notches cover either mains standard. A TimeSeriesScope at plus or minus 50 µV covers scalp EEG.
19 # 1-30 Hz keeps the brain rhythms and drops the drift below and the
20 # muscle activity above; two notches cover either mains standard
21 bandpass = gp.Bandpass(f_lo=1, f_hi=30)
22 notch50 = gp.Bandstop(f_lo=48, f_hi=52)
23 notch60 = gp.Bandstop(f_lo=58, f_hi=62)
24
25 scope = gp.TimeSeriesScope(amplitude_limit=50, time_window=10)
26
27 p.connect(source, bandpass)
28 p.connect(bandpass, notch50)
29 p.connect(notch50, notch60)
30 p.connect(notch60, scope)
31 app.add_widget(scope)
32
33 p.start()
34 app.run()
35 p.stop()
36 p.close()
Run the script. Connecting takes a few seconds: an idle amplifier advertises in bursts, so a single scan can fall between them, and the node scans several times before it reports an amplifier as absent. Then two checks, both worth doing once:
Without electrodes on skin, every channel sits at the edge of the input range. The bandpass removes that constant offset, so the scope shows an almost flat trace: flat on every channel means no contact, not a quiet brain.
With the headset on, close your eyes. Alpha power (8 to 13 Hz) over the back of the head rises within seconds. A ratio near one between eyes closed and open usually means poor contact.
Figure 30: A BCI Core-8 on a head, 1 to 30 Hz with both notches.
The driver repairs short radio dropouts by itself, filling up to a second. A silence longer than 2 s is logged as a warning, and the amplifier reconnects on its own; the samples after the reconnect keep their true time, with the gap left where it happened rather than closed up. A dropout over 100 ms is logged as a warning, and five within a minute are reported as a degrading link. A silence that reaches 60 s is an error, and the run stops: an amplifier gone that long is not coming back on its own.
In this episode, you learned how to:
stream a BCI Core with BCICore and let it set the rate
give a Core-4 its channel count or montage
recognise no contact, and know how a dropout is reported
Proceed to Episode 2, where a Unicorn Hybrid Black brings EEG and motion in one stream.
Nodes in this episode: BCICore, Bandpass, Bandstop, TimeSeriesScope
File s3e1_bci_core.py – View file on GitHub
1"""Season 3, Episode 1: a BCI Core streamed into a filtered scope."""
2
3import gpype as gp
4
5# A Core-8's electrode names are known to g.Pype. A Core-4 needs its own
6# montage, or channel_count=4: the channel count is not discovered
7MONTAGE = None
8# MONTAGE = gp.Montage(["Fz", "Cz", "Pz", "Oz"]) # a Core-4
9
10if __name__ == "__main__":
11
12 app = gp.MainApp()
13 p = gp.Pipeline()
14
15 # The first amplifier found, at the rate it reports; serial= picks
16 # one when several are in range
17 source = gp.BCICore(montage=MONTAGE)
18
19 # 1-30 Hz keeps the brain rhythms and drops the drift below and the
20 # muscle activity above; two notches cover either mains standard
21 bandpass = gp.Bandpass(f_lo=1, f_hi=30)
22 notch50 = gp.Bandstop(f_lo=48, f_hi=52)
23 notch60 = gp.Bandstop(f_lo=58, f_hi=62)
24
25 scope = gp.TimeSeriesScope(amplitude_limit=50, time_window=10)
26
27 p.connect(source, bandpass)
28 p.connect(bandpass, notch50)
29 p.connect(notch50, notch60)
30 p.connect(notch60, scope)
31 app.add_widget(scope)
32
33 p.start()
34 app.run()
35 p.stop()
36 p.close()