ECG Atrial Fibrillation Detection
Deep learning research on detecting atrial fibrillation in 12-lead ECG signals, and how detection behaves as the signal is resampled from 500 Hz down to 62 Hz.
Built with
- Python
- TensorFlow
- PyTorch
- CNN1D
- CNN-LSTM
- Signal processing
- PTB-XL

Overview
Atrial fibrillation is a common cardiac arrhythmia that is often intermittent, which makes it easy to miss in a short clinical recording. Automated detection from the ECG waveform is therefore an active research area — and an area where the practical question is not only can a model detect it, but how much signal does the model actually need.
This research compares two deep learning architectures on the public PTB-XL 12-lead ECG dataset, and studies how their behaviour changes as the recordings are resampled to progressively lower rates.
Problem
Continuous or wearable ECG monitoring is constrained by power, storage and bandwidth, all of which scale with sampling rate. Clinical ECG is typically recorded at 500 Hz, but if a model performs comparably on a much lower-rate signal, the practical cost of long-term monitoring drops substantially.
The open question is where that trade-off actually sits, and whether it is the same for different model families.
Goals
- Implement two architectures with meaningfully different inductive biases: a one-dimensional convolutional network, and a convolutional–recurrent hybrid.
- Evaluate both on the same data, split the same way, across four sampling rates: 500 Hz, 250 Hz, 100 Hz and 62 Hz.
- Keep the preprocessing and training pipeline reproducible so results are attributable to the variable under study rather than to pipeline drift.
My role
The research was carried out as an undergraduate project in Information Technology. My work covered the research design, signal preprocessing, both model implementations, the evaluation harness and the write-up.
Approach
Data. PTB-XL provides 12-lead clinical ECG recordings with diagnostic annotations. Records are labelled for the presence of atrial fibrillation, and split so that no subject appears in more than one partition.
Preprocessing. Recordings are resampled to each target rate, normalised per lead, and segmented into fixed-length windows. The same preprocessing code path is used for every rate, parameterised only by the target frequency, so the sampling rate remains the single varying factor.
Models.
- CNN1D — stacked one-dimensional convolutional blocks that learn local morphological features directly from the raw waveform, followed by pooling and a classification head. It has no explicit notion of long-range time structure.
- CNN-LSTM — the same style of convolutional front end used as a feature extractor, with the resulting sequence passed to recurrent layers. This gives the model an explicit mechanism for temporal dependence across the window, which matters for an arrhythmia defined by rhythm irregularity rather than by a single beat’s shape.
Evaluation. Both architectures are trained and evaluated under identical conditions at each sampling rate, on a held-out split, so architecture and sampling rate can be compared independently.
Key implementation details
- A single parameterised preprocessing pipeline, so a rate change is a configuration change rather than a separate code path.
- Subject-level splitting, to prevent recordings from the same patient appearing in both training and evaluation.
- Deterministic seeding and recorded run configuration so experiments can be repeated.
Challenges
Class imbalance is intrinsic to the dataset — atrial fibrillation records are far outnumbered by normal ones — so accuracy alone is not a meaningful measure and had to be handled both in training and in how results are reported.
Downsampling is also not a neutral operation. Reducing the rate removes high-frequency morphology, and doing it without introducing aliasing artefacts that the model could learn from required care in the resampling step itself.
Outcome
The work is published as a preprint:
Sampling Matters: The Effect of ECG Frequency on Deep Learning-Based Atrial Fibrillation Detection — doi.org/10.48550/arXiv.2604.16437
The CNN-LSTM model performed best and remained consistently calibrated at the intermediate 100–250 Hz sampling rates. The CNN1D baseline lost accuracy and sensitivity at 500 Hz, showing that sampling frequency affected the two model architectures differently.
What I learned
The most useful lesson was methodological: when the variable under study is a property of the data itself, almost all of the engineering effort goes into making sure nothing else varies. The modelling was the smaller half of the work; the pipeline discipline was the larger one.
Related projects
Interested in this kind of work?
Happy to talk through the architecture, the trade-offs or anything that is not covered above.

