This section describes functions used to perform reading of a EDF/BDF file.

EDF/BDF file reader edfreader

class pyedflib.EdfReader[source]

Bases: pyedflib._extensions._pyedflib.CyEdfReader

This provides a simple interface to read EDF, EDF+, BDF and BDF+ files.

Attributes:
admincode
annotations_in_file
birthdate
datarecord_duration

datarecord duration in seconds (as a double)

datarecords_in_file

number of data records

equipment
file_duration

file duration in seconds

filetype
gender
handle

edflib internal int handle

patient

patient name?

patient_additional
patientcode
patientname
recording_additional
signals_in_file
startdate_day
startdate_month
startdate_year
starttime_hour
starttime_minute
starttime_second
starttime_subsecond
technician

Methods

close(self) Closes the file handler
file_info_long(self) Returns information about the opened EDF/BDF file
getAdmincode(self) Returns the Admincode.
getBirthdate(self[, string]) Returns the birthdate as string object
getDigitalMaximum(self[, chn]) Returns the maximum digital value of signal edfsignal.
getDigitalMinimum(self[, chn]) Returns the minimum digital value of signal edfsignal.
getEquipment(self) Returns the used Equipment.
getFileDuration(self) Returns the duration of the file in seconds.
getGender(self) Returns the Gender of the patient.
getHeader(self) Returns the file header as dict
getLabel(self, chn) Returns the label (name) of signal chn (“FP1”, “SaO2”, etc.).
getPatientAdditional(self) Returns the additional patientinfo.
getPatientCode(self) Returns the patientcode
getPatientName(self) Returns the patientname
getPhysicalDimension(self, chn) Returns the physical dimension of signal edfsignal (“uV”, “BPM”, “mA”, “Degr.”, etc.)
getPhysicalMaximum(self[, chn]) Returns the maximum physical value of signal edfsignal.
getPhysicalMinimum(self[, chn]) Returns the minimum physical value of signal edfsignal.
getPrefilter(self, chn) Returns the prefilter of signal chn (“HP:0.1Hz”, “LP:75Hz N:50Hz”, etc.)
getRecordingAdditional(self) Returns the additional recordinginfo
getSampleFrequencies(self) Returns samplefrequencies of all signals.
getSampleFrequency(self, chn) Returns the samplefrequency of signal edfsignal.
getSignalHeader(self, chn) Returns the header of one signal as dicts
getSignalHeaders(self) Returns the header of all signals as array of dicts
getSignalLabels(self) Returns all labels (name) (“FP1”, “SaO2”, etc.).
getStartdatetime(self) Returns the date and starttime as datetime object
getTechnician(self) Returns the technicians name
getTransducer(self, chn) Returns the transducer of signal chn (“AgAgCl cup electrodes”, etc.).
make_buffer() utilty function to make a buffer that can hold a single datarecord.
open(file_name, annotations_mode, …)
readAnnotations(self) Annotations from a edf-file
readSignal(self, chn[, start, n, digital]) Returns the physical data of signal chn.
read_digital_signal() read_digital_signal(self, signalnum, start, n, np.ndarray[np.int32_t, ndim=1] sigbuf read @n number of samples from signal number @signum starting at @start into numpy int32 array @sigbuf sigbuf must be at least n long
readsignal() read @n number of samples from signal number @signum starting at @start into numpy float64 array @sigbuf sigbuf must be at least n long
check_open_ok  
digital_max  
digital_min  
file_info  
getNSamples  
load_datarecord  
physical_dimension  
physical_max  
physical_min  
prefilter  
read_annotation  
samplefrequency  
samples_in_datarecord  
samples_in_file  
signal_label  
transducer  
close(self)[source]

Closes the file handler

file_info(self)[source]
file_info_long(self)[source]

Returns information about the opened EDF/BDF file

getAdmincode(self)[source]

Returns the Admincode.

Parameters:
None

Examples

>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> f.getAdmincode()==''
True
>>> f.close()
getBirthdate(self, string=True)[source]

Returns the birthdate as string object

Parameters:
None

Examples

>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> f.getBirthdate()=='30 jun 1969'
True
>>> f.close()
getDigitalMaximum(self, chn=None)[source]

Returns the maximum digital value of signal edfsignal.

Parameters:
chn : int

channel number

Examples

>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> f.getDigitalMaximum(0)
32767
>>> f.close()
getDigitalMinimum(self, chn=None)[source]

Returns the minimum digital value of signal edfsignal.

Parameters:
chn : int

channel number

Examples

>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> f.getDigitalMinimum(0)
-32768
>>> f.close()
getEquipment(self)[source]

Returns the used Equipment.

Parameters:
None

Examples

>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> f.getEquipment()=='test generator'
True
>>> f.close()
getFileDuration(self)[source]

Returns the duration of the file in seconds.

Parameters:
None

Examples

>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> f.getFileDuration()==600
True
>>> f.close()
getGender(self)[source]

Returns the Gender of the patient.

Parameters:
None

Examples

>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> f.getGender()==''
True
>>> f.close()
getHeader(self)[source]

Returns the file header as dict

Parameters:
None
getLabel(self, chn)[source]

Returns the label (name) of signal chn (“FP1”, “SaO2”, etc.).

Parameters:
chn : int

channel number

Examples

>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> f.getLabel(0)=='squarewave'
True
>>> f.close()
getNSamples(self)[source]
getPatientAdditional(self)[source]

Returns the additional patientinfo.

Parameters:
None

Examples

>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> f.getPatientAdditional()==''
True
>>> f.close()
getPatientCode(self)[source]

Returns the patientcode

Parameters:
None

Examples

>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> f.getPatientCode()==''
True
>>> f.close()
getPatientName(self)[source]

Returns the patientname

Parameters:
None

Examples

>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> f.getPatientName()=='X'
True
>>> f.close()
getPhysicalDimension(self, chn)[source]

Returns the physical dimension of signal edfsignal (“uV”, “BPM”, “mA”, “Degr.”, etc.)

Parameters:
chn : int

channel number

Examples

>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> f.getPhysicalDimension(0)=='uV'
True
>>> f.close()
getPhysicalMaximum(self, chn=None)[source]

Returns the maximum physical value of signal edfsignal.

Parameters:
chn : int

channel number

Examples

>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> f.getPhysicalMaximum(0)==1000.0
True
>>> f.close()
getPhysicalMinimum(self, chn=None)[source]

Returns the minimum physical value of signal edfsignal.

Parameters:
chn : int

channel number

Examples

>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> f.getPhysicalMinimum(0)==-1000.0
True
>>> f.close()
getPrefilter(self, chn)[source]

Returns the prefilter of signal chn (“HP:0.1Hz”, “LP:75Hz N:50Hz”, etc.)

Parameters:
chn : int

channel number

Examples

>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> f.getPrefilter(0)==''
True
>>> f.close()
getRecordingAdditional(self)[source]

Returns the additional recordinginfo

Parameters:
None

Examples

>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> f.getRecordingAdditional()==''
True
>>> f.close()
getSampleFrequencies(self)[source]

Returns samplefrequencies of all signals.

Parameters:
None

Examples

>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> all(f.getSampleFrequencies()==200.0)
True
>>> f.close()
getSampleFrequency(self, chn)[source]

Returns the samplefrequency of signal edfsignal.

Parameters:
chn : int

channel number

Examples

>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> f.getSampleFrequency(0)==200.0
True
>>> f.close()
getSignalHeader(self, chn)[source]

Returns the header of one signal as dicts

Parameters:
None
getSignalHeaders(self)[source]

Returns the header of all signals as array of dicts

Parameters:
None
getSignalLabels(self)[source]

Returns all labels (name) (“FP1”, “SaO2”, etc.).

Parameters:
None

Examples

>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> f.getSignalLabels()==['squarewave', 'ramp', 'pulse', 'noise', 'sine 1 Hz', 'sine 8 Hz', 'sine 8.1777 Hz', 'sine 8.5 Hz', 'sine 15 Hz', 'sine 17 Hz', 'sine 50 Hz']
True
>>> f.close()
getStartdatetime(self)[source]

Returns the date and starttime as datetime object

Parameters:
None

Examples

>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> f.getStartdatetime()
datetime.datetime(2011, 4, 4, 12, 57, 2)
>>> f.close()
getTechnician(self)[source]

Returns the technicians name

Parameters:
None
.. code-block:: python
>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> f.getTechnician()==''
True
>>> f.close()
getTransducer(self, chn)[source]

Returns the transducer of signal chn (“AgAgCl cup electrodes”, etc.).

Parameters:
chn : int

channel number

Examples

>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> f.getTransducer(0)==''
True
>>> f.close()
readAnnotations(self)[source]

Annotations from a edf-file

Parameters:
None
readSignal(self, chn, start=0, n=None, digital=False)[source]

Returns the physical data of signal chn. When start and n is set, a subset is returned

Parameters:
chn : int

channel number

start : int

start pointer (default is 0)

n : int

length of data to read (default is None, by which the complete data of the channel are returned)

digital: bool

will return the signal in original digital values instead of physical values

Examples
——–
>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> x = f.readSignal(0,0,1000)
>>> int(x.shape[0])
1000
>>> x2 = f.readSignal(0)
>>> int(x2.shape[0])
120000
>>> f.close()