Episode 4: Unicorn Hybrid Black

Learn how to acquire real EEG data with the Unicorn Hybrid Black amplifier. This episode demonstrates how to configure the device and stream live biosignals into your processing pipeline via Bluetooth.

Note

This page is still under development. Until we have the step-by-step instructions ready, please refer to the code example below.

File example_devices_hybrid_black.pyView file on GitHub

  1"""
  2Unicorn Hybrid Black Device Example - Real-time EEG Acquisition and Processing
  3
  4This example demonstrates how to connect to and process real-time EEG data from
  5a g.tec Unicorn Hybrid Black amplifier system. It showcases EEG
  6signal processing with standard filtering techniques commonly used in clinical
  7and research BCI applications.
  8
  9What this example shows:
 10- Real-time data acquisition from Unicorn Hybrid Black hardware
 11- Bandpass filtering for EEG frequency band selection
 12- Power line interference removal with notch filters
 13- Real-time visualization of EEG signals
 14- Hardware integration with g.Pype framework
 15
 16Hardware requirements:
 17- g.tec Unicorn Hybrid Black EEG amplifier
 18- Windows operating system
 19- Unicorn Suite installed (including Python API)
 20
 21Expected behavior:
 22When you run this example:
 23- Connects to Unicorn Hybrid Black amplifier automatically via Bluetooth
 24- Displays real-time EEG from 8 channels
 25- Shows filtered signals in real-time scope
 26- Amplitude range: ±50 µV (typical EEG range)
 27- Time window: 10 seconds of continuous data
 28
 29Signal processing pipeline:
 301. Raw EEG acquisition (8 channels, 250 Hz)
 312. Bandpass filtering (1-30 Hz) - standard EEG band
 323. 50 Hz notch filter - removes European power line noise
 334. 60 Hz notch filter - removes American power line noise
 345. Real-time visualization
 35
 36Real-world applications:
 37- Mobile EEG monitoring and research
 38- BCI system development and testing
 39- Neurofeedback training applications
 40- Cognitive state monitoring research
 41- Consumer neurotechnology applications
 42- Attention and meditation training
 43
 44Usage:
 45    1. Pair Unicorn Hybrid Black via Bluetooth
 46    2. Power on the device
 47    3. Run: python example_devices_hybrid_black.py
 48    4. Monitor real-time EEG signals
 49
 50Note:
 51    This example provides the foundation for all BCI applications
 52    requiring real-time EEG data acquisition and processing with
 53    the Unicorn Hybrid Black wireless amplifier.
 54"""
 55import gpype as gp
 56
 57# Sampling rate (hardware-dependent, fixed at 250 Hz for Unicorn Hybrid Black)
 58fs = 250
 59
 60if __name__ == "__main__":
 61
 62    # Initialize main application for GUI and device management
 63    app = gp.MainApp()
 64
 65    # Create real-time processing pipeline for EEG data
 66    p = gp.Pipeline()
 67
 68    # === HARDWARE DATA SOURCE ===
 69    # Unicorn Hybrid Black: Wireless 8-channel EEG amplifier
 70    # Automatically detects and connects to available hardware via Bluetooth
 71    # Provides high-quality, low-noise EEG signals at 250 Hz
 72    #
 73    # Optional sensor channels:
 74    #   include_accel: Add 3 accelerometer channels (X, Y, Z)
 75    #   include_gyro:  Add 3 gyroscope channels (X, Y, Z)
 76    #   include_aux:   Add auxiliary channels (battery, counter, validation)
 77    #
 78    source = gp.HybridBlack(
 79        include_accel=True,  # Enable accelerometer (channels 9-11)
 80        include_gyro=True,   # Enable gyroscope (channels 12-14)
 81        include_aux=True,    # Enable battery/counter/validation (channels 15-17)
 82    )
 83
 84    splitter = gp.Router(input_channels=gp.Router.ALL,
 85                         output_channels={"EEG": range(8),
 86                                          "ACC": [8, 9, 10],
 87                                          "GYRO": [11, 12, 13],
 88                                          "AUX": [14, 15, 16]})
 89
 90    # === SIGNAL CONDITIONING STAGE ===
 91    # Bandpass filter: Extract standard EEG frequency range
 92    # 1-30 Hz preserves all major brain rhythms while removing:
 93    # - DC drift and movement artifacts (<1 Hz)
 94    # - EMG muscle artifacts and high-frequency noise (>30 Hz)
 95    bandpass = gp.Bandpass(
 96        f_lo=1, f_hi=30  # High-pass: remove DC and slow drift
 97    )  # Low-pass: remove muscle artifacts
 98
 99    # === POWER LINE INTERFERENCE REMOVAL ===
100    # Notch filter for 50 Hz power line noise (European standard)
101    # 48-52 Hz range accounts for slight frequency variations
102    notch50 = gp.Bandstop(
103        f_lo=48, f_hi=52  # Lower bound of 50 Hz notch
104    )  # Upper bound of 50 Hz notch
105
106    # Notch filter for 60 Hz power line noise (American standard)
107    # 58-62 Hz range accounts for slight frequency variations
108    # Both filters ensure compatibility with different power systems
109    notch60 = gp.Bandstop(
110        f_lo=58, f_hi=62  # Lower bound of 60 Hz notch
111    )  # Upper bound of 60 Hz notch
112
113    combiner = gp.Router(input_channels={"EEG": gp.Router.ALL,
114                                         "ACC": gp.Router.ALL,
115                                         "GYRO": gp.Router.ALL,
116                                         "AUX": gp.Router.ALL},
117                         output_channels=gp.Router.ALL)
118
119    # === REAL-TIME VISUALIZATION ===
120    # Professional EEG scope with clinical amplitude scaling
121    # 50 µV range covers typical EEG signal amplitudes
122    # 10-second window provides good temporal context
123    scope = gp.TimeSeriesScope(
124        amplitude_limit=50, time_window=10  # ±50 µV range
125    )  # 10-second display
126
127    # === PIPELINE CONNECTIONS ===
128    # Create signal processing chain: Hardware → Filtering → Visualization
129    # Order matters: bandpass first, then notch filters, finally display
130
131    p.connect(source, splitter)  # Split raw data into EEG, ACC, GYRO, AUX
132
133    # Connect hardware source to initial bandpass filter
134
135    p.connect(splitter["EEG"], bandpass)
136
137    # Connect bandpass output to first notch filter (50 Hz)
138    p.connect(bandpass, notch50)
139
140    # Connect first notch to second notch filter (60 Hz)
141    p.connect(notch50, notch60)
142
143    # Connect final filtered signal to visualization scope
144    p.connect(notch60, combiner["EEG"])  # Send filtered EEG to combiner
145    p.connect(splitter["ACC"], combiner["ACC"])  # Send ACC to combiner
146    p.connect(splitter["GYRO"], combiner["GYRO"])  # Send GYRO to combiner
147    p.connect(splitter["AUX"], combiner["AUX"])  # Send AUX to combiner
148    p.connect(combiner, scope)  # Display combined signals in scope
149    # === APPLICATION SETUP ===
150    # Add visualization widget to main application window
151    app.add_widget(scope)
152
153    # === EXECUTION ===
154    # Start real-time data acquisition and processing
155    p.start()  # Initialize hardware and begin data flow
156    app.run()  # Start GUI event loop (blocks until window closes)
157    p.stop()  # Clean shutdown: stop hardware and close connections