EEGBiFormer: Real-Time EEG Attention Classification via Hybrid CNN-Transformer with EEG-Informed Auditory Protocol Validation
Organizations: Lake Washington High School, Kirkland, WA, USA
Abstract
Sustained attention is critical for academic performance, yet existing auditory support tools are static and not grounded in real-time neural evidence. This paper presents EEGBiFormer, a hybrid CNN-Transformer model for realtime binary classification of attention states, focus versus nonfocus, from 16-channel EEG signals. A custom analog front-end acquisition board was designed and built to collect a task-based EEG dataset. Before model training, spectral and connectivity analysis, using Power Spectral Density and Phase Locking Value, confirmed distinct neural signatures between attention states, providing physiological grounding for the classification approach. EEGBiFormer achieved 91.3 percent window-level validation accuracy with an F1 score of 94.5 percent, and 88.2 percent recording-level accuracy across 17 independent sessions. End-to-end system latency was measured below 100 ms, supporting real-time responsiveness. The trained model was further used to objectively rank auditory stimuli by focus-state confidence, yielding EEG-informed audio protocols. In a paired within-subject behavioral study with 37 participants, these protocols produced a statistically significant 20 percent improvement in composite attention scores over silent controls, with a medium-to-large effect size. This work demonstrates a complete pipeline from custom EEG hardware through neural signal analysis, deep learning classification, and evidence-based auditory protocol design.
Figures & tables
| Component | Specification |
|---|---|
| Analog Front-End | 2 LH001-99 AFE chips, daisy-chain (16 ch) |
| Sampling Rate | 202 Hz per channel |
| System Noise | RMS |
| Electrode Type | Comb electrodes |
| Wireless | Bluetooth Low Energy (BLE), ESP32-S3 |
| Battery | 3.7 V Li-polymer, h continuous |
| Split | Focus | Non-focus | Total |
|---|---|---|---|
| Training | 27 | 11 | 38 |
| Validation | 8 | 3 | 11 |
| Component | Parameter | Value | Rationale |
|---|---|---|---|
| CNN | Layers | 3 | Hierarchical feature extraction |
| CNN | Kernel size | 9 | Matches Beta/Gamma oscillation periods |
| CNN | Channel depth | Progressive representation capacity | |
| Transformer | Encoder layers | 2 | Models first- and second-order dependencies |
| Transformer | Attention heads | 8 | Parallel multi-scale temporal modeling |
| Output | Pooling | Global Average | Sequence aggregation, parameter efficiency |
| Metric | Value |
|---|---|
| Accuracy | 91.3% |
| Precision (Focus) | 96.7% |
| Recall (Focus) | 92.4% |
| F1 Score | 94.5% |
| Metric | Value |
|---|---|
| Recording-level Accuracy | 88.2% |
| Precision (Focus) | 90.9% |
| Recall (Focus) | 90.9% |
| F1 Score | 90.9% |
| Condition | Mean | SD | Range |
|---|---|---|---|
| EEG-informed audio | 79.2 | 18.6 | 47–100 |
| Silence control | 66.0 | 21.2 | 33–93 |
| Difference | +13.2 | 20.0 | — |
EEG Decoding
Electroencephalography (EEG) decoding maps brain-signal patterns to mental states, stimuli, speech, or intended actions.
See all 210 papers