Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read edf data in Python 3

How can I read edf data using Python? I want to analyze data of a edf file, but I cannot read it using pyEDFlib. It threw the error OSError: The file is discontinous and cannot be read and I'm not sure why.

like image 371
Mindy Avatar asked Aug 16 '18 04:08

Mindy


People also ask

How do I read an EDF file?

EDF files are the primary file type associated with Edificius and is only supported by Edificius. You can open an EDF file with Edificius by selecting File → Open. If you receive an EDF file and do not have access to Edificius, you can download and install the trial of Edificius from their website to open the file.

What is EDF in Python?

pyEDFlib is a python library to read/write EDF+/BDF+ files based on EDFlib. EDF means European Data Format and was firstly published Kemp1992. In 2003, an improved version of the file protocol named EDF+ has been published and can be found at Kemp2003. The EDF/EDF+ format saves all data with 16 Bit.

What is an EDF file?

European Data Format (EDF) is a standard file format designed for exchange and storage of medical time series. Being an open and non-proprietary format, EDF(+) is commonly used to archive, exchange and analyse data from commercial devices in a format that is independent of the acquisition system.


1 Answers

I assume that your data are biological time-series like EEG, is this correct? If so, you can use the MNE library.

You have to install it first. Since it is not a standard library, take a look here. Then, you can use the read_raw_edf() method.

For example:

import mne
file = "my_path\\my_file.edf"
data = mne.io.read_raw_edf(file)
raw_data = data.get_data()
# you can get the metadata included in the file and a list of all channels:
info = data.info
channels = data.ch_names

See documentation in the links above for other properties of the data object

like image 65
BossaNova Avatar answered Sep 26 '22 09:09

BossaNova