Skip to main content

A deep learning toolkit for ECG analysis

Project description

DeepECG-Kit

A PyTorch Lightning-based deep learning library for ECG analysis and arrhythmia classification. Provides a CLI for training, evaluation, and inference across multiple model architectures and ECG datasets.

Install with pip install deepecgkit, or for local development clone the repo and run pip install -e ".[dev]".

Usage

deepecg train -m kanres -d af-classification    # train (auto-downloads dataset)
deepecg evaluate --checkpoint model.ckpt -d af-classification
deepecg predict --checkpoint model.ckpt --input ecg.npy
deepecg resume --checkpoint model.ckpt --epochs 100
deepecg list-models                              # list available models/datasets
deepecg list-datasets
deepecg info -m kanres

Models: afmodel, convnext-v2, crnn, deep-res-cnn, dualnet, fcn-wang, gru, inception-time, kanres, kanres-deep, lstm, mamba, medformer, resnet, resnet-wang, se-resnet, simple-cnn, tcn, transformer, xresnet, xresnet1d-benchmark

Datasets: af-classification (1-lead, 4-class, PhysioNet 2017), ptbxl (12-lead, 5 superclasses, multi-label), mitbih-afdb (2-lead, binary/4-class, MIT-BIH AFDB), ltafdb (2-lead, binary/4-class, Long-Term AFDB), unified-af (1-lead, 4-class, combined cross-dataset).

Experiments

Experiments are defined in experiments.yaml and run via python scripts/run_experiments.py. Each experiment trains a model on a dataset using the CLI under the hood. Results save to runs/{timestamp}-{model}-{dataset}/ with checkpoints (top 3 by val_loss), training plots, and test evaluation (confusion matrix, classification report).

Default Training Parameters

Parameter Value
Epochs 50
Batch size 32
Learning rate 0.001
Optimizer Adam
LR scheduler ReduceLROnPlateau (factor=0.5, patience=5)
Early stopping patience 10
Validation split 0.2
Test split 0.1
Seed 42

References

Datasets

  1. af-classification — Clifford GD, Liu C, Moody B, Li-wei HL, Silva I, Li Q, Johnson AE, Mark RG. "AF Classification from a Short Single Lead ECG Recording: The PhysioNet/Computing in Cardiology Challenge 2017." Computing in Cardiology (CinC), 2017. [PhysioNet]

  2. ptbxl — Wagner P, Strodthoff N, Bousseljot RD, Kreiseler D, Lunze FI, Samek W, Schaeffter T. "PTB-XL, a Large Publicly Available Electrocardiography Dataset." Scientific Data, 7(1):154, 2020. [PhysioNet]

  3. mitbih-afdb — Moody GB, Mark RG. "A New Method for Detecting Atrial Fibrillation Using R-R Intervals." Computers in Cardiology, 10:227–230, 1983. [PhysioNet]

  4. ltafdb — Petrutiu S, Sahakian AV, Swiryn S. "Abrupt Changes in Fibrillatory Wave Characteristics at the Termination of Paroxysmal Atrial Fibrillation in Humans." Europace, 9(7):466–470, 2007. [PhysioNet]

  5. unified-af — Combined cross-dataset using af-classification, mitbih-afdb, and ltafdb (see references above).

Models

  1. convnext-v2 — Woo S, Debnath S, Hu R, Chen X, Liu Z, Kweon IS, Xie S. "ConvNeXt V2: Co-designing and Scaling ConvNets with Masked Autoencoders." CVPR, 2023. [GitHub]

  2. deep-res-cnn — Elyamani H. "ECG Classification Using Deep Residual CNN." 2022. [GitHub]

  3. inception-time — Fawaz HI, Lucas B, Forestier G, Pelletier C, Schmidt DF, Weber J, Webb GI, Idoumghar L, Muller PA, Petitjean F. "InceptionTime: Finding AlexNet for Time Series Classification." Data Mining and Knowledge Discovery, 34:1936–1962, 2020. [GitHub]

  4. mamba — Gu A, Dao T. "Mamba: Linear-Time Sequence Modeling with Selective State Spaces." arXiv:2312.00752, 2023. [GitHub]

  5. medformer — Wang N, Liang X, Wang Z, Zhao J, Liu Y, Peng L, Miao C. "MedFormer: A Multi-Granularity Patching Transformer for Medical Time-Series Classification." NeurIPS, 2024. [GitHub]

  6. xresnet / xresnet1d-benchmark — Strodthoff N, Wagner P, Schaeffter T, Samek W. "Deep Learning for ECG Analysis: Benchmarks and Insights from PTB-XL." IEEE Journal of Biomedical and Health Informatics, 25(5):1519–1528, 2021. [GitHub]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deepecgkit-0.1.0.tar.gz (90.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

deepecgkit-0.1.0-py3-none-any.whl (102.7 kB view details)

Uploaded Python 3

File details

Details for the file deepecgkit-0.1.0.tar.gz.

File metadata

  • Download URL: deepecgkit-0.1.0.tar.gz
  • Upload date:
  • Size: 90.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.8

File hashes

Hashes for deepecgkit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6018d5f01aca7aa959ba5595b5436d97097a55b4c7b224337e3a0566021d7d3e
MD5 5be654c4af9287c621fa664a6d5ecd9f
BLAKE2b-256 6b2488e04dfb5fed5e14e321845e932b513093d0b3c8bf0796de8d0cdebf0d19

See more details on using hashes here.

File details

Details for the file deepecgkit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: deepecgkit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 102.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.8

File hashes

Hashes for deepecgkit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6379022e0c957885af1bdca4fff69b39430aaf73db5a88432482f836be9dbf1e
MD5 9986f6e76b4c9cfbbd5364ff378016d1
BLAKE2b-256 89d00d07465783a385e12f7d136c87a78692354e2819cfc1b94eedbd0ab9d3f8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page