Extracting epochs from an edf file to save as .m file?

61 views (last 30 days)
pickyourbrain
pickyourbrain on 21 Nov 2024 at 6:07
Commented: pickyourbrain on 23 Nov 2024 at 22:44
Hey, newbie to coding and all of that. I'm trying to extract 10 random epochs that are 20 seconds each from my EEG recording (.edf file). I want to be able to save these epochs as a .m file. I'm trying to do this without having to use the EEGLAB GUI. I used edfread and it seems that the data within the edf file is a timetable with a size of 5282 x 1.
Any help on how to do this would be greatly appreciated.
  7 Comments
Walter Roberson
Walter Roberson on 23 Nov 2024 at 20:59
sampling_rate = hdr.EEGEEG1A_B(1);
No.
https://www.mathworks.com/help/signal/ref/edfread.html#mw_a83171d9-fafc-4332-ad36-8243ddcc75c6 shows an example of using edfinfo() and edfread() to compute the vector of sampling frequencies, fs . sampling_rate is 1 ./ fs
Each different signal could, in theory, have a different sampling rate.
epoch_samples = epoch_duration * sampling_rate;
That might not be an integer.
What you should be doing instead, is repeatedly using timerange to extract epochs, since there could be a different number of samples in each epoch (because the epoch_samples is not certain to be an integer.)
pickyourbrain
pickyourbrain on 23 Nov 2024 at 22:44
Sorry, this is still very abstract for me. Could you explain more about how timerange can be implemented? Do I use timerange in a for loop? What is the structure contained in each epoch?

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!