In this project, I use the open ECG dataset from AF Classification from a Short Single Lead ECG Recording - The PhysioNet Computing in Cardiology Challenge 2017, dataset can be found in here.
In dataset, there are total 8528 short single lead ECG recordings collected by AliveCor device. The ECG recordings last from 9s to 60s and were sampled as 300Hz and have been band pass filtered by AliverCor device. The recordings have been categorized into 4 types: Normal rhythm, Atrial fibrillation, other rhythm and noisy recordings.
Type | Recording | Mean | SD | Max | Median | Min |
---|---|---|---|---|---|---|
Normal | 5154 | 31.9 | 10.0 | 61.0 | 30 | 9.0 |
AF | 771 | 31.6 | 12.5 | 60 | 30 | 10.0 |
Other | 2557 | 34.1 | 11.8 | 60.9 | 30 | 9.1 |
Noisy | 46 | 27.1 | 9.0 | 60 | 30 | 10.2 |
Total | 8528 | 32.5 | 10.9 | 61.0 | 30 | 9.0 |
Overview
QRS complex detection
Apply Hamilton QRS complex detection algorithm to locate the R peaks of ECG signals.
Heartbeat segmentation
1D-CNN
2D-CNN
-
Download ECG dataset: Download dataset in here and extract training2017 and sample2017 folders.
-
Execute preprocess.py to prepare training input for further CNN training
python3 Preprocess.py
- Execute main.py for training model via convolution neural network
python3 main.py
- After training, to see training result with tensorboard, execute following command in terminal. Copy the url and open it with web broswer.
tensorboard --logdir logs/
- 1DCNN_med_wave.ipynb : Use median wave extraction method to select features as training data, and training data with one dimension convolution neural network.
- 2DCNN_templates.ipynb: Use heartbeat extraction method to generate heartbeat images as training data, and training data with two dimension convolution neural network.
- 2DCNN_specg.ipynb: Use spectrogram as training data, and training data with two dimension convolution neural network.