/ECG-GAN

Synthesize plausible ECG signals via Generative adversarial networks

Primary LanguagePythonMIT LicenseMIT

Synthesis ECG signals via Generative adversarial networks

Setup

pip install -r requirement.txt

Usage

download dataset

  • option 1
sh download.sh

if you haven't install unzip, install unzip package first before run download.sh
install guildline:
General - for Linux
Homebrew - for MacOS

Process ECG signals

run following command

python3 process_ecg.py

if you change the dataset path, modify process_ecg.py

# modify dataset path if necessary
AA_DATASET_DIR = 'AA_dataset/'   # MIT-BIH Arrhythmia Database
    
AF_DATASET_DIR = 'AF_dataset/'   # AF Classification from a Short Single Lead ECG Recording - The PhysioNet Computing in Cardiology Challenge 2017
LABEL_PATH = 'AF_dataset/REFERENCE-original.csv'

GAN Training

training ECG signal with GAN model

python3 train.py

modify the input dataset path in train.py if you change the path of X_train_af.pkl and y_af.pkl

X_train = pickle.load(open("path_of_X_train_af.pkl", "rb"))  # --> load AF dataset
y = pickle.load(open("path_of_y_af.pkl", 'rb'))

Output

MIT-BIH Arrhythmia Database

aa_e4000_7.pngaa_e4000_16.pngaa_e4000_11.pngaa_e4000_19.pngaa_e4000_40.pngaa_e5000_12.pngaa_e5000_26.pngaa_e7000_44.pngaa_e8000_33.pngaa_e10000_51.pngaa_e10000_89.png

Short Single Lead ECG Recording

Atrial Fibrillation

real
af_real_3.png af_real_4.png af_real_6.png
epoch 1000
afaf_e1000_3.png afaf_e1000_4.png afaf_e1000_6.png
epoch 2000
afaf_e2000_6.png afaf_e2000_8.png afaf_e2000_14.png