| 1 |
# Physiological Waveforms |
| 2 |
Physiological monitoring data such as electrocardiograms, pulse oximetry, or external triggering may accompany MR acquisitions. These physiological data are stored in MRD as a combination of a fixed [WaveformHeader](WaveformHeader) and the [raw physiological waveforms](WaveformData). |
| 3 |
|
| 4 |
(WaveformHeader)= |
| 5 |
## WaveformHeader |
| 6 |
The WaveformHeader contains metadata associated with a set of waveform data and has the following fields: |
| 7 |
| Field | Description | Type | Offset | |
| 8 |
| -- | -- | -- | -- | |
| 9 |
| version | Version number | uint16_t | 0 bytes | |
| 10 |
| flags | Bit field with flags | uint64_t | 8 bytes (not 2!) | |
| 11 |
| measurement_uid | Unique ID for this measurement | uint32_t | 16 bytes | |
| 12 |
| scan_counter | Number of the acquisition after this waveform | uint32_t | 20 bytes | |
| 13 |
| time_stamp | Starting timestamp of this waveform | uint32_t | 24 bytes | |
| 14 |
| number_of_samples | Number of samples acquired | uint16_t | 28 bytes | |
| 15 |
| channels | Active channels | uint16_t | 30 bytes | |
| 16 |
| sample_time_us | Time between samples in microseconds | float | 32 bytes | |
| 17 |
| waveform_id | [ID matching types specified in XML header](WaveformIDs) | uint16_t | 36 bytes | |
| 18 |
| | **Total** | **40 bytes (2 bytes padding at the end!)** | | |
| 19 |
|
| 20 |
A reference implementation for serialization/deserialization of the WaveformHeader can be found in [serialization.cpp](../libsrc/serialization.cpp). |
| 21 |
|
| 22 |
(WaveformIDs)= |
| 23 |
### Waveform IDs |
| 24 |
The ``waveform_id`` field in the WaveformHeader describes the type of physiological data stored. The following ID numbers are standardized: |
| 25 |
| Value | Name | |
| 26 |
| -- | -- | |
| 27 |
| 0 | ECG | |
| 28 |
| 1 | Pulse Oximetry | |
| 29 |
| 2 | Respiratory | |
| 30 |
| 3 | External Waveform 1 | |
| 31 |
| 4 | External Waveform 2 | |
| 32 |
|
| 33 |
For each type of ``waveform_id`` included in the dataset, a corresponding ``WaveformInformation`` entry is found in the MRD header to describe the data interpretation. For example: |
| 34 |
```xml |
| 35 |
<waveformInformation> |
| 36 |
<waveformId>0</waveformName> |
| 37 |
<waveformName>ECG1</waveformName> |
| 38 |
<waveformTriggerChannel>4</waveformTriggerChannel> |
| 39 |
</waveformInformation> |
| 40 |
``` |
| 41 |
|
| 42 |
Physiological data used for triggering may have an associated "trigger" channel as detected by the MR system. The ``waveformTriggerChannel`` indicates the channel index (0-indexed) which contains the detected triggers and is omitted if no trigger data is present. |
| 43 |
|
| 44 |
Waveform ID numbers less than 1024 are reserved while numbers greater than or equal to 1024 can be used to define custom physiological data. For custom waveform_ids, corresponding WaveformInformation entries should be added to the MRD header to describe the data interpretation. For example: |
| 45 |
```xml |
| 46 |
<waveformInformation> |
| 47 |
<waveformId>1024</waveformName> |
| 48 |
<waveformName>CustomName</waveformName> |
| 49 |
</waveformInformation> |
| 50 |
``` |
| 51 |
|
| 52 |
(WaveformData)= |
| 53 |
## Waveform Data |
| 54 |
Waveform data is sent as an uint32_t array, ordered by looping through samples and then through channels: |
| 55 |
<style> |
| 56 |
.smalltable td { |
| 57 |
font-size: 80%; |
| 58 |
border-collapse: collapse; |
| 59 |
border-spacing: 0; |
| 60 |
border-width: 0; |
| 61 |
padding: 3px; |
| 62 |
border: 1px solid lightgray |
| 63 |
} |
| 64 |
</style> |
| 65 |
|
| 66 |
<table class="smalltable"> |
| 67 |
<tr> |
| 68 |
<td style="text-align: center" colspan="3">Channel 1</td> |
| 69 |
<td style="text-align: center" colspan="3">Channel 2</td> |
| 70 |
<td style="text-align: center" rowspan="2">...</td> |
| 71 |
<td style="text-align: center" colspan="3">Channel n</td> |
| 72 |
</tr> |
| 73 |
<tr> |
| 74 |
<td style="text-align: center">w<sub>1</sub></td> |
| 75 |
<td style="text-align: center">...</td> |
| 76 |
<td style="text-align: center">w<sub>n</sub></td> |
| 77 |
<td style="text-align: center">w<sub>1</sub></td> |
| 78 |
<td style="text-align: center">...</td> |
| 79 |
<td style="text-align: center">w<sub>n</sub></td> |
| 80 |
<td style="text-align: center">w<sub>1</sub></td> |
| 81 |
<td style="text-align: center">...</td> |
| 82 |
<td style="text-align: center">w<sub>n</sub></td> |
| 83 |
</tr> |
| 84 |
</table> |