Skip to main content

A deep learning toolkit for ECG analysis

Project description

DeepECG-Kit

A pure-PyTorch 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.2.0.tar.gz (92.1 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.2.0-py3-none-any.whl (104.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for deepecgkit-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d2a46d9c043ba591db7105670239233196f3c74e646cc8a4e65fc4a01ae8e8ac
MD5 0abb14da6cc30e7fb7fb4c1ded671679
BLAKE2b-256 75d4ebbcdc1d7e41c6fbad8cae5ca4469cf1617f29341ea4da3aaae94745d37e

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for deepecgkit-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 12931b514a53e55d7422d326ba961d6c54255e29c36f5f5bf3e2f6cf42f16609
MD5 facfe41dc669bd44bf9d78a081388b3a
BLAKE2b-256 3ddd206771840414651d9067c8b5dbd3523f126cfe3d2a03f62b65e911a1f61c

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