edfrw.reader

Tools for reading data from European Data Format (EDF) files.

EdfReader(filename)

Bases: object

Open an EDF file for reading.

Attributes:

Name Type Description
header object of `class::EdfHeader`

EDF file header.

filename str

Path to edf file.

signals list

List of signals in EDF file.

duration_s number

Duration of the recording in seconds.

Notes

This class currently only works for reading EDF files. Data from EDF+C files can also be read but the “EDF Annotations” signal will not be properly parsed. EDF+D files are not supported.

Open and EDF file for reading.

Parameters:

Name Type Description Default
filename str

Path to the EDF file.

required

close()

Close the file.

read_record(rec_number)

Return data from one record.

Parameters:

Name Type Description Default
rec_number integer

Record number to read data from (index starts from 0).

required

Returns:

Name Type Description
samples array of int16

Data samples in record, in the original order and format as that stored in the EDF file (i.e. all samples from signal 0 followed by all samples from signal 1, etc.)

read_signal(signal, from_second=0, to_second=np.Inf)

Read a signal from an EDF file.

Parameters:

Name Type Description Default
signal integer or string

Signal to read. If an integer, it is the signal index (starting from 0); if a string it is the name (label) of the signal.

required
from_second numeric, default

Time in seconds to read data from.

0
to_second numeric, default

Time in seconds to read data to.

np.Inf

Returns:

Type Description
time, samples

Time (in seconds) and signal data samples.

Examples:

>>> edffile = EdfReader("myfile.edf")

Assuming this file has a signal labelled “ADC”, read that signal from time 20 to time 750 seconds.

>>> time, samples = edffile.read_signal("ADC", 20, 750)

read_signal_from_record(sig_number, rec_number)

Read a signal in a data record.

Parameters:

Name Type Description Default
sig_number int

Number of the signal to read (starts from 0).

required
rec_number int

Record number (starts from 0).

required

Returns:

Type Description
time, samples

Time in seconds and signal data samples.

header_fromfile(filename)

Read the header from an EDF file.

Parameters:

Name Type Description Default
filename str

Path to the EDF file

required

Returns:

Name Type Description
header object of