File size: 7,025 Bytes
8073b02 1df41ae 8073b02 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | ---
language:
- en
license: cc-by-4.0
size_categories:
- n<1K
task_categories:
- other
pretty_name: CODE-test
tags:
- ecg
- electrocardiogram
- biosignals
- time-series
- medical
- ecg-classification
configs:
- config_name: default
data_files:
- split: test
path: data/train-*
---
<h1 align="center">CODE-test: An Annotated 12-Lead ECG Dataset</h1>
<p align="center"><video controls autoplay loop muted playsinline width="900" poster="https://huggingface.co/datasets/dronefreak/CODE-test/resolve/main/assets/demo_banner_poster.jpg" src="https://huggingface.co/datasets/dronefreak/CODE-test/resolve/main/assets/demo_banner.mp4"><img src="https://huggingface.co/datasets/dronefreak/CODE-test/resolve/main/assets/demo_banner_poster.jpg" alt="Six ECG traces, one per labeled abnormality, sweeping across the screen" width="900"></video></p>






> **Unofficial mirror of CODE-test: 827 12-lead ECGs with labels from cardiologists, residents, medical students and a neural network, in a viewer-ready Parquet layout with exact signal values.**
## Dataset Description
- **Homepage:** https://zenodo.org/records/3765780
- **Paper:** https://doi.org/10.1038/s41467-020-15432-4
- **Code:** https://github.com/antonior92/automatic-ecg-diagnosis
- **License:** CC BY 4.0
## Disclaimer
This repository is **not** an official release of CODE-test.
CODE-test was created by Antônio H. Ribeiro, Manoel Horta Ribeiro, Gabriela M. M. Paixão, Derick M. Oliveira, Paulo R. Gomes, Jéssica A. Canazart, Milton P. S. Ferreira, Carl R. Andersson, Peter W. Macfarlane, Wagner Meira Jr., Thomas B. Schön and Antonio Luiz P. Ribeiro. This repository does **not** claim ownership of the data. **If you are an author or rights holder and want this repository changed or removed, please open a discussion and it will be addressed promptly.**
These are records from real patients. Do not attempt to identify anyone in them. This dataset is for research and is not a medical device or a basis for clinical decisions.
**Source and verification:** built from Zenodo record 3765780 (v1.0.3), with the download checked against its MD5. Every stored signal was read back from Parquet and compared with the source HDF5 for exact equality.
---
# Dataset Overview
CODE-test is the test set of *Automatic diagnosis of the 12-lead ECG using a deep neural network* (Nature Communications, 2020). Each of the 827 exams comes from a different patient and is labeled for six abnormalities: 1st degree AV block (`1dAVb`), right bundle branch block (`RBBB`), left bundle branch block (`LBBB`), sinus bradycardia (`SB`), atrial fibrillation (`AF`) and sinus tachycardia (`ST`).
---
# Changes from the Official Release
- Packed into Parquet, one row per exam, as a `test` split, matching how the authors use this set.
- Joined the tracings, patient attributes and all annotation files into one table.
- Added `lead_names`, `active_start`, `active_end`, `is_empty` and a rendered 12-lead `preview`.
- The official package is included unchanged at `original/data.zip`.
- No signal values or labels were changed.
---
# Dataset Structure
| Column | Content |
|---|---|
| `exam_index` | row position in the official files, 0 to 826 |
| `age`, `sex` | from `attributes.csv` |
| `lead_names` | **verified** order of the 12 leads in `signal` (see below) |
| `gold_standard` | consensus labels: two cardiologists, with a senior specialist resolving disagreements |
| `cardiologist1`, `cardiologist2` | each cardiologist's labels |
| `cardiology_residents`, `emergency_residents`, `medical_students` | labels from each group |
| `dnn_prediction` | the paper's neural network output, thresholded to 0 or 1 |
| `signal` | `float64`, shape `(12, 4096)` as (lead, sample), 400 Hz |
| `active_start`, `active_end` | first and last sample where any lead is non-zero |
| `is_empty` | true if every sample is zero (no exam here) |
| `preview` | PNG plot of the recorded portion |
### Read before using the signals
- **The documented lead order is wrong for three leads.** The official README lists `DI, DII, DIII, AVR, AVL, AVF, V1..V6`, but the stored order is **`DI, DII, DIII, AVL, AVF, AVR, V1..V6`**. We tested each exam against the standard limb-lead equations: 773 of 827 match this order on all three leads, the remaining 54 are too noisy to classify on at least one lead, and none match the documented order. The signal is unchanged, so use `lead_names`. The sibling datasets SaMi-Trop and CODE-15% do follow the documented order, so reorder these leads before combining them.
- **Many signals are zero-padded, but not all.** The official description says 7 s and 10 s recordings are centered in 4096 samples with zeros. In this file, 253 of 827 exams are non-zero across all 4096 samples, so read `active_start` and `active_end` instead of assuming a duration.
- **The amplitude unit is ambiguous.** The official README says the scale is `1e-4 V` and also says to multiply by 1000 to obtain volts, and these two statements disagree. Values are kept as published and no unit is asserted here.
- **`datasets` NumPy formatting rounds this column.** `with_format("numpy")` returns `float32`. For exact values, use the default format as shown below.
## Usage
```python
# pip install datasets pillow numpy
import numpy as np
from datasets import load_dataset
ds = load_dataset("dronefreak/CODE-test", split="test")
row = ds[0]
signal = np.asarray(row["signal"], dtype=np.float64) # (12, 4096)
recorded = signal[:, row["active_start"]:row["active_end"] + 1]
avr = signal[row["lead_names"].index("AVR")]
labels = row["gold_standard"] # {"1dAVb": 0, "RBBB": 0, ...}
```
---
# Dataset Sources
## Citation
```bibtex
@article{ribeiro_automatic_2020,
title = {Automatic Diagnosis of the 12-Lead {{ECG}} Using a Deep Neural Network},
author = {Ribeiro, Ant{\^o}nio H. and Ribeiro, Manoel Horta and Paix{\~a}o, Gabriela M. M. and Oliveira, Derick M. and Gomes, Paulo R. and Canazart, J{\'e}ssica A. and Ferreira, Milton P. S. and Andersson, Carl R. and Macfarlane, Peter W. and Meira Jr., Wagner and Sch{\"o}n, Thomas B. and Ribeiro, Antonio Luiz P.},
year = {2020},
volume = {11},
number = {1},
pages = {1760},
doi = {10.1038/s41467-020-15432-4},
journal = {Nature Communications}
}
```
---
# License
CODE-test is released by its authors under **Creative Commons Attribution 4.0 International (CC BY 4.0)**. This mirror reformats the data as described above. Please credit the authors and cite the paper.
|