ECG Pipeline: QRS Detection & HRV Domains
Prince E. Adjei
Kwame Nkrumah University of Science and Technology
Topic: ECG Pipeline Module 3: Biomedical Signal Processing
Biosignal Processes And Analysis (BME 366)
© 2025 Prince E. Adjei
Topics
(1). ECG Feature Detection and Signal Basics
(2). QRS Detection and RR Interval Extraction
(3). Introduction to Heart Rate Variability (HRV)
(4). Time and Frequency Domain HRV Analysis
(5). HRV Visualization and Clinical Interpretation
ECG Pipeline: QRS Detection & HRV Domains
Learning Objectives
•Apply QRS detection techniques and extract clean RR intervals
for further analysis.
•Explain the physiological basis and relevance of Heart Rate
Variability (HRV).
•Perform HRV analysis using both time-domain and frequency-
domain methods.
•Interpret HRV metrics using visualizations and relate findings to
clinical conditions.
Review
•An electrocardiogram (ECG)
reflects the electrical activity
of the heart.
•The pacemaker cells, known as
the sinoatrial (SA) node,
control the heart rhythm.
•The PQRST represents one
complete ECG cycle.
•The ECG is the most commonly
known, recognized, and used
biomedical signal.
REVIEW
Wave Components:
•P wave –Atrial depolarization
•QRS complex –Ventricular
depolarization
•T wave –Ventricular repolarization
Key Intervals:
•PR: Atrial to ventricular delay
(~0.12–0.20s)
•QT: Ventricular activity (rate-
dependent)
•ST: Should be isoelectric (flat)
REVIEW
Sampling:
•Clinical ECG: 250–500 Hz
•Follows Nyquist (≥2× highest freq)
•Higher rates improve R-peak
accuracy
12-Lead ECG:
•Limb (frontal): I (LA–RA), II (LL–RA),
III (LL–LA), aVR (RA), aVL (LA), aVF
(LL)
•Chest (horizontal): V1–V6 from 4th
ICS (sternum) to midaxillary (V6)
Pan-Tompkins algorithm
•A classic and efficient real-time method for R-peak detection in
ECG signals.
•It uses a series of signal processing steps to accurately isolate QRS
complexes, even in noisy environments.
Signal Processing Pipeline
1.Band-pass Filtering
⚬Removes baseline wander and high-frequency noise
⚬Combines low-pass (~11 Hz) and high-pass (~5 Hz) filters
2.Differentiation
⚬Highlights rapid changes in slope
⚬Emphasizes steep QRS complex upstrokes
Pan-Tompkins algorithm
3. Squaring Function
⚬Converts the signal to positive values
⚬Amplifies large differences and suppresses small ones
4. Moving Window Integration
⚬Smooths the signal using a sliding window (~150 ms)
⚬Represents energy and the approximate width of the QRS
5. Adaptive Thresholding
⚬Continuously adjusts the threshold based on noise and signal
peaks
⚬Detects true R-peaks while rejecting false positives
Pan-Tompkins demo
•The RR interval is the time between two successive R-peaks on an
ECG signal.
•It reflects the duration of one cardiac cycle (i.e., one heartbeat).
•If tn and tn+1 are the time positions of two consecutive R-peaks (in
seconds), then:
•Measured in milliseconds (ms) or seconds (s)
•Used to calculate heart rate:
RR interval extraction
Ectopic Skip Handling
•Ectopic beats (e.g., PVCs) cause irregular RR intervals
•These lead to spurious short or long RR intervals
•Must be detected and flagged to avoid distortion in HRV or rhythm
analysis.
Error Cleaning
•Remove or correct intervals caused by:false/extra peaks, missed
detections, and motion artifacts
•Use signal quality index (SQI), moving average filters, or
interpolation
RR interval extraction
Heart Rate Variability (HRV) is the variation in time between successive
heartbeats, usually derived from the RR interval series.
Time-Domain Measures
•Based directly on the RR intervals
•Simple and widely used in clinical settings
•Reflects overall variability, short-term parasympathetic activity.
Frequency-Domain Measures
•Uses spectral analysis (e.g., FFT, Welch)
•Analyzes the distribution of power across frequency bands
•Reflects rhythmic oscillations in autonomic control
HRV domains:Time vs Frequency
•Time-domain HRV metrics quantify variability in the RR interval
time series directly, without requiring signal transformation.
Key Metrics:
1. SDNN (Standard Deviation of NN intervals)
⚬Reflects total HRV over the recording period
⚬Sensitive to both short- and long-term changes
⚬Common in 24-hour recordings
Time-Domain HRV
2. RMSSD (Root Mean Square of Successive Differences)
•Captures short-term variability
•Strongly associated with parasympathetic (vagal) activity
•Suitable for short recordings (e.g., 1–5 min)
3. pNN50 (% of successive RR intervals differing by >50 ms)
•Also reflects short-term parasympathetic modulation
•Correlates with RMSSD, but is more sensitive to outliers
Time-Domain HRV
Time-Domain: Recommended Time Windows
Metric
Minimum Duration
Typical Use
SDNN
≥5 min (best: 24h)
Overall variability
RMSSD
≥1 min
Short
-term HRV
pNN50
≥2
–5 min
Short
-term HRV
Frequency Domain HRV
•Analyzes how power (variability) is distributed across frequencies in the RR
interval series. Reflects autonomic nervous system rhythms.
Key Metrics:
1.LF Power (Low Frequency)
⚬Related to both sympathetic and parasympathetic influences
⚬Usually derived from 0.04–0.15 Hz band
2.HF Power (High Frequency)
⚬Reflects parasympathetic (vagal) activity
⚬Often associated with respiratory sinus arrhythmia (RSA)
3.LF/HF Ratio
⚬Proposed indicator of sympathovagal balance
⚬Interpretation is debated; it may oversimplify autonomic control
Questions
1) What is the QRS complex, and why is
it important in ECG analysis?
2) What is the purpose of the squaring
step in the Pan-Tompkins algorithm?
3) What is an RR interval, and how is it
used in HRV analysis?
1.Tachogram
•RR intervals vs.time (or beat
number)
•Shows beat-to-beat fluctuation
and long-term trends
•Useful for spotting sudden
shifts (e.g. ectopics, artifacts)
or gradual changes (e.g., stress,
recovery)
HRV Visualization Techniques
HRV Visualization Techniques
2. Poincaré Plot
•Scatter plot of RRₙ₊₁vs.RRₙ
•Elliptical shape →healthy
variability
•Flattened or clustered shape →
reduced HRV
•Quantified with:
•SD1 (short-term)
•SD2 (long-term)
3. Frequency Band Overlay
•Plot of Power Spectral Density
(PSD) with:
•LF and HF regions are shaded or
labeled
Makes it easy to see:
•Dominant rhythms
•Shifts in autonomic balance
•Often based on Welch’s method
HRV Visualization Techniques
•There is no fixed “normal” HRV value, but general ranges are known for
healthy adults:
HRV Standards
METRIC
RANGE
SDNN
30
–50 ms
RMSSD
20
–40 ms
pNN50
5
–15%
LF/HF
1
–2
Stress
•HRV decreases
•Reduced parasympathetic tone (vagal withdrawal)
•LF/HF ratio may increase
•Marker of mental/emotional/physical load
Sleep
•HRV increases, especially during deep (NREM) sleep
•Dominated by parasympathetic activity
•RMSSD and HF power rise
•Useful for tracking recovery or sleep quality
HRV in Different States
Stroke
•HRV markedly decreases
•SDNN and RMSSD are reduced in acute stroke
•Loss of autonomic control —a predictor of poor outcome
•Bilateral or brainstem lesions show the strongest effect
Exercise
•HRV decreases during exercise (especially RMSSD, HF)
•Reflects sympathetic activation
•HRV rebounds post-exercise during recovery
•Used to monitor training load and overtraining
HRV in Different States
The lab demonstrates how to:
•Load a real ECG recording from PhysioNet
•Use neurokit2.ecg_process() to detect R-peaks and extract
features
•Visualize the ECG signal with detected landmarks
•Optionally, compute HRV metrics and RR intervals
Lab Preview: Analyzing PhysioNet ECG with neurokit2
•The Pan-Tompkins algorithm detects R-peaks through a sequence of
filtering, differentiation, squaring, and adaptive thresholding.
•RR intervals form the basis of HRV analysis, requiring careful
preprocessing to handle ectopic beats and noise.
•HRV is assessed in time and frequency domains using metrics like
SDNN, RMSSD, pNN50,and LF/HF ratio, often computed via Welch PSD.
•HRV can be visualized using tachograms, Poincaré plots, and frequency
band overlays to illustrate variability and autonomic balance.
Summary