Raw Files
The high-rate signals of the 287-2B (PPG2, accelerometer, BioZ) are not stored as rows in the SDK's database. The SDK writes the bytes it downloads from the bracelet, unchanged, to .wiff files on the phone.
This page describes the binary layout of those files, for when you read them outside the SDK, for example on your server.
| What you want to do | Where to look |
|---|---|
| Get the files onto the phone and export them | Raw File Transfer & Export |
| Decode PPG2 and accelerometer files into samples in your app | Parsing Raw Files: the SDK has the parsers Ppg2WiffParser and AccWiffParser |
| Decode the files yourself | This page |
The SDK has no parser for BioZ files. For those, use the layout below.
General header and PPG2
Multi-color PPG file (PPG2)
This file contains a header and a body section. Both are made of records. Every record starts with 3 bytes with the predefined values 0x4F, 0x48, 0x52.
All numbers of more than one byte are little-endian: the least significant byte comes first.
Record Format
| Part | Bytes | Content |
|---|---|---|
| Sync pattern | 3 | [S0] [S1] [S2], fixed values [0x4F] [0x48] [0x52]: ASCII "OHR" |
| Length | 2 | [Llsb] [Lmsb]: the number of bytes that follow in this record, the ID included |
| ID | 1 | [ID]: the type of the record |
| Payload | Length − 1 | [P0] .. [PLength-2]: the data |
A record has no checksum. To check that a record is complete, look for the next sync pattern, or the end of the file, directly after its payload. The SDK's parsers do the same: when the pattern is not there, they drop the record and search for the next "OHR".
The record IDs:
| ID | Record |
|---|---|
| 0x0A | Time-size header |
| 0x0B | Version header |
| 0x0C | Host version header |
| 0x0F | Measurements |
The header
The header contains 3 records:
Time-size header:
- The 3 bytes Sync pattern [0x4F] [0x48] [0x52] => ASCII “OHR”
- Length [Llsb] [Lmsb] Length of the record excluding the first 5 bytes. Normally it is 17 (0x0011).
- ID [ID] = 0x0A
- Payload : p0-p3 : 4 bytes: The size of the file.
- p4-p11: 8 bytes reserved (normally zero).
- p12-p15: start time of the measurement, in seconds since 1970-01-01 UTC (this is the start time of the PPG2 measurement).
Version Header:
- The 3 bytes Sync pattern [0x4F] [0x48] [0x52] => ASCII “OHR”
- Length [Llsb] [Lmsb] Length of the record excluding the first 5 bytes. It is 26 (0x001A).
- ID [ID] = 0x0B
- Payload : p0-p7 : 8 bytes reserved (normally zero).
- p8-p10: 3 bytes, FW version. something like 0, 3, 120
- p11-p24: The name of the product (MMT287-2ph2) followed by 2 zeros at the end.
Host version header
- The 3 bytes Sync pattern [0x4F] [0x48] [0x52] => ASCII “OHR”
- Length [Llsb] [Lmsb] Length of the record excluding the first 5 bytes. It is 32 (0x0020).
- ID [ID] = 0x0C
- Payload : p0-p30 : 31 bytes reserved
The SDK's parsers accept a time-size header at any position in a file, not only at its start, and take its start time as the time of the samples that follow.
The body
The body of the file contains records of measurements. Their record ID is 0x0F.
The payload of a measurements record is a sequence of chunks. Each chunk holds the values of one metric:
| Part | Bytes | Content |
|---|---|---|
| Metric ID | 1 | The metric of the chunk, see the list below |
| Length | 2 | [Llsb] [Lmsb]: the number of bytes that follow in this chunk |
| Data | Length | The values, in the format of the metric |
The metric IDs:
| Metric ID | Metric |
|---|---|
| 0x7E | PPG Green |
| 0x7C | PPG Red |
| 0x7D | PPG Red middle |
| 0x7B | PPG InfraRed |
| 0x7F | PPG Ambient |
| 0x1E | Time |
| 0x2B | Accelerometer, see Accelerometer |
Ppg2WiffParser returns the green, red and infrared samples. It skips the chunks of the red middle and ambient metrics.
Time chunk
A chunk with metric ID 0x1E gives the time of the samples that follow it.
| Part | Bytes | Content |
|---|---|---|
| Index | 1 | The packet index from 0 to 255 |
| Quality | 1 | |
| Time | 4 | Seconds since 1970-01-01 UTC |
Multicolor PPG record
- The 3 bytes Sync pattern [0x4F] [0x48] [0x52] => ASCII “OHR”
- Length [Llsb] [Lmsb] Length of the record excluding the first 5 bytes.
- ID [ID] = 0x0F
- Payload : The payload contains the actual measurements of the PPG channels. Since there are different channels (green, red, IR, ambient), one record may contain more than one chunk. The data of each channel has the format below.
PPG chunk format
-
The Metric ID:
- PPG Green: 0x7E
- PPG Red: 0x7C
- PPG Red middle: 0x7D
- PPG InfraRed: 0x7B
- PPG Ambient: 0x7F
-
For every metric we have the following data:
| Part | Bytes | Content |
|---|---|---|
| Length | 2 | [Llsb] [Lmsb]: length of the metric |
| index | 1 | The packet index from 0 to 255 |
| quality | 1 | 4 |
| BPI | 1 | Body position index |
| PF | 1 | PPG sample format: 0x60 for 32 Hz (the normal value), 0x61 for 64 Hz, 0x62 for 128 Hz, 0x63 for 256 Hz, 0x64 for 512 Hz |
| SI | 1 | Stream locations identifier. bit7 - bit4: Led, bit3 - bit0: Photodiode |
| OFS | 1 | PPG Offset. bit7 – bit0: Offset |
| exp | 1 | 0 |
| Li | 4 | Relative LED power [%] for each quarter of samples (M/4). 0..100: power |
| Gi | 4 | Relative ADC gain used to obtain Pi for each quarter of samples (M/4). 0: gain factor 1x, 1: gain factor 2x, 2: gain factor 4x, 3: gain factor 8x |
| Pi | 2 × M | The PPG samples, 16 bit unsigned each |
A chunk holds one second of samples: M is the sample rate given by PF (32 samples at 32 Hz).
The value of a sample. The SDK's parser, like Corsano's reference parser, computes the PPG value of a sample as:
value = Pi + Gi * 32768 - 16384
where Gi is the gain byte of the quarter of the chunk the sample is in (the first quarter of the samples uses the first byte, and so on). It then corrects a rollover: when the value is about 32768 higher or lower than the previous value of the same channel (a difference between 31768 and 33768), it subtracts or adds 32768. A channel is one metric ID on one SI value.
The time of a sample. A chunk has no time of its own. Start from the start time of the time-size header, or from the last time chunk. Each chunk of a channel then covers the next second, and the samples of a chunk are evenly spaced over it (1000 / M milliseconds apart). The SDK's parser sets the clock of a channel to the time of a time chunk or time-size header only when the two differ by more than 6 seconds.
Accelerometer
Accelerometer File
The accelerometer records have the format of the multi-color PPG records. Only the metric ID and the data of the chunk are different.
- The 3 bytes Sync pattern [0x4F] [0x48] [0x52] => ASCII “OHR”
- Length [Llsb] [Lmsb] Length of the record excluding the first 5 bytes.
- ID [ID] = 0x0F
- Payload : one chunk with the measurements of the 3-axis accelerometer:
| Part | Bytes | Content |
|---|---|---|
| Metric ID | 1 | 0x2B |
| Length | 2 | [Llsb] [Lmsb]: length of the payload |
| index | 1 | The packet index from 0 to 255 |
| quality | 1 | 4 |
| BPI | 1 | Body position index |
| AF | 1 | Acceleration sample format, set to 6E for 32 Hz |
| Samples | 6 × M | <X0,L> <X0,H> <Y0,L> <Y0,H> <Z0,L> <Z0,H>…<XM-1,L> <XM-1,H> <YM-1,L> <YM-1,H> <ZM-1,L> <ZM-1,H> |
where:
- Xi : Acceleration along X axis
- Yi : Acceleration along Y axis
- Zi : Acceleration along Z axis
Each value is a signed 16-bit number. A chunk holds one second: 32 samples, 31.25 ms apart. The file also holds time chunks (metric ID 0x1E, see Time chunk), which give the time of the samples.
See Accelerometer data for the unit of the values.
BioZ
BioZ File
The BioZ file contains the skin conductance data of the user.
The format of the BioZ records is exactly like the one of the multi-color PPG records; only the metric ID is different, as mentioned below.
- The 3 bytes Sync pattern [0x4F] [0x48] [0x52] => ASCII “OHR”
- Length [Llsb] [Lmsb] Length of the record excluding the first 5 bytes.
- ID [ID] = 0x3E
- Payload : The payload contains the actual measurements of the skin conductance, as following:
| Part | Bytes | Content |
|---|---|---|
| Length | 2 | [Llsb] [Lmsb]: length of the payload |
| Index | 1 | An index counter from 0 to 255 |
| quality | 1 | Set to 4 |
| BPI | 1 | Body position index |
| BioZF | 1 | BioZ sample format: 01 for 25 Hz |
| Samples | 3 × 25 | <B0,0> <B0,1><B0,2> <B1,0> <B1,1><B1,2> …<B24,0> <B24,1><B24,2> |
where:
- Bx,0 : Bioz index x the least significant byte (of 24 bits)
- Bx,1 : Bioz index x the byte in the middle (of 24 bits)
- Bx,2 : Bioz index x the most significant byte (of 24 bits)
Script for parsing
The exported files can be parsed using our sample code, available in Python or PHP.
Please request access via our contact page.