ECG Heart Rate Extraction Using Signal Progressing




In this project, I utilized the Pan-Tompkins algorithm to extract heart rate from the EKG waveform.

Repository with code can be found here.

Background

The electrocardiogram, otherwise known as the ECG or EKG, is a recording of the electrical potential of the heart. Analysis of this waveform has proved to be an important diagnostic tool for cardiovascular disease and recovery.

Recent studies suggest that resting HR, specifically heart rate variability (HRV), can be indicative of certain cardiovascular disorders and overall mortality as well as an indication of recovery. Thus, efficient signal processing algorithms to derive heart rate from the ECG waveform are critical in effective clinical treatment. These algorithms can be coupled with existing wearables to drive continuous physiological monitoring with the goal of incorporating proactivity in consumer/clinical health.
ECG Waveform
ECG Pan-Tompkins
The Pan-Tompkins algorithm is a technique introduced back in 1985 that uses a relatively simple methodology for HR determination from the ECG. Since its introduction, the algorithm has been widely used in industrial and academic applications.


The algorithm works by extracting peaks (specifically, the QRS wave) of the waveform. The method is as follows:

1. Use a band-pass filter to filter out noise

2. Take the derivative of the time series

3. Square and smooth the result using moving window integration

The resultant waveform consists of identifiable peaks which are indicative of a QRS complex. Every one of these peaks is a heart-beat.

Implementation

My implementation of this algorithm can be found in my GitHub. A Python script and Jupyter notebook are provided to show the methods and use, respectively.

Some comments regarding implementation:

1. The original literature suggests several transfer functions for use specifically in signals that are sampled at 200hz. The data I retreived from PhysioNet was sampled at 360hz. The workaround here is to resample signals to the desired frequency, or use a generalized form of the algorithm and test its performance. I used the latter approach to reduce computational cost and avoid typical problems that may occur during resampling.

2. My implementation of this algorithm should be considered barebones for an industry-standard implementation; there are far more sophisticated techniques that are utilized to improve algorithm performance, especially in the presence of noise, such as:

  a. Introduce a refactory period of 200ms when a peak is detected so no erroneous peaks are counted.
  b. Introduce adaptive thresholds based on surrounding noise levels.
  c. Introduce a way to detect high amplitude T waves that may be counted as QRS waves.

I'll be working on implementing these more advanced methods when I get the chance. Please feel free to contact me to check on progress.