Hardware–Algorithm Co-Design for Brain–Computer Interfaces in Mental Health
A Real-Time EEG-Based Stress Monitoring and Intervention System
This work explores the co-design of biomedical sensing hardware and deep learning algorithms for brain–computer interfaces, focusing on mental stress detection and intervention. The project investigates how signal acquisition constraints, noise characteristics, and embedded system limitations directly inform model design and system architecture.
The resulting system demonstrates a complete research pipeline from neural signal acquisition to real-time cognitive state inference, aligning with ongoing research in neurotechnology, intelligent biomedical systems, and embedded AI.
Why Brain–Computer Interfaces for Mental Health Remain an Open Research Problem
Mental stress and affective disorders are challenging to monitor objectively outside controlled clinical settings. While EEG provides direct access to neural dynamics, existing BCI systems often fall into two extremes: laboratory-grade systems prioritising signal fidelity over accessibility, or consumer platforms relying on indirect proxies with limited physiological grounding.
This crucial gap motivates a central question in modern Bioengineering and EECS: Can we design EEG-based systems that maintain neuroscientific validity while being deployable, affordable, and capable of real-time operation?
Pain Points
Cost and Availability of Current EEG Systems
Market Survey on Accessibility
Market Survey requiring EEG and Stress Management System accessibility in Pakistan and other resource constraint Environments.
Proposed Solution and Impact
Core Research Question
This project hypothesises that robust stress-related neural signatures can be extracted from low-cost, hardware-constrained EEG systems when signal processing and AI models are explicitly designed around those constraints.
Rather than relying solely on software compensation for poor signal quality, this research investigates how hardware-aware filtering, amplification, and resolution enhancement can ensure more reliable downstream learning.
The key question is: Under what sensing and computational conditions does stress classification remain stable and meaningful?
Noisy EEG signal with Artifacts (SAM-40 Dataset):
End-to-End BCI as a Research System
The proposed architecture establishes a complete BCI pipeline incorporating both engineering robustness and neuroscientific relevance. EEG signals are acquired, conditioned via analogue filtering and amplification, digitised using a high-resolution ADC, and wirelessly transmitted for inference.
A deep learning model interprets the signals in real time, mapping the output to user-level stress indicators and interventions. This system allows for the systematic study of how each layer of the system influences cognitive-state inference, promoting holistic optimisation rather than isolated component design.
Designing EEG Hardware for Learning-Centric BCIs
A custom single-channel EEG sensor was engineered as a dedicated research instrument. Electrode placement targets FP1, following the international 10–20 system, to capture prefrontal activity linked to cognitive load and stress.
The analogue front-end includes impedance matching, buffering, and instrumentation amplification (using AD620), supplemented by notch and band-limiting filters. This robust design permits controlled investigation into how initial signal conditioning affects subsequent learned representations.
Instrumentation Amplifiers
Notch Filter (50 Hz) to block powerline interference
Low Pass Filter
Removes high frequency oscillations (200 Hz).
Clamper Circuit
Complete Hardware Implementation
Hardware
Electrode Placement (FP1 pole)
Results
Resolution, Sampling, and Embedded Constraints
To circumvent the inherent resolution limitations of typical embedded EEG platforms, a 16-bit external ADC (ADS1115) was seamlessly integrated with an ESP32 microcontroller.
This configuration delivers higher-fidelity digitisation while sustaining reliable wireless communication and real-time operational capacity. The system supports optimal sampling rates for cognitive EEG analysis, offering a robust platform to investigate how ADC resolution and sampling strategies impact model robustness—a vital topic in edge-AI and embedded neuroscience research.
Learning Stress Representations from EEG
Model development utilised the SAM-40 EEG dataset, which was collected under rigorously controlled cognitive stress paradigms. Data from the FP1 channel, consistent with the hardware design, underwent meticulous segmentation, filtering, and transformation using discrete wavelet decomposition (db2 mother wavelet with 4 levels).
A convolutional neural network, was engineered to directly learn stress-related neural patterns from the processed EEG segments. Key emphasis was placed on developing representations that exhibit resilience and stability despite common signal variability and noise.
EEG Bands Extracted from Raw EEG using Wavelet Transform
Stress Detection (CNN) Model
Accuracy Curves ———> 99.7% Training, 99.5% Testing
Loss Curves—————> Losses < 0.2 for both train and test
Prediction Score Via Confusion Matrix
From Neural Signals to Real-Time Inference
The system successfully demonstrates reliable EEG signal acquisition, even under noisy field conditions, coupled with effective suppression of power-line and high-frequency artifacts. The StressNet model accurately distinguishes between stress and non-stress states, with the entire inference pipeline functioning in real time via a custom visualization and stress management application.
Crucially, the system facilitates the observation of how signal quality, preprocessing, and model design collectively influence inference stability, yielding critical insights for future BCI development.
EEG Visualization through ESP32 Bluetooth on Python Bluetooth App
The stress management application integrates real-time AI-based stress inference with a secure user interface for continuous monitoring. User authentication and session data are managed using a hybrid backend architecture, combining SQLite for local storage and Firebase for cloud-based credential management and login history tracking. This design supports scalability, data persistence, and future deployment in real-world stress monitoring studies.
EEG Signal Visualization
Stress Indication & Music Intervention to relieve the patient or subject
The system provides adaptive music-based stress intervention. Music automatically changes if stress does not reduce within one minute and stops once stress indicators return to baseline.
Contributions and Future Research Directions
This project successfully delivers an end-to-end framework for hardware-aware BCI design, integrating custom EEG sensing, signal conditioning, and deep learning inference. The work highlights the necessity of co-designing hardware and algorithms to achieve reliable cognitive-state estimation in resource-constrained environments.
Current limitations include reliance on a single EEG channel and offline training. Future research will encompass multi-channel sensing, adaptive on-device learning, closed-loop neurofeedback, and clinical validation. This trajectory provides a strong foundation for doctoral research in neurotechnology, intelligent biomedical systems, and embedded machine learning.
Showcasing our research on OpenHouse
Made with