MCi Insights
ECG feature extraction with wavelets
Clinically meaningful cardiac analysis does not require a workstation. It requires the right transform and a careful implementation on an 8-bit microcontroller.
Electrocardiography measures the heart's electrical activity, and the diagnostic information sits in the shape and timing of the PQRST complex. Detecting those features accurately is the basis for identifying arrhythmia, ischaemia and other cardiovascular conditions. Conventional ECG systems use substantial processing power to do it. This project demonstrates the same task on an Atmel AVR microcontroller.
Why the signal is difficult
ECG signals are low amplitude — typically minus 1 to plus 1 mV — and sit in an environment full of interference: muscle artefact, mains hum, baseline wander from respiration and movement, and substantial morphological variation between individuals.
Wavelet transforms suit this problem particularly well. Unlike Fourier analysis, which trades away time localisation, wavelets provide multi-resolution analysis with both time and frequency information. That matters here because the ECG contains a sharp, high-frequency transient (the QRS complex, particularly the R-wave) alongside slow, low-frequency components (P and T waves) that must be characterised in the same analysis.
The implementation
- 1. Acquisition
- The raw signal is taken from an ECG sensor or analogue front end, amplified and digitised by the microcontroller's ADC. An ATmega328P provides adequate ADC channels and throughput for real-time acquisition.
- 2. Filtering
- Preprocessing removes muscle artefact, power-line interference and baseline drift, using a bandpass filter to retain the cardiac frequency band and low-pass filtering to remove high-frequency noise. An FIR filter implemented in software on the AVR is sufficient and predictable.
- 3. Wavelet decomposition
- The Discrete Wavelet Transform decomposes the filtered signal into sub-bands capturing features at multiple resolutions. Haar and Daubechies wavelets are chosen for computational simplicity and real-time viability on constrained hardware.
- 4. R-wave detection
- The R-wave is identified first — it is the most prominent feature, high in amplitude and sharp in transition, which makes it robust to detect and ideal as a reference point.
- 5. PQRST identification
- Working outward from each detected R-wave, and using the known morphology of the cardiac cycle, the system locates the P, Q, S and T waves by analysing wavelet coefficients across the relevant sub-bands.
- 6. Feature derivation
- Heart rate from the RR interval, PR interval from P-wave onset to QRS onset, QT interval from QRS onset to T-wave offset, and QRS duration — the measurements clinical interpretation actually uses.
- 7. Output
- Results displayed locally on an LCD or LED matrix, stored for later analysis, or transmitted over serial to a remote system.
Why it matters
The demonstration is that real-time, clinically meaningful cardiac feature extraction runs on hardware that costs a few euros and draws milliwatts. That changes what is deployable: portable monitors, wearable devices, and continuous monitoring in settings where conventional equipment is unavailable or unaffordable.
The same architecture — conditioned acquisition, digital filtering, wavelet decomposition, feature extraction on-device — transfers directly to industrial vibration monitoring, acoustic analysis and power quality measurement. Any domain where a transient buried in noise carries the information you need.
Tell us what you're building.
Bring us a defined project, an audit finding, a system that has outgrown its architecture, or a regulation you are not sure how to satisfy. We will tell you plainly whether we are the right people for it.