Skip to main content
medRxiv
  • Home
  • About
  • Submit
  • ALERTS / RSS
Advanced Search

Image Based Deep Learning in 12-Lead ECG Diagnosis

View ORCID ProfileRaymond Ao, George He
doi: https://doi.org/10.1101/2022.11.21.22282586
Raymond Ao
1Independent
MD
  • Find this author on Google Scholar
  • Find this author on PubMed
  • Search for this author on this site
  • ORCID record for Raymond Ao
  • For correspondence: raymond53892{at}gmail.com
George He
MD
  • Find this author on Google Scholar
  • Find this author on PubMed
  • Search for this author on this site
  • Abstract
  • Full Text
  • Info/History
  • Metrics
  • Data/Code
  • Preview PDF
Loading

Abstract

Background Most studies on machine learning classification of electrocardiogram (ECG) diagnoses focus on processing raw signal data rather than ECG images. In clinical practice, it is often the case where ECGs printed on paper or only digital images are easily accessible. This study aims to evaluate the accuracy of image based deep learning algorithms on 12 lead ECG diagnosis.

Methods Deep learning models were trained on various 12-lead ECG datasets and evaluated for accuracy by testing on holdout test data as well as data from datasets not seen in training.

Results The results demonstrated excellent AUROC, AUPRC, sensitivity and specificity on holdout test data from datasets used in training, but poorer accuracy on unseen datasets.

Discussion This study demonstrates feasibility of image based deep learning algorithms in ECG diagnosis, and identifies directions for future research in order to develop clinically applicable deep-learning models in ECG diagnosis.

1 Introduction

Deep learning methods have been shown excellent diagnostic performance on classifying electrocar-diogram (ECG) diagnoses using signal data, even surpassing individual cardiologist performance in some studies. Most studies published to date focus on machine learning diagnosis of ECGs by processing raw signal data. In clinical practice, obtaining signal data from ECG machines may be difficult, such as in cases where ECGs are printed on paper, or where only digital images are easily accessible. In this experiment, we trained convolutional neural networks (CNNs) capable of classifying raw images of 12-lead ECGs with comparable or superior performance to existing raw signal classifiers.

1.1 Literature review

Multiple studies have shown excellent diagnostic accuracy, including performance superior to cardiologists, in 12-lead ECG diagnosis. For example, one study which used raw ECG data created a DNN which performed similarly to or better than the average of individual cardiologists [1] in classifying 12 different rhythms, including atrial fibrillation/flutter, AVB, junctional rhythm, ventricular tachycardia, SVT, and Wenkebach in single lead ECG. Other studies used signal data from 12-lead ECGs with excellent results in arrhythmia classification.

The method used in this experiment differs from most other studies in that ECG image data is directly used to train and test deep learning models as opposed raw signal data or transformations of signal data. The benefit of this method is that models can be used in cases where there is no raw signal data (e.g. ECGs printed on paper) or where signal data is difficult to obtain and analyse. The only studies we have identified which use raw ECG images only differentiated between ‘normal’ and ‘sick’ or abnormal [2], or individual beats only [3]

2 Methods

2.1 Datasets

The primary dataset used for model development and evaluation was PTB-XL. We also tested for external validity of models across different unseen datasets, as well as with different datasets in combination.

The following publicly available ECG datasets were used:

  • PTB-XL [4] (PTB)

  • CPSC 2018 database [5] (CPSC)

  • 12-lead ECG database for arrhythmia research from Chapman University and Shaoxing People’s Hospital [6] (Shaoxing)

  • Test dataset for: Automatic multi-label ECG diagnosis of impulse or conduction abnormalities in patients with deep learning algorithm: a cohort study [7] (Tongji)

Each dataset contained raw 10-second 12-lead ECG signal waveform data with corresponding diagnostic labels.

2.2 Data pre-processing

For each individual ECG sample, an image was generated by plotting the signal data. We used the Python ECG plot [8] library, which generates 12-lead ECG images resembling ECG displays and print-outs commonly used in clinical practice. An example is shown in Figure 1. Images were processed at 1600x512 resolution.

Figure 1:
  • Download figure
  • Open in new tab
Figure 1:

Example of an ECG image generated from the signal data of one sample in the dataset

The images were then converted to grayscale, then binarised using simple thresholding, Otsu thresholding, and adaptive thresholding. A binarised copy was saved for each of the thresholding techniques. For further data augmentation, a slightly blurred vision of the grayscale image was created, and the aforementioned thresholding techniques were also applied. In total, eight augmented copies of each original ECG image was generated. An example of an image after grayscale conversion and adaptive thresholding is shown in figure 2.

Figure 2:
  • Download figure
  • Open in new tab
Figure 2:

Example of an ECG image after grayscale conversion and adaptive thresholding

Figure 3:
  • Download figure
  • Open in new tab
Figure 3:

Example of an activation heatmap for an ECG showing WPW

Figure 4:
  • Download figure
  • Open in new tab
Figure 4:

Example of an activation heatmap for an ECG showing myocardial infarction

Figure 5:
  • Download figure
  • Open in new tab
Figure 5:

Example of an activation heatmap for an ECG showing SVT

2.3 Classification task overview

Binary classification models were trained predict the presence and absence of:

  • Normal ECG (NORM)

  • Left bundle branch block (LBBB)

  • Right bundle branch block (RBBB)

  • Atrial fibrillation (AFIB)

  • Atrial flutter (AFLT)

  • First degree AV block (fAVB)

  • Myocardial infarction (MI)

  • Wolff-Parkinson White (WPW)

  • Supraventricular tachycardia

Models were trained using the PTB-XL dataset and evaluated on holdout test data from PTB-XL. Additionally, models were also tested on ECG images from other datasets not involved in training. Further testing was done on combined datasets, where matching diagnostic labels were present.

For each training run, the included samples from all datasets were randomly shuffled, and split into training, validation and holdout test sets, with splits of 0.8, 0.1 and 0.1 respectively.

2.4 Model architecture and training

Model were built on VGG16 architecture with Imagenet pre-trained weights. The original classification layer was removed and replaced with a classification head consisting of a global average pooling 2D layer, a dropout layer for training, followed by a fully connected layer with one output and sigmoid activation.

The classification head was initially trained for up to 10 epochs with early stopping, while all other layers were frozen. The entire model was then unfrozen, and trained until no further drop in validation loss was seen (early stopping with patience of 6). The learning rate was 1x 10-^5. A learning rate schedule involving reducing the learning rate when the validation loss plateaued was trialled, without significant improvement of results.

For most training instances, binary cross-entropy loss was used. We also experimented with focal loss for highly imbalanced datasets.

3 Results

The models demonstrated good performance when tested on unseen holdout test data from the original datasets used on training. Generalisation to unseen, external datasets was poorer. Performance of models trained on a combination of different datasets mixed together showed good performance on holdout test splits containing the mixed datasets. The results are summarised in table below

View this table:
  • View inline
  • View popup
  • Download powerpoint
Table 1:

Test results of models trained on PTB-XL ECGs and tested on a holdout test set from PTB-XL

View this table:
  • View inline
  • View popup
  • Download powerpoint
Table 2:

Test results of models trained on combined datasets and tested on holdout data from the combined datasets

View this table:
  • View inline
  • View popup
  • Download powerpoint
Table 3:

Test results of models tested on separate, unseen datasets than those used in training

4 Visual explanation

Gradient-weighted Class Activation Mapping (Grad-CAM) creates a heatmap to visualise areas of the image which are important in predicting its class.

Here are examples of activation maps

5 Discussion

The results show that computer vision models are capable of achieving good diagnostic performance on unseen ECGs sampled from the same population(s) and dataset(s) as that used for model training, including combinations of different datasets. The models were not able to generalise well to unseen external datasets - this may be due to differences in labelling criteria for diagnoses between the datasets, or variances in ECG quality. Overall, classification performance on ECG images using deep CNNs is comparable to the best models using raw ECG signal holdout test data from the same dataset.

5.1 Future work and application

This research demonstrates that computer vision AI models can diagnose conditions on ECG with good accuracy. Future research which could bring this technology closer to clinical application could focus on developing models which can generalise to a wide range of ECG image formats from various sources, and cover a wider range of relevant clinical diagnoses. Additional diagnoses which would be of interest clinically would include diagnosing STEMI in patients with LBBB or pacemaker, differentiating SVT with abberency vs VT, and specific subtypes of AV block. Furthermore, models could be developed to be applicable to different ECG formats or styles. The techniques demonstrated here could also be applied for novel practical applications, such as smartphone applications to diagnose photos of ECGs, or in telehealth.

Data Availability

Data used is publicly available

http://2018.icbeb.org/Challenge.html

https://physionet.org/content/ptb-xl/1.0.3/

https://pubmed.ncbi.nlm.nih.gov/32051412/

References

  1. [1].↵
    Awni Y. Hannun, Pranav Rajpurkar, Masoumeh Haghpanahi, Geoffrey H. Tison, Codie Bourn, Mintu P. Turakhia, and Andrew Y. Ng. Cardiologist-level arrhythmia detection and classification in ambulatory electrocardiograms using a deep neural network. Nature Medicine, 2019.
  2. [2].↵
    Boussaa Mohamed, Atouf Issam, Atibi Mohamed, and Bennis Abdellatif. Ecg image classification in real time based on the haar-like features and artificial neural networks. Procedia Computer Science, 73:32–39, 2015. International Conference on Advanced Wireless Information and Communication Technologies (AWICT 2015).
    OpenUrl
  3. [3].↵
    Tae Joon Jun, Hoang Minh Nguyen, Daeyoun Kang, Dohyeun Kim, Daeyoung Kim, and Young-Hak Kim. Ecg arrhythmia classification using a 2-d convolutional neural network, 2018.
  4. [4].↵
    P. Wagner, N. Strodthoff, RD. Bousseljot, et al. Ptb-xl, a large publicly available electrocardio-graphy dataset.
  5. [5].↵
    Feifei Liu, Chengyu Liu, Lina Zhao, Xiangyu Zhang, Xiaoling Wu, Xiaoyan Xu, Yulin Liu, Caiyun Ma, Shoushui Wei, and Zhiqiang et al. He. An open access database for evaluating the algorithms of electrocardiogram rhythm and morphology abnormality detection. Journal of Medical Imaging and Health Informatics, 8(7):1368–1373, 2018.
    OpenUrlCrossRef
  6. [6].↵
    Jianwei Zheng, Jianming Zhang, Sidy Danioko, Hai Yao, Hangyuan Guo, and Cyril Rakovski. A 12-lead electrocardiogram database for arrhythmia research covering more than 10,000 patients. Scientific Data, 7(1), 2020.
  7. [7].↵
    Hongling Zhu, Cheng Cheng, Hang Yin, Xingyi Li, Ping Zuo, Jia Ding, Fan Lin, Jingyi Wang, Beitong Zhou, and Yonge et al. Li. Automatic multi-label ecg diagnosis of impulse or conduction abnormalities in patients with deep learning algorithm: A cohort study. SSRN Electronic Journal, 2020.
  8. [8].↵
    dy1901. Ecg plot.
Back to top
PreviousNext
Posted November 22, 2022.
Download PDF
Data/Code
Email

Thank you for your interest in spreading the word about medRxiv.

NOTE: Your email address is requested solely to identify you as the sender of this article.

Enter multiple addresses on separate lines or separate them with commas.
Image Based Deep Learning in 12-Lead ECG Diagnosis
(Your Name) has forwarded a page to you from medRxiv
(Your Name) thought you would like to see this page from the medRxiv website.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Share
Image Based Deep Learning in 12-Lead ECG Diagnosis
Raymond Ao, George He
medRxiv 2022.11.21.22282586; doi: https://doi.org/10.1101/2022.11.21.22282586
Twitter logo Facebook logo LinkedIn logo Mendeley logo
Citation Tools
Image Based Deep Learning in 12-Lead ECG Diagnosis
Raymond Ao, George He
medRxiv 2022.11.21.22282586; doi: https://doi.org/10.1101/2022.11.21.22282586

Citation Manager Formats

  • BibTeX
  • Bookends
  • EasyBib
  • EndNote (tagged)
  • EndNote 8 (xml)
  • Medlars
  • Mendeley
  • Papers
  • RefWorks Tagged
  • Ref Manager
  • RIS
  • Zotero
  • Tweet Widget
  • Facebook Like
  • Google Plus One

Subject Area

  • Health Informatics
Subject Areas
All Articles
  • Addiction Medicine (349)
  • Allergy and Immunology (668)
  • Allergy and Immunology (668)
  • Anesthesia (181)
  • Cardiovascular Medicine (2648)
  • Dentistry and Oral Medicine (316)
  • Dermatology (223)
  • Emergency Medicine (399)
  • Endocrinology (including Diabetes Mellitus and Metabolic Disease) (942)
  • Epidemiology (12228)
  • Forensic Medicine (10)
  • Gastroenterology (759)
  • Genetic and Genomic Medicine (4103)
  • Geriatric Medicine (387)
  • Health Economics (680)
  • Health Informatics (2657)
  • Health Policy (1005)
  • Health Systems and Quality Improvement (985)
  • Hematology (363)
  • HIV/AIDS (851)
  • Infectious Diseases (except HIV/AIDS) (13695)
  • Intensive Care and Critical Care Medicine (797)
  • Medical Education (399)
  • Medical Ethics (109)
  • Nephrology (436)
  • Neurology (3882)
  • Nursing (209)
  • Nutrition (577)
  • Obstetrics and Gynecology (739)
  • Occupational and Environmental Health (695)
  • Oncology (2030)
  • Ophthalmology (585)
  • Orthopedics (240)
  • Otolaryngology (306)
  • Pain Medicine (250)
  • Palliative Medicine (75)
  • Pathology (473)
  • Pediatrics (1115)
  • Pharmacology and Therapeutics (466)
  • Primary Care Research (452)
  • Psychiatry and Clinical Psychology (3432)
  • Public and Global Health (6527)
  • Radiology and Imaging (1403)
  • Rehabilitation Medicine and Physical Therapy (814)
  • Respiratory Medicine (871)
  • Rheumatology (409)
  • Sexual and Reproductive Health (410)
  • Sports Medicine (342)
  • Surgery (448)
  • Toxicology (53)
  • Transplantation (185)
  • Urology (165)