What does an ECG show?

Introduction

Project introduction

What does an ECG show?

An electrocardiogram (ECG) records the small voltage that the heart produces on the skin, about one thousandth of a volt, sampled hundreds of times per second. Each heartbeat draws the same three shapes. The P wave is a small bump made by the upper chambers (the atria) as they contract. The QRS complex is the tall, narrow spike made by the lower chambers (the ventricles), and its highest point is called the R peak. The T wave is a rounder bump made as the ventricles recover.

Most beats start in the heart's natural pacemaker and look alike from one beat to the next. Some beats arrive early from somewhere else. A supraventricular ectopic beat starts above the ventricles and usually keeps a normal-looking QRS complex, so mainly its early timing gives it away. A ventricular ectopic beat starts in the ventricles themselves and looks wide and different, often with no P wave in front. Long recordings hold tens of thousands of beats, which is why people have built programs to sort them since the 1970s.

Why is it hard?

Real recordings are messy. Breathing makes the line between beats drift, electrodes pick up mains hum and muscle noise, and every person's beats have their own shape. A classifier trained on some patients has to work on people it has never seen, and the rare beat types often come from only a few patients.

In this project you work with the MIT-BIH Arrhythmia Database, 48 half-hour recordings that cardiologists annotated beat by beat, published by PhysioNet under the Open Data Commons Attribution License. You will clean the signal, find every heartbeat, and train a small network to sort beats into the classes of the AAMI EC57 standard. Then you will see how much the score depends on whether the test patients were also in the training data. This is a learning exercise and not a diagnostic tool.

One patient's heartbeats

6 s of a real ECG
NNVNVNV
20 s23 s26 s
Nnormal beatVearly beat from the ventriclesthe line between beats drifts
Cleandrift and hum out
Find beatsone peak per beat
Windows0.67 s per beat
1D CNNN, S, V or F
New patientsthe honest test

What you will build

01

Clean

Remove baseline wander with a moving average, then turn every QRS complex into one bump of slope energy.

02

Find beats

Pick R peaks with an adaptive threshold and a refractory period, as in Pan and Tompkins' 1985 detector.

03

Classify

Cut a window around every beat and score a classifier class by class with sensitivity and precision.

Start with a flat baseline

Remove the slow drift under the heartbeats with a centred moving average.

Continue to Problem 1