Extracting columns from a matrix, corresponding start and end times

5 vues (au cours des 30 derniers jours)
User48765
User48765 le 18 Mar 2019
Hi!
I am completely new to MATLAB, and I am having some difficulty. I have a 64x430250 matrix with EEG data, from which i need to extract all data corresponding to the latency events of interest. I have a vector (EEG.times, 1x430250) containing all the sampling times, vectors for the latencies of the different events themselves, and need to extract data from -200ms to 800ms around the event. I have also created vectors containing the start/end times for each of the variables if that should make anything easier. So if the startT is equal to EEG.times, extract the corresponding data in EEG.data (all rows, column startT:endT), and store it in a new variable (preferably a 3d matrix). I know I should end up with a 64x250x96 (as i know there are 96 events). Can someone help me?

Réponse acceptée

Jos (10584)
Jos (10584) le 18 Mar 2019
The easiest approach is to create a for loop over the events
Nevents = nume(EventTimes)
R = zeros(64, 250, Nevents) % pre-allocation
for k = 1:Nevents
TF = EEG.Times > EventTimes(k)-200 & EEG.Times < EventTimes(k) + 800 ;
% TF should contain 250 true values!!!
R(:,:,k) = EEG.data(: , TF) ;
end
However, this will fail if there if for some events the number of samples within the time window is not the same ... You should think how you want to deal with these events.

Plus de réponses (1)

User48765
User48765 le 18 Mar 2019
Thank you so much!

Catégories

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

Community Treasure Hunt

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

Start Hunting!

Translated by