kritikabme/ecg-arrhythmia-analysis
0
ECG Arrhythmia Analysis System
Kritika Patidar · SGSITS Indore · B.Tech Biomedical Engineering
Research-grade pipeline: Pan-Tompkins QRS detection → HRV analysis → 1D-CNN arrhythmia classification Dataset: MIT-BIH Arrhythmia Database (PhysioNet) | Classes: Normal · PVC · LBBB · RBBB
Project Structure
ecg-arrhythmia-system/
├── notebooks/
│ └── ECG_Arrhythmia_Analysis.ipynb ← Full research notebook (run first)
├── app/
│ ├── app.py ← Gradio deployment
│ ├── model.py ← ECGResNet1D architecture
│ ├── preprocessing.py ← Pan-Tompkins + HRV + utilities
│ ├── requirements.txt ← Dependencies
│ ├── README.md ← HF Spaces card
│ └── ecg_model.pth ← Trained weights (generated by notebook)
└── README.md ← This fileQuickstart (Windows, Python 3.13)
1. Install dependencies
"C:\Program Files\Python313\python.exe" -m pip install -r app\requirements.txt2. Run the research notebook
Open notebooks/ECG_Arrhythmia_Analysis.ipynb in Jupyter:
"C:\Program Files\Python313\python.exe" -m pip install jupyter
"C:\Program Files\Python313\python.exe" -m jupyter notebook notebooks\The notebook will:
- Download MIT-BIH records from PhysioNet (first run only, ~300 MB cached)
- Run Pan-Tompkins QRS detection
- Compute HRV metrics
- Train ECGResNet1D (~50 epochs, ~20 min on CPU / ~3 min on GPU)
- Export
app/ecg_model.pth
3. Run Gradio app locally
cd app
"C:\Program Files\Python313\python.exe" app.pyOpen http://localhost:7860
Deploy to HuggingFace Spaces (Never sleeps)
Step 1 — Create a new Space
- Go to https://huggingface.co/new-space
- Space name:
ecg-arrhythmia-analysis - SDK: Gradio
- Hardware: CPU Basic (free tier, no sleeping on Spaces)
- Visibility: Public
Step 2 — Upload files
# Clone your new space locally
git clone https://huggingface.co/spaces/<YOUR_HF_USERNAME>/ecg-arrhythmia-analysis
cd ecg-arrhythmia-analysis
# Copy the app files
cp ../ecg-arrhythmia-system/app/* .
# If you have trained weights, add them:
# cp ../ecg-arrhythmia-system/app/ecg_model.pth .
# For large model files (>100 MB), use Git LFS:
# git lfs install
# git lfs track "*.pth"
git add .
git commit -m "Initial deployment: ECG arrhythmia analysis system"
git pushStep 3 — Verify
- Space URL:
https://huggingface.co/spaces/<YOUR_HF_USERNAME>/ecg-arrhythmia-analysis - HF Spaces never sleep (unlike Streamlit Community Cloud)
- Build logs: Space page → "App" tab → "Logs"
Security on HuggingFace Spaces
HF Spaces runs in an isolated container:
- No API keys needed (wfdb streams PhysioNet openly)
- Input validation is handled in
app.py(file size, format, signal length) - No user data is stored (all processing is in-memory per request)
.gitignoretheecg_model.pthfrom public repos if it contains sensitive data
Notebook Outputs (Figures)
Model Performance (typical MIT-BIH results)
Results vary with train/test split and random seed.
IEEE Paper Template
@article{patidar2025ecg,
title = {ECG Arrhythmia Classification Using 1D Residual CNNs
with Pan-Tompkins QRS Detection and HRV Analysis
on the MIT-BIH Arrhythmia Database},
author = {Patidar, Kritika},
journal = {IEEE Transactions on Biomedical Engineering},
year = {2025},
note = {Preprint — SGSITS Indore}
}Target conferences / journals:
- IEEE EMBC (Engineering in Medicine and Biology Conference)
- IEEE Transactions on Biomedical Engineering
- Computers in Biology and Medicine (Elsevier)
- Biomedical Signal Processing and Control (Elsevier)
References
- Pan J, Tompkins WJ. A Real-Time QRS Detection Algorithm. IEEE Trans Biomed Eng. 1985;32(3):230–236.
- Task Force of ESC/NASPE. Heart Rate Variability: Standards of Measurement, Physiological Interpretation and Clinical Use. Circulation. 1996;93(5):1043–1065.
- Moody GB, Mark RG. The Impact of the MIT-BIH Arrhythmia Database. IEEE Eng Med Biol. 2001;20(3):45–50.
- He K, Zhang X, Ren S, Sun J. Deep Residual Learning for Image Recognition. CVPR. 2016.
- Selvaraju RR et al. Grad-CAM: Visual Explanations from Deep Networks via Gradient-based Localization. ICCV. 2017.
- Loshchilov I, Hutter F. Decoupled Weight Decay Regularization. ICLR. 2019.
⚠️ Disclaimer: This system is for research purposes only and is not intended for clinical diagnosis or medical decision-making.
