Skip to content

Commit 8ed084b

Browse files
authored
Merge pull request #11 from wfdb/bg_header_example
Improve and update `.hea` example
2 parents f0a86d1 + 471a9f2 commit 8ed084b

1 file changed

Lines changed: 62 additions & 7 deletions

File tree

spec/header-files.md

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,52 @@ A header file contains:
2121

2222
Each line must be under 255 characters, and fields are separated by spaces or tabs (except where otherwise noted).
2323

24+
Detailed documentation on header files can be found at: [https://physionet.org/physiotools/wag/header-5.htm](https://physionet.org/physiotools/wag/header-5.htm)
25+
2426
---
2527

2628
## Record Line
2729

2830
The first non-comment line is the **record line**, which provides metadata about the overall record. It includes:
2931

3032
| Field | Description |
31-
|:------|:------------|
33+
|:------|:-----------|
3234
| Record name | Identifier for the record (letters, digits, underscores only). |
3335
| Number of segments (optional) | If present, appended as `/n`. Indicates a multi-segment record. |
3436
| Number of signals | Number of signals described in the header. |
3537
| Sampling frequency (optional) | Samples per second per signal. Defaults to 250 if omitted. |
3638
| Counter frequency (optional) | Secondary clock frequency, separated from sampling frequency by a `/`. |
3739
| Base counter value (optional) | Offset value for counter, enclosed in parentheses. |
38-
| Number of samples (optional) | Total samples per signal. |
40+
| Number of samples (optional) | Total samples per signal when `samps_per_frame`=1; total frames otherwise. |
3941
| Base time (optional) | Start time of the recording (`HH:MM:SS`). |
4042
| Base date (optional) | Start date (`DD/MM/YYYY`). |
4143

42-
**Example:**
44+
### Examples
45+
46+
**Basic header (uniform sampling frequency):**
47+
record 100 from the [MIT-BIH database](https://www.physionet.org/content/mitdb)
48+
```text
49+
100 2 360 650000
50+
```
51+
52+
- `100`: Record name (must match the filename prefix).
53+
- `2`: Number of signals in the record.
54+
- `360`: Sampling frequency in Hz.
55+
- `650000`: Number of samples for each signal.
56+
57+
**Multi-frequency header (unique sampling rates per channel):**
58+
4359
```text
44-
100 2 360 650000 12:00:00 01/01/2000
60+
12345 3 62.5 625 12:00:00 30/01/1989
4561
```
4662

63+
- `12345`: Record name (must match the filename prefix).
64+
- `3`: Number of signals in the record.
65+
- `62.5`: Sampling frequency in Hz.
66+
- `625`: Number of samples. For multi-frequency records this is the total frames for each signal.
67+
- `12:00:00`: Base time.
68+
- `30/01/1989`: Base date.
69+
4770
---
4871

4972
## Signal Specification Lines
@@ -67,12 +90,43 @@ Each signal has its own line immediately following the record line (for single-s
6790
| Block size (optional) | Number of samples per block (for formats supporting block I/O). |
6891
| Description (optional) | Free-text description of the signal (e.g., lead name `ECG Lead II`). |
6992

70-
**Example:**
93+
### Examples
94+
95+
**Basic header (uniform sampling frequency):**
96+
record 100 from the [MIT-BIH database](https://www.physionet.org/content/mitdb)
7197
```text
72-
100.dat 212 200 11 1024 995 0 MLII
73-
100.dat 212 200 11 1024 995 0 V5
98+
100.dat 212 200 11 1024 995 -22131 0 MLII
99+
100.dat 212 200 11 1024 1011 20052 0 V5
74100
```
75101

102+
- `100.dat`: File name of the signal file.
103+
- `212`: Format samples are stored in (12-bit two's complement).
104+
- `200`: ADC gain (i.e. number of digital values per physical unit).
105+
- `11`: ADC resolution (bits).
106+
- `1024`: ADC zero value.
107+
- `995`, `1011`: Initial value.
108+
- `-22131`, `20052`: Checksum (sum of all signal samples modulo 2^16).
109+
- `0`: Block size.
110+
- `MLII`, `V5`: Description (e.g., signal lead names).
111+
112+
**Multi-frequency header (unique sampling rates per channel):**
113+
```text
114+
12345.dat 16x4 200/μV 12 0 0 2178 0 ECG
115+
12345.dat 16x2 16/mmHg 12 0 0 3497 0 ICP
116+
12345.dat 16x1 2500/Ohm 12 0 0 1366 0 RESP
117+
```
118+
119+
- `12345.dat`: File name of the signal file.
120+
- `16`: Format samples are stored in (16-bit integers).
121+
- `x4`,`x2`,`x1`: 4, 2, and 1 samples per frame, respectively. This indicates that the ECG signal has `157 * 4 = 628` samples while the ICP signal has 314 samples and the RESP signal has 157 samples.
122+
- `200/μV`, `16/mmHg`, `2500/Ohm`: ADC gain (i.e., number of digital values per physical unit).
123+
- `12`: ADC resolution (bits).
124+
- `0`: ADC zero value.
125+
- `0`: Initial value.
126+
- `2178 `, `3497`, `1366`: Checksum (sum of all signal samples modulo 2^16).
127+
- `0`: Block size.
128+
- `ECG`, `ICP`, `RESP`: Description (e.g., signal lead names).
129+
76130
---
77131

78132
## Comments and Info Strings
@@ -87,4 +141,5 @@ Each signal has its own line immediately following the record line (for single-s
87141

88142
- A header file may describe signals stored in multiple files or multiple signals in a single file.
89143
- Fields like sampling frequency, counter frequency, and base time/date improve time-aligned analysis but are optional.
144+
- Storage format options and details can be found at: [https://physionet.org/physiotools/wag/signal-5.htm](https://physionet.org/physiotools/wag/signal-5.htm)
90145
- Multi-segment records use a slightly different structure (described separately).

0 commit comments

Comments
 (0)