Downloads · 30 days
0
ahczhg/ecg-mamba-improved
ecg-mamba-improved is a machine learning model from ahczhg. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
[](https://opensource.org/licenses/MIT) [](https://www.python.org/downloads/) [](https://pytorch.org/)
Downloads · 30 days
0
Access
Public
Updated Nov 25, 2025
Repo size
—
Likes
2
Public
Click a slice to open those files.
.ipynb1.6 MB · 99%
From the Hugging Face model README
A comprehensive comparison of baseline and improved ECG-Mamba architectures for cardiac abnormality classification using 12-lead ECG signals.
This project implements and compares two ECG-Mamba architectures for cardiac abnormality detection:
The Improved ECG-Mamba model introduces three critical enhancements:
| Feature | Baseline ECG-Mamba | Improved ECG-Mamba |
|---|---|---|
| Processing | Unidirectional | Bi-directional |
| Architecture | Single branch | 4-branch multi-lead |
| Attention | None | Transformer layer |
| Lead Grouping | No | Yes (anatomical) |
| Context | Forward only | Forward + Backward |
python >= 3.8
torch >= 2.0.0
numpy >= 1.21.0
pandas >= 1.3.0
scikit-learn >= 1.0.0
matplotlib >= 3.4.0
seaborn >= 0.11.0
wfdb >= 4.0.0
tqdm >= 4.62.0
causal-conv1d >= 1.2.0
mamba-ssm >= 1.0.0
Note: If Mamba-SSM is not available (no GPU), the code automatically falls back to LSTM implementation.
git clone https://github.com/YOUR_USERNAME/ecg-mamba-improved.git
cd ecg-mamba-improved
pip install -r requirements.txt
pip install causal-conv1d>=1.2.0
pip install mamba-ssm
jupyter notebook ECG_Mamba_Improved_Comparison.ipynb
Input (batch, 1000, 12)
↓
Embedding (12 → d_model)
↓
4x Mamba Layers (unidirectional)
↓
Global Average Pooling
↓
LayerNorm + Classifier
↓
Output (batch, n_classes)
Input (batch, 1000, 12)
↓
Split into 4 lead groups (3 leads each)
↓
4x Lead-Specific Branches (each with BiMamba)
├─ Limb Standard (I, II, III)
├─ Limb Augmented (aVR, aVL, aVF)
├─ Chest Anterior (V1, V2, V3)
└─ Chest Lateral (V4, V5, V6)
↓
Lead Fusion Module (attention-weighted)
↓
Shared Bi-Directional Mamba
↓
Transformer Attention Block
↓
Global Average Pooling
↓
LayerNorm + Classifier
↓
Output (batch, n_classes)
The notebook trains both models sequentially and provides:
The Improved ECG-Mamba model demonstrates significant improvements over the baseline:
The notebook generates:
This work is based on:
ECG-Mamba: Cardiac Abnormality Classification With Non-Uniform-Mix Augmentation on 12-Lead ECGs
IEEE Journal of Translational Engineering in Health and Medicine (JTEHM), 2025
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
For questions or issues, please open an issue on GitHub.
This project is for research and educational purposes only. It is not intended for clinical diagnosis or medical decision-making. Always consult qualified healthcare professionals for medical advice.