How the extract EEG data according to different epoch limits?

18 vues (au cours des 30 derniers jours)
Elaine
Elaine le 17 Mai 2024
Commenté : Elaine le 21 Mai 2024
Hey there! Currently I got an EEG data with events like "2", "4", "6","8" which mean the outset of different audio stimui. There are 20 kinds of specific audio stimuli with some similar features for each kind of event/trigger. I have the stimuli matrix generated in each experiment which is in the actual stimulating order. so the specific stimulus for each event could be targeted. In each stimulus, there is 1s silence at the begining and and the end and duration of actual voice is from 1s to 2s. I can use the detectSpeech function to find the outset and end of the voice.
Now I want to extract the EEG data with actual audio stimuli and delete the silence areas, which couldn't be realized by exracting epochs with specific limits(start and end). could you please tell me how to use script to get the EEG epochs with different length?
Thank you very much!

Réponses (1)

William Rose
William Rose le 17 Mai 2024
Are you using EEGLAB? If so, I recommend you post your quesiton to the EEGLAB mailing list - see here.
The answer depends on how the audio and eeg data are synchronized and formatted. The audio and EEG sampling rates will be different. You can find the audio file sampling rate, fs, with
[y,fs]=audioread(filename);
I assume you want to make a single continuous EEG file with the EEG during speech. Extract the relevant portions of the EEG by converting the speech start/stop indices (obtained with detectSpeech()) to the corresponding indices of the EEG signal, taking into account the different sampling rates and the time offset, if any, between the start of the speech file and the start of the EEG data file.
I assume you have 8 EEG channels, sampled at 256 Hz, and the EEG data is in array x, which is N-by-8. There may be a time offset (tOfst, in seconds) between the start of the audio and EEG data files, where tOfst is >0 or <0 if the audio file starts before or after the eeg file, respectively.
x=rand(4096,8); % represents 16 seconds of EEG data
% real EEG data may be formatted differently
tOfst=0.5; % time offset (s) >0 if audio starts before EEG
fse=256; % EEG sampling rate (Hz)
[y,fsa]=audioread(audiofilename); % read audio file and get audio sampling rate (Hz)
y=y(:,1); % take channel 1 of stereo file
idxa = detectSpeech(y,fsa); % indices where speech starts, ends
[Ns,~]=size(idxa); % number of speech segments
idxe=round(idxa*fse/fsa+tOfst*fse); % speech start/stop indices for EEG file
xs=[]; % (empty) array for EEG during speech
for i=1:Ns
xs=[xs;x(idxe(i,1):idxe(i,2),:)];
end
Neegsp=length(xs);
fprintf('Duration of EEG during speech=%.2f s.\n',Neegsp/fse)
Good luck.
  6 commentaires
William Rose
William Rose le 21 Mai 2024
The metadata for the sample file says the dataset consists of 1 epoch with 33 events.
I see the dataset has 65 channels sampled at 200 Hz for about 84.5 s. It looks to me like channel 65 is the audio channel. Channel 65 and appears to have 7 non-zero segments, each about 1-2 seconds long. Is this the expected number of speech segments for this dataset?
Would you send me a secure email so we can continue this dicussion offline? It will be easier to share files that way. To do this, click on the "WR" circle next to my posts. That should bring up a pop-up window with an envelope in the top right corner. Click the envelope to send an email.
Elaine
Elaine le 21 Mai 2024
For sure! Thank you so much!

Connectez-vous pour commenter.

Catégories

En savoir plus sur EEG/MEG/ECoG dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by