How to read: H5 file

Jonathan
Written by Jonathan
Last update
The h5 format is a convenient format to store time series data. Libraries from several programming
languages provide tools to read/edit these file. In this documentation we only cover python. In python,
h5py handles reading and writing h5 files.
 

Reading a file

In a python console
import
h5py
h5 = h5py.File(
'path/to/file.h5'
)
The file contains few meta data:
 
>>
> list(h5.attrs)
['description'
'dreem_data_version'
'hardware'
'start_time'
'stop_time'
'timezone'
'version_algo'
'version_m4'
'version_mcu'
'version_mpu'
'version_system']
 
The most importants are:
description: the list of the available signals in the file.
start_time: the UTC timestamp in seconds when the record was started
stop_time: the UTC timestamp in seconds when the record was stopped
timezone: the timezone of the user (based on the last timezone of the mobile app the headband
was connected to)
hardware and version: various meta data regarding the version of the Dreem device used.
The description can be red like this:
 
>>> import json
>>> json.loads(h5.attrs['description'])
[{'name':'RAW1 F7-O1',
'domain':'RAW',
'fs':250,
'path':'eeg1/raw',
'default':False},
{'name':'CH1 F7-O1',
'domain':'EEG',
'fs':250,
'path':'eeg1/filtered',
'default':True},
{'name':'RAW2 F8-O2',
'domain':'RAW',
'fs':250,
'path':'eeg2/raw',
'default':False},
 
It lists the available time series that can be used for analysis.
 

Signals specifications

EEG

Raw

Raw output of the Dreem headband Sampled at 250Hz on 4 bytes.

Filtered

Raw eeg filtered using a bandpass butterworth order 2 between 0.4Hz and 35Hz. 3 additionnal notch filters are added to remove 50Hz and 60Hz electrical noises, and 62,5Hz to remove optionnal impedance injection (deactivated by default) noises.

Accelerometer

Raw

Raw output of the Dreem headband Sampled at 50 on 4 bytes.

Filtered

Raw accelerometer filtered using an order 4 bandpass butterworth between 0.1Hz and 0.5 Hz. This frequency range is used to observe respiration.

Accelerometer Norm

Norm of the raw output as square_root(x ^ 2 + y ^ 2 + z ^ 2)

Pulse oximeter (dreem2 only)

Raw

Raw output of the Dreem headband Sampled at 50 on 4 bytes.

Filtered

Raw pulse oximeter filtered using an order 4 highpass butterworth filter to remove low frequencies below 0.5Hz.