We release the latest research paper: Self-supervised Anomaly Detection Pretraining Enhances Long-tail ECG Diagnosis
Aofan Jiang, Chaoqin Huang, Qing Cao, Yuchen Xu, Zi Zeng, Kang Chen, Ya Zhang, and Yanfeng Wang
Code will be made public in this repository soon
Abstract: Current computer-aided ECG diagnostic systems struggle with the underdetection of rare but critical cardiac anomalies due to the imbalanced nature of ECG datasets. This study introduces a novel approach using self-supervised anomaly detection pretraining to address this limitation. The anomaly detection model is specifically designed to detect and localize subtle deviations from normal cardiac patterns, capturing the nuanced details essential for accurate ECG interpretation. Validated on an extensive dataset of over one million ECG records from clinical practice, characterized by a long-tail distribution across 116 distinct categories, the anomaly detection-pretrained ECG diagnostic model has demonstrated a significant improvement in overall accuracy. Notably, our approach yielded a 94.7% AUROC, 92.2% sensitivity, and 92.5% specificity for rare ECG types, significantly outperforming traditional methods and narrowing the performance gap with common ECG types. The integration of anomaly detection pretraining into ECG analysis represents a substantial contribution to the field, addressing the long-standing challenge of long-tail data distributions in clinical diagnostics. Furthermore, prospective validation in real-world clinical settings revealed that our AI-driven approach enhances diagnostic efficiency, precision, and completeness by 32%, 6.7%, and 11.8% respectively, when compared to standard practices. This advancement marks a pivotal step forward in the integration of AI within clinical cardiology, with particularly profound implications for emergency care, where rapid and accurate ECG interpretation is crucial. The contributions of this study not only push the boundaries of current ECG diagnostic capabilities but also lay the groundwork for more reliable and accessible cardiovascular care.
This repository contains the official PyTorch implementation of
Multi-scale Cross-restoration Framework for Electrocardiogram Anomaly Detection
Aofan Jiang, Chaoqin Huang, Qing Cao, Shuang Wu, Zi Zeng, Kang Chen, Ya Zhang, and Yanfeng Wang
Presented at MICCAI 2023 (Early Accept)
@inproceedings{jiang2022ecgad,
title={Multi-scale Cross-restoration Framework for Electrocardiogram Anomaly Detection}
author={Jiang, Aofan and Huang, Chaoqin and Cao, Qing and Wu, Shuang and Zeng, Zi and Chen, Kang and Zhang, Ya and Wang, Yanfeng},
booktitle={International Conference on Medical Image Computing and Computer Assisted Intervention (MICCAI)},
year={2023}
}
Abstract: Electrocardiogram (ECG) is a widely used diagnostic tool for detecting heart conditions. Rare cardiac diseases may be underdiagnosed using traditional ECG analysis, considering that no training dataset can exhaust all possible cardiac disorders. This paper proposes using anomaly detection to identify any unhealthy status, with normal ECGs solely for training. However, detecting anomalies in ECG can be challenging due to significant inter-individual differences and anomalies present in both global rhythm and local morphology. To address this challenge, this paper introduces a novel multi-scale cross-restoration framework for ECG anomaly detection and localization that considers both local and global ECG characteristics. The proposed framework employs a two-branch autoencoder to facilitate multi-scale feature learning through a masking and restoration process, with one branch focusing on global features from the entire ECG and the other on local features from heartbeatlevel details, mimicking the diagnostic process of cardiologists. Anomalies are identified by their high restoration errors. To evaluate the performance on a large number of individuals, this paper introduces a new challenging benchmark with signal point-level ground truths annotated by experienced cardiologists.
Keywords: Anomaly Detection, Electrocardiogram
- python >= 3.6.9
- pytorch >= 1.10.0
- torchvision >= 0.11.1
- numpy >= 1.19.2
- scipy >= 1.5.2
- matplotlib >= 3.3.2
- wfdb >= 4.1.0
- heartpy >= 1.2.7
- tqdm
- Download the PTB-XL dataset here and preprocess it by
preprocess.py
. Or one can choose to directly download our processed PTB-XL data set for anomaly detection on Google Drive or Baidu Disk (hrsh) and put it underdata
folder. - Download our proposed benchmark with signal point-level localization annotations on Google Drive or Baidu Disk (439w) and put it under
data
folder. - Download the pre-train models on Google Drive or Baidu Disk (m60k) and put it under
ckpt
folder.
After the preparation work, the whole project should have the following structure:
./ECGAD
├── README.md
├── train.py # training code
├── test.py # testing code
├── ckpt
│ └── mymodel.pt
├── data
│ ├── benchmark_data.npy # proposed benchmark data
│ ├── benchmark_label.npy # proposed benchmark label
│ ├── train.npy # processed PTB-XL training data
│ ├── test.npy # processed PTB-XL testing data
│ └── label.npy # processed PTB-XL testing label
├── model.py
├── dataloader.py
└── utils.py
python test.py --data_path ./data/ --load_model 1 --load_path ./ckpt/mymodel.pt
python train.py --data_path ./data/ --save_model 1 --save_path ./ckpt/mymodel_new.pt
Then you can run the evaluation using:
python test.py --data_path ./data/ --load_model 1 --load_path ./ckpt/mymodel_new.pt
Detection (PTB-XL) | Localization (Benchmark) | |||
AUC (%) | Paper | Inplementation | Paper | Inplementation |
Ours | 86.0 | 86.0 | 74.7 | 75.4 |
If you have any problem with this code, please feel free to contact stillunnamed@sjtu.edu.cn.