Health and Fitness

Looking at PhysioNet ECG Records: WFDB Files for Students

How WFDB records store ECG signals and annotations, what ECG paper settings mean, and a worked look at a two-lead test record. For education only.

Saizul Amin
Saizul Amin20 Nov 2026 · 4 min read
Looking at PhysioNet ECG Records: WFDB Files for Students

Looking at PhysioNet ECG Records: WFDB Files for Students

PhysioNet hosts some of the most used physiological recordings in research and teaching, including the MIT-BIH Arrhythmia Database. Most of them are stored in the WFDB format, which splits one record into several small files. Knowing how those files fit together makes it much easier to use the data in a course or a project. This article is for learning about the file format and the display; it is not about interpreting anyone's heart rhythm.

The files in a record

A record called 100 usually comes as 100.hea, 100.dat and 100.atr.

  • The .hea header is plain text. Its first line gives the record name, the number of signals, the sampling frequency and the number of samples. Each following line describes one signal: the file it lives in, the storage format, the gain in ADC units per millivolt, the baseline, the resolution and a description such as MLII or V1.
  • The .dat file holds the samples, interleaved frame by frame. Format 212, common in older databases, packs two 12-bit samples into three bytes. Format 16 is plain 16-bit little-endian.
  • The .atr file holds annotations in MIT format: a sample number and a code for each label, such as N for a normal beat or V for a premature ventricular contraction, plus optional text.

To turn a stored number into millivolts, subtract the baseline and divide by the gain.

ECG paper

Printed ECGs use a standard grid. At 25 mm/s and 10 mm/mV, one small square is 0.04 s wide and 0.1 mV tall, and a large square of five small ones is 0.2 s by 0.5 mV. Doubling the speed to 50 mm/s spreads the waves out, which helps when reading short intervals. The WFDB ECG Record Viewer draws the leads on such a grid, scaled to the width of your screen, with paper speed, gain and window length you can change.

Worked example: a test record

To check the reader, the tool writes and reads back its own record. It has two leads, II and V1, sampled at 250 Hz for 1,000 samples, which is 4 seconds. The header lines read "test.dat 16 200/mV", meaning format 16 and 200 ADC units per millivolt. Lead II is a sine wave of amplitude 1 mV, so its peak is stored as the number 200 and displayed as 1.000 mV. The .dat file is 4,000 bytes: 1,000 frames of two 2-byte samples.

A test annotation file holds three labels: N at sample 100, V at sample 2000 with the text "(B", and N at sample 2250. The viewer counts 3 beats. The gap from 100 to 2000 is 7.6 seconds, longer than the 3-second limit for an RR interval, so it is skipped. The gap from 2000 to 2250 is 250 samples, exactly 1.0 second, which is 60 beats per minute, so the mean, lowest and highest rate all read 60 bpm. The table of labels shows N twice and V once.

The format 212 decoder can be checked by hand too. The three bytes 100, 0xF0 and 0x38 hold two samples: the first is 100 plus the low four bits of the middle byte shifted up, which is 100; the second is 0x38 plus the high four bits shifted up, 0xF38, which as a signed 12-bit number is −200.

Exporting for analysis

For a signal processing assignment, CSV of the window or the whole record gives time and every lead in millivolts, ready for Python, MATLAB or a spreadsheet. Annotations CSV lists each label with its sample, time and meaning, which makes a simple ground truth for testing a beat detector.

Common mistakes

  • Selecting only the .dat file. The header is needed to know the format, gain and number of signals.
  • Mixing up samples and seconds. Divide sample numbers by the sampling frequency: sample 2250 at 250 Hz is 9 seconds.
  • Forgetting the baseline. Raw numbers are not millivolts until the baseline is subtracted and the gain divided out.
  • Reading meaning into the picture. The viewer shows stored labels; it does not detect or judge rhythms.
  • Assuming every database uses 212. Newer records use other formats, and the viewer reads 212, 16, 61, 80, 310 and 311.

A word on use

The viewer is for education and research with public datasets. It is not a medical device and is not for diagnosis. Anyone worried about their own heart should speak to a doctor rather than look at a trace on a website.

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages