(formerly TelePyth, and before that the Python/EEG half of TelePath)
This repository contains the EEG signal-processing and classification pipeline for a Steady-State Visual Evoked Potential (SSVEP) Brain-Computer Interface, developed as part of a Master's thesis in Neural Engineering at Saarland University of Applied Sciences.
It is a direct continuation of TelePath, an SSVEP-controlled VR maze game built for the same programme. TelePath asked whether a VR headset was a viable delivery platform for an SSVEP BCI. This project asks the next question: can the EEG itself be recorded from inside the ear instead of from scalp electrodes? The VR headset was dropped, the Unity game was moved to a standard TV/monitor setup, and the focus shifted to designing and evaluating a custom in-ear electrode mold against a conventional occipital montage.
The full write-up is included in this repository: Master_Thesis_Hristo_Marinov.pdf — "Design and Evaluation of an In-Ear Electrode Mold for Brain-Computer Interfaces."
This thesis presents the design and evaluation of a custom in-ear electrode mold for steady-state visual evoked potential (SSVEP) based brain-computer interfaces through single-subject investigation. Despite achieving electrode impedances within the clinically acceptable range (2–13 kΩ, verified prior to recording) and comprehensive signal processing, in-ear EEG failed to detect visual evoked potentials across three distinct paradigms due to fundamental anatomical constraints. The approximately 10 cm distance from visual cortex to ear canal results in severe signal attenuation that places responses below detection thresholds.
Simultaneous occipital recordings validated the experimental design and revealed that paradigm structure strongly influences SSVEP amplitude: an interactive game paradigm produced 2–5× stronger responses than passive television-viewing paradigms. Hyperparameter optimization via Bayesian search with Leave-One-Trial-Out (LOTO) cross-validation identified optimal processing configurations, achieving 80% end-to-end classification accuracy with occipital recordings, while in-ear recordings remained at chance level across all conditions.
The custom thermoplastic polyurethane (TPU) earpiece balanced comfort during extended sessions, electrode positioning stability, and manufacturing reproducibility. However, signal quality limitations demonstrate that in-ear EEG is unsuitable for visual BCI paradigms. These findings clarify the technical boundaries of in-ear-EEG spatial sensitivity while providing practical design principles for SSVEP-based BCIs: active, goal-directed tasks with direct gaze fixation maximize response amplitude and system performance.
| TelePath | InEarBCI | |
|---|---|---|
| Delivery platform | Meta Quest 2 VR headset | Desktop / 55" TV, no headset |
| EEG montage | Scalp (Oz), single channel | Occipital (Oz, O1, O2, POz) and custom in-ear mold, simultaneous |
| Real-time processing | MATLAB/Simulink | Custom Python pipeline (this repo) |
| Classifier | KNN | Random Forest (binary + multiclass), Bayesian-optimized |
| Paradigms | Maze navigation only | Maze game + logo-based TV selection + frame-based TV selection |
| Question being asked | Is VR usable for SSVEP control? | Is an in-ear electrode viable for SSVEP detection? |
The Unity front end (menus, maze game, UDP command interface) is largely unchanged from TelePath — see the screenshots below — with two new virtual-television paradigms added for testing generalization beyond spatial navigation.
Options Menu (stimulus frequencies, trial timing, UDP config):

Fourteen design iterations — from modified sports-earbud shells to a two-piece mechanical electrode holder — led to a final mold-based solution: an anatomical cast of the participant's ear, digitized and refined in CAD, then 3D-printed in thermoplastic polyurethane (TPU, Shore 95A) with electrode cups coated in nail polish for adhesion. Four electrodes were positioned per the Kidmose et al. in-ear configuration (ERA, ERB, ERE, ERH).
Materials tested and rejected along the way: rigid PLA (pressure points, poor tolerances), soft silicone (excellent comfort, unstable electrode positioning), and SLA resin (brittle, biocompatibility concerns). TPU was the only material that held stable impedance through 2-hour sessions while remaining comfortable.
Three SSVEP paradigms, all using the same four stimulation frequencies (7.5, 10, 12, 15 Hz) mapped to up/down/left/right, were run with simultaneous occipital and in-ear recording:
1. Game paradigm — active maze navigation, 12 s stimulation blocks. Strongest and most reliable responses of the three.

2. Frame-based TV paradigm — flickering checkerboard border around four virtual TV screens, 30 s stimulation blocks. Weakest responses.

3. Logo-based TV paradigm — flickering checkerboard logo embedded in each screen. Intermediate response strength.

- Acquisition: g.tec Unicorn BCI Core 4 (4-channel, 1000 Hz), streamed via Lab Streaming Layer (
eeg_device.py) - Preprocessing: stationary wavelet denoising, 50 Hz notch (Q=35), FIR bandpass (
signal_processing.py) - Feature extraction (
feature_extraction.py): sliding-window Canonical Correlation Analysis (CCA) and Phase-Locking Value (PLV), with window/step sizes tuned via Bayesian optimization - Classification (
classifier.py): Random Forest, separate binary (rest vs. stimulation) and multiclass (frequency discrimination) models, SMOTE class balancing - Hyperparameter search & validation (
bayes_opt_online_data_test.py,loso_online_data_test.py): Bayesian optimization with Leave-One-Trial-Out cross-validation - Orchestration (
main_system.py,config.py,data_manager.py,utils.py,plot.py): offline/online mode switching, UDP communication with the Unity front end, logging and visualization
Mean CCA during the game paradigm reached 0.76 ± 0.11 during stimulation vs. 0.14 ± 0.03 at rest (5.4× increase, p < 0.001). In-ear recordings, measured simultaneously from the same trials, never rose above baseline:
Occipital montage:
| Paradigm | Binary (rest vs. stim) | Multiclass (frequency) | Combined end-to-end |
|---|---|---|---|
| Game | 81.18% | 97.33% | 80.0% |
| Logo-based TV | 85.43% | 49.34% | 42.3% |
| Frame-based TV | 85.99% | 12.42% | 10.92% |
In-ear montage:
| Paradigm | Binary | Multiclass | Combined |
|---|---|---|---|
| Game | 57.65% | 50.00% | 51.76% |
| Logo-based TV | 71.71% | 30.71% | 24.93% |
| Frame-based TV | 84.87% | 18.81% | 15.97% |
(Chance levels: binary 50%, multiclass 25%, combined 20%.) In-ear multiclass and combined accuracies sit at or below chance in every paradigm — more training data did not help, confirming the failure is a signal-detection problem, not a classifier or data-volume problem.
- In-ear EEG cannot detect SSVEPs from visual cortex. The ~10 cm distance from V1 to the ear canal, combined with reduced spatial diversity (4 closely-spaced electrodes vs. 4 electrodes spanning 10 cm on the scalp) and elevated EMG/50 Hz noise susceptibility, produces an estimated 30–40 dB attenuation — well below detection threshold, regardless of signal-processing sophistication.
- Task engagement matters more than raw stimulus size. The interactive game paradigm outperformed both TV paradigms despite identical stimulus contrast and frequencies; the frame-based paradigm, with 7.5× more flickering screen area than the logo paradigm, produced the weakest responses because it sat in the visual periphery, outside the focus of attention.
- 80% end-to-end accuracy is achievable with occipital electrodes under realistic, single-session, untrained-user conditions (12–30 s stimulus blocks) — a practical benchmark rather than an idealized best case.
- Ear-EEG remains promising for non-visual paradigms (auditory ASSR, motor imagery, cognitive-state monitoring), where the signal source sits much closer to the ear canal.
See Chapters 5–6 of the thesis for the full discussion, limitations, and proposed future directions (hybrid ear–mastoid montages, active electrodes, deep-learning-based detection).
main_system.py— system entry point, offline/online mode orchestration, UDP link to the Unity front endconfig.py— all tunable parameters (frequencies, filter settings, optimized feature windows, classifier hyperparameters)eeg_device.py— LSL-based acquisition from the g.tec Unicorn BCI Core 4signal_processing.py— wavelet denoising, notch/bandpass filteringfeature_extraction.py— CCA and PLV sliding-window feature extractionclassifier.py— Random Forest binary/multiclass classification with SMOTEbayes_opt_online_data_test.py,loso_online_data_test.py— Bayesian hyperparameter search and LOTO cross-validationdata_manager.py,utils.py,plot.py— data I/O, UDP/logging utilities, visualizationfigures/— figures used in this README (Unity UI reused from TelePath; results and hardware figures from the thesis)Master_Thesis_Hristo_Marinov.pdf— full thesisrequirements.txt— Python dependencies
The Unity project itself (game, menus, maze generation, UDP command handling) lives in TelePath; this repository covers the EEG acquisition, processing, and classification side that was rebuilt and extended for the in-ear BCI study.
- Single-subject study (the primary investigator); in-ear results require replication across a larger cohort before generalizing
- TV paradigm videos were presented without audio to avoid auditory-evoked-potential contamination, reducing ecological validity for the multimedia-selection use case
- No eye-tracking was collected to directly quantify fixation differences between paradigms
- In-ear electrode configuration followed a layout validated for auditory potentials (Kidmose et al.), not optimized specifically for visual-cortex sensitivity
- Hybrid ear–mastoid montages and higher-density peri-auricular arrays to improve spatial sampling of visual potentials
- Deep learning / transfer learning approaches (EEGNet, transformers) evaluated against rigorous surrogate-data null-hypothesis testing
- Active (pre-amplified) in-ear electrodes to improve input impedance and reduce movement artifacts
- Multi-subject validation and exploration of non-visual (auditory, motor imagery) ear-EEG paradigms, where the technology remains promising
pip install -r requirements.txtRequires a g.tec Unicorn BCI Core (or another LSL-compatible EEG stream) for live acquisition; offline processing can run directly on the provided calibration CSVs. See config.py for all system-mode and parameter switches.
© 2025–2026 Hristo Marinov This work is licensed under the CC BY-NC-ND 4.0 License. Commercial use or derivative works require prior written consent.




