wonambi.ioeeg.edf module

Module reads and writes header and data for EDF data.

class wonambi.ioeeg.edf.Edf(edffile)[source]

Bases: object

Provide class EDF, which can be used to read the header and the data.

Parameters:

edffile (str) – Full path for the EDF file

hdr

header taken from EDF file

Type:

dict

return_dat(chan, begsam, endsam)[source]

Read data from an EDF file.

Reads channel by channel, and adjusts the values by calibration.

Parameters:
  • chan (list of int) – index (indices) of the channels to read

  • begsam (int) – index of the first sample

  • endsam (int) – index of the last sample

Returns:

numpy.ndarray – A 2d matrix, where the first dimension is the channels and the second dimension are the samples.

return_hdr()[source]

Return the header for further use.

Returns:

  • subj_id (str) – subject identification code

  • start_time (datetime) – start time of the dataset

  • s_freq (float) – sampling frequency

  • chan_name (list of str) – list of all the channels

  • n_samples (int) – number of samples in the dataset

  • orig (dict) – additional information taken directly from the header

Notes

EDF+ accepts multiple frequency rates for different channels. Here, we use only the highest sampling frequency (normally used for EEG and MEG signals), and we UPSAMPLE all the other channels.

return_markers()[source]
wonambi.ioeeg.edf.remove_datetime(filename)[source]

Remove datetime from filename by overwriting the date / time info.

Parameters:

filename (Path) – path to edf file

Notes

It modifies the file.

Todo

This function might be part of a large anonymization procedure for edf

wonambi.ioeeg.edf.write_edf(data, filename, subj_id='X X X X', physical_max=1000, physical_min=None)[source]

Export data to FieldTrip.

Parameters:
  • data (instance of ChanTime) – data with only one trial

  • filename (path to file) – file to export to (include ‘.mat’)

  • subj_id (str) – subject id

  • physical_max (int) – values above this parameter will be considered saturated (and also those that are too negative). This parameter defines the precision.

Notes

Data is always recorded as 2 Byte int (which is ‘int16’), so precision is limited. You can control the precision with physical_max. To get the precision:

>>> precision = physical_max / DIGITAL_MAX

where DIGITAL_MAX is 32767.