MATLAB Answers

1

Create events/annotations on EEGLAB?

Asked by Maanasi Garg on 4 Oct 2016
Latest activity Commented on by Itaf BEN SLIMEN on 20 Jun 2018
Can I manually create events/annotations in .set EEG files on EEGLAB without previously importing epoch info or event info? The EEGs which I want to analyze with EEGLAB have files with respective event annotations, but those files are in .edf.seizures format, which I can't figure out how to open on EEGLAB.

  0 Comments

Sign in to comment.

1 Answer

Answer by Rylan Dmello on 14 Oct 2016
 Accepted Answer

Hello Maanasi,
I understand that you want to import ‘ .edf.seizures ’ files into MATLAB for processing by EEGLAB. Please refer to the EEGLAB documentation for more information:
Since ‘ .edf.seizures ’ seems to be a non-standard file format, it is possible to write your own MATLAB function to import event annotations from these files. The following MATLAB Answers page provides more information about this:
Building on the above answer, assuming that you want to read more than one seizure event, you can use the following MATLAB function:
function [ number_of_seizures, seizure_start_time_offsets, seizure_lengths ] = get_seizure_periods( annotation_file_location )
file_descriptor = fopen(annotation_file_location);
byte_array = fread(file_descriptor);
number_of_seizures = (sum(byte_array == hex2dec('ec')) - 1) / 2;
for i=1:number_of_seizures
seizure_start_time_offsets(i) = bin2dec(strcat(dec2bin(byte_array(23 + (i*16))),dec2bin(byte_array(26 + (i*16)))));
seizure_lengths(i) = byte_array(34 + (i*16));
end
end
The above function provides the number of seizure events, the seizure start time offsets (from the previous event), and the duration of the seizures. In the above function, I have assumed that the seizure data stays at the same byte positions in each ‘ .edf.seizures ’ file. I also used the publicly-available ‘ .edf.seizures ’ data from the CHB-MIT Scalp EEG Database to test the above function:
If you are getting your ‘ .edf.seizures ’ files from a different source, you may want to write your own data import function. Also, since EEGLAB may want the data in the form of a matrix, you may want to reshape the above arrays into a matrix before importing it into EEGLAB.
In order to import this data from the MATLAB workspace into EEGLAB, you might want to use the “Import Epoch Info” feature of EEGLAB. Please refer to the EEGLAB documentation for more information about importing epoch information:

  2 Comments

Thank you! I figured out how to input events with a text file.
please have you a solution for this problem !! i can't open the file .edf.seizures !!

Sign in to comment.