How the extract EEG data according to different epoch limits?
Ältere Kommentare anzeigen
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!
Antworten (1)
William Rose
am 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 Kommentare
Elaine
am 19 Mai 2024
William Rose
am 19 Mai 2024
Are you using files created by EEGLab, such as the example data file, “eeglab_data_epochs_ica.set”
Could you zip one file and upload it so we can see how it is structured?
You write: "all the resampled audio envelopes were aligned to one auxiliary channel of the EEG data. The synchronization was made utilizing the event latency and corresponfing audio length of each trigger. The stimulating oder of audios was dertermined by the stim Matrix generated before each experiment. "
"Resampled audio" has me curious. Resampled to a lower samping rate? To the same rate as the EEG rate? Normal EEG sampling rates of 256 or 512 or even 1024 Hz (rare) would be too slow for audio, but maybe the envolpe would still be good for voice detection, of you rectify and then lowpass the audio.. But that is not what detectSpeech() expects.
Have you checked the results that detectSpeech() gives? I did a little test using the built-in laptop microphone and got poor results.
Elaine
am 20 Mai 2024
William Rose
am 20 Mai 2024
I opened file "sample_083__audioFeature.set". It is my first time ever using EEGLAB or its functions. I see the file has 65 channels and 65K+ points.
Will look at it more later.
William Rose
am 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
am 21 Mai 2024
Kategorien
Mehr zu EEG/MEG/ECoG finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
