NeuroCardiacShield
A complete multi-modal physiological monitoring platform that integrates brain and heart signals for real-time health risk assessment
We built an end-to-end system from embedded firmware to machine learning to demonstrate how next-generation wearable medical devices could detect cardiovascular-neurological risks before they become emergencies.
Why This Matters
Every year, millions of people experience sudden cardiac events or neurological emergencies that could have been predicted. Current wearables monitor heart OR brain — never both together.
Cardiac Events
805,000heart attacks per year in the US alone
Many cardiac arrhythmias produce neurological symptoms (dizziness, syncope) before the heart attack occurs. Current ECG monitors miss these warning signs.
Neurological Events
1 in 26people will develop epilepsy
SUDEP (Sudden Unexpected Death in Epilepsy) kills thousands yearly. These deaths involve cardiac arrhythmias triggered by seizures — a brain-heart connection that single-modality devices cannot detect.
The Gap We Address
The heart and brain are bidirectionally connected through the autonomic nervous system. Cardiac events affect brain function; neurological events affect heart rhythm. No consumer device monitors both simultaneously.
NeuroCardiac Shield demonstrates how such a device would be built — from signal acquisition to machine learning inference — as a complete reference implementation.
What We Built
A complete end-to-end system that captures brain and heart signals, processes them in real-time, extracts clinically meaningful features, and predicts health risks using machine learning.
Hardware Layer
C firmware simulating an embedded device that captures 8-channel EEG and 3-lead ECG at 250 Hz.
- • 569-byte binary packets
- • 10 packets/second throughput
- • BLE communication stub
Signal Processing
Digital signal processing pipeline using validated algorithms from clinical literature.
- • Butterworth bandpass filters
- • R-peak detection (Pan-Tompkins)
- • Welch PSD estimation
ML Inference
Ensemble model combining gradient boosting with deep learning for interpretable predictions.
- • XGBoost (60% weight)
- • BiLSTM (40% weight)
- • 76 hand-crafted features
End-to-End Data Flow
Real-Time Physiological Monitoring
Watch simulated brain and heart signals as they would appear from a real patient. Each signal carries specific physiological meaning that our system extracts and analyzes.
8-Channel EEG
Brain electrical activity
Relaxed / Eyes Closed: Dominant alpha rhythm, especially in occipital regions. Classic "alpha block" when eyes open.
Understanding EEG Frequency Bands
3-Lead ECG
Heart electrical activity
Understanding the PQRST Complex
Each heartbeat produces a characteristic waveform.
How We Generate Clinically Realistic Data
Our synthetic data isn't random noise — it's generated using validated algorithms from peer-reviewed neuroscience and cardiology literature. Here's exactly how it works.
Why Synthetic Data?
Real patient EEG/ECG data requires IRB approval, HIPAA compliance, and months of clinical partnerships. For an academic prototype, we use synthetic data that mimics real physiological signals closely enough to develop and test our algorithms. The same signal processing and ML pipelines would work on real data.
Power spectral density matches clinical EEG databases. 1/f noise slope verified against published norms.
PQRST timing matches AHA guidelines. HRV metrics fall within normal physiological ranges.
Different cognitive/arousal states produce distinct spectral signatures, just like in real recordings.
EEG Signal Generation Algorithm
Each EEG channel is composed of 5 frequency bands (delta, theta, alpha, beta, gamma) with amplitudes based on the 10-20 electrode system and published normative data.
signal = Σ A_band × sin(2π × f_band × t)Real EEG has a characteristic "1/f" power spectrum — lower frequencies have more power. We use the Voss-McCartney algorithm to generate pink noise with equal energy per octave.
PSD(f) ∝ 1/f^α, where α ≈ 1Cognitive states alter the relative power of each band. Alert states boost beta/gamma; relaxed states boost alpha; drowsy states boost theta/delta.
Alpha waves naturally "wax and wane" in real EEG. We add slow (~0.5 Hz) modulation to create realistic spindle-like patterns.
Dominant alpha rhythm, especially in occipital regions. Classic "alpha block" when eyes open.
Interactive Component Explorer
See how each frequency band contributes to the final signal. Click a band to isolate it.
ECG Signal Generation: The McSharry Model
Our ECG generation is based on the McSharry dynamical model, a widely-cited algorithm that uses Gaussian functions to create realistic PQRST morphology.
Each ECG wave (P, Q, R, S, T) is modeled as a Gaussian:
W(t) = A × exp(-(t - t₀)² / (2σ²))RR intervals vary naturally (5-10%). We model this plus respiratory sinus arrhythmia (RSA).
Baseline wander (~0.2 Hz), electrode noise, and 60 Hz powerline interference are added.
Premature Ventricular Contractions have wide QRS, no P wave, and inverted T waves.
Scientific References
EEG Signal Generation
ECG Signal Generation
Note: While our synthetic data follows established algorithms, it is not a substitute for real clinical data. The patterns are approximations and would require validation against actual patient recordings before any clinical use.
From Raw Signals to Meaningful Features
Raw physiological signals are noisy and high-dimensional. Our digital signal processing pipeline extracts 76 clinically meaningful features that the ML model uses for prediction.
EEG Feature Extraction
4th-order Butterworth filter (0.5-50 Hz) removes DC drift and high-frequency noise while preserving brain rhythms.
Welch's method decomposes each channel into frequency bands (delta, theta, alpha, beta, gamma).
Band powers, spectral entropy, and inter-hemispheric coherence computed per channel.
ECG & HRV Feature Extraction
Pan-Tompkins algorithm identifies R-peaks (heartbeats) with 99%+ accuracy on clean signals.
SDNN, RMSSD, pNN50 computed from R-R intervals per Task Force of ESC (1996) standards.
LF (0.04-0.15 Hz) and HF (0.15-0.4 Hz) power reflect sympathetic/parasympathetic balance.
Complete Feature Set: 76 Features
Every feature has clinical meaning — we prioritize interpretability over black-box representations.
Interpretable Risk Prediction
We chose an ensemble approach that prioritizes explainability. Medical AI must be interpretable — clinicians need to understand WHY a prediction was made, not just what it is.
Ensemble Architecture
Gradient boosted trees operating on 76 hand-crafted features. Provides direct feature importance scores.
Ensemble
Bidirectional LSTM captures temporal patterns in raw signal windows that features might miss.
ROC Curve (XGBoost)
Area Under Curve measures how well the model separates classes. 0.5 = random, 1.0 = perfect.
Top Feature Importance
Which features matter most? HRV metrics dominate — the autonomic nervous system is key.
Honest Limitation
Our BiLSTM achieves 99.75% accuracy — suspiciously high. This indicates the synthetic training data contains patterns that are too easy to learn and would not generalize to real patients. We document this as a limitation, not an achievement. Real clinical deployment would require training on actual patient data with IRB approval and clinical validation studies.
Four-Layer Medical Device Architecture
We followed IEC 62304 medical device software patterns (though without formal compliance). Each layer has clear responsibilities and interfaces, enabling independent testing and future hardware integration.
dashboard/app.pyReal-time dashboard displaying 8-channel EEG, ECG waveforms, risk gauge, and HRV metrics. WebSocket connection for live updates.
cloud/api/server.pyREST API for data ingestion (/ingest), ML inference (/inference), and system status. Manages 1000-packet circular buffer.
cloud/signal_processing/ml/model/Signal processing (Butterworth filters, Welch PSD, R-peak detection) and ML inference (ensemble prediction with confidence).
firmware/cloud/device_adapters/Device adapters for simulated, BLE, and serial connections. Binary packet parsing (569 bytes → JSON). Hardware abstraction layer.
Reproducible, Verified, Open Source
Every component is tested. Every claim is verified. The entire codebase is open source for inspection, learning, and extension.
Verification Breakdown
Try It Yourself
Live Device Integration
Connect your own wearable device to see real physiological data flowing through the NeuroCardiac Shield system. We support any Bluetooth LE heart rate monitor.
Device Connection
Connect a Bluetooth heart rate monitor to see live data
How to Connect
- 1Put on your heart rate monitor (chest strap works best for HRV data)
- 2Make sure Bluetooth is enabled on your computer
- 3Click "Connect Device" and select your device from the list
- 4Watch your real heart data flow through the system!
Compatible Devices
We're working on integrating consumer EEG devices like Muse and OpenBCI. This requires custom SDK integration. Star the repo to get notified when EEG support is added!