File Exchange

image thumbnail

Reading and saving of data in the EDF+

version 1.3.0.0 (6.59 KB) by Andrey Shapkin
Reading and saving of multichannel biological and physical signals in the European Data Format (EDF)

32 Downloads

Updated 14 Jun 2013

View License

The European Data Format (EDF) is a simple and flexible format for exchange and storage of multichannel biological and physical signals.

The code is intended for reading and saving of data in the EDF+.

[data, header] = readEDF(filename)

SaveEDF(filename, data, header)

% filename - EDF+ file name (*.edf)

% data - Contains a signals matrix or cell conteins signals data

% header - Contains header structure

http://www.edfplus.info/

Cite As

Andrey Shapkin (2020). Reading and saving of data in the EDF+ (https://www.mathworks.com/matlabcentral/fileexchange/38641-reading-and-saving-of-data-in-the-edf), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (15)

Dear friends! I apologize for not responding long to the messages. At the moment, I have a very big load on the main work, and my work is little related to the EEG, so I practically do not have the opportunity to quickly make corrections. The comments already had were on fixing code errors, as soon as the time appears I will upload the update. A short note: in versions of matlab older than 2011, programs may not work correctly.

Does anyone have a solution for the missing samplerate:

""Reference to non-existent field 'samplerate'.

Error in SaveEDF (line 48)
samplerate=header.samplerate(1);""

I can't save the edf because of that..

Makena Low

Has anyone gotten a working version of the SaveEDF function?

Like Victor mentioned changing the code below helped me in reading the data along with the annotations

THERE IS AN ERROR IN:

Rs=cumsum([1; header.duration*header.samplerate]); % строка индексов подблоков каналов Rs(k):Rs(k+1)-1

PLEASE FIX IT TO:

Rs=cumsum([1; header.samplerate]); % строка индексов подблоков каналов Rs(k):Rs(k+1)-1

Since header.samplerate is not a sampling frequency, but Nr of samples in one epoch, which can be more than 1 second.

David Lee

Hi. After downloading, what should I do in order to read the .edf file from my emotiv epoc ? Thank you

The SaveEDF function completely does not work. The instructions fail to include all the necessary information for getting it to work and the code is written so badly it would take a lot of time to get it working.

Important: You really need to change one line of the code to make it work.
1. Download
2. Put the downloaded files into a folder ( directory of the folder should not change)
2. Change one line of the code (have a look at the comment of Victor (21 Jun 2015))
3. Add the directory of the folder to Matlab (fastest way: -> 'Set Path' Button (beneath preferences) -> add folder -> choose the directory of your folder

After fixing that bug, it's a great edf reader!

David

This file loads the edf file from emotic's epoc.

A very fast EDF reader. In my testing, faster than "blockEdfLoad.m".

"SaveEDF.m" has a bug. It throws error if any of the 'header.prefilt' is empty.
To tide over this, I added a check if 'header.prefilt' is empty:
if ~isempty(header.prefilt{n})
prefilt(n,1:length(header.prefilt{n})) = header.prefilt{n};
end

Mary

Evy Cleeren

Hi,

I would like to use these functions to anonymize patients EEG data. After saving with these functions, the EEG data is rounded (-7.7058 becomes -8 and so on...). Does that matter for further analyses? How can I prevent this from happening?

Thanks a lot!

Victor

THERE IS AN ERROR IN:

Rs=cumsum([1; header.duration*header.samplerate]); % строка индексов подблоков каналов Rs(k):Rs(k+1)-1

PLEASE FIX IT TO:

Rs=cumsum([1; header.samplerate]); % строка индексов подблоков каналов Rs(k):Rs(k+1)-1

Since header.samplerate is not a sampling frequency, but Nr of samples in one epoch, which can be more than 1 second.

Jakub

I believe there is an error in line 76 of << ReadEDF.m >>.

The file as-downloaded has the following:
Rs=cumsum([1; header.duration*header.samplerate]);

This is incorrect because << header.duration >> does not have to be an integer. The result is that an error occurs when the values of Rs are used to denote vector indices in line 84: Ch_data(Rs(k):Rs(k+1)-1, :)

The correct form of line 76 should be:
Rs=cumsum([1; header.samplerate]);

Helio

Dear Andrey I'm very grateful to have found your routines. I've been dealing with edf+ annotations for a while and your reader works just flawless. Thanks a lot for sharing!

Mark Skopin

Please disregard my previous comment. I got it to work. The startime and startdate fields were not all in lowercase. Great functions and very useful! Thanks again!

Updates

1.3.0.0

Products Required change

1.2.0.0

Screenshot update

MATLAB Release Compatibility
Created with R2009b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired: blockEdfLoad, blockEDFLoadClass