Calculate mean of an array in time windows.

7 visualizaciones (últimos 30 días)
Joana
Joana el 21 de En. de 2020
Respondida: Athul Prakash el 24 de En. de 2020
Hi
i have EEG data recorded at 1200hz from 5 channels, for 10 repetitions, and i need to calculate mean of each 1s signal in 10 time windows (each of 100ms) as a features. Is thi the right way to do.? Although the features i'm getting isn't right.
for repetition = 1:size(EEG,3) % loop through repetitions
featCnt = 1; % feature counter for generic choice of features or channels
chanCnt = 1;
for channel = 1:length(channels)
for window = 1:10
% calculate mean for current repetition and channel
features(repetition,featCnt) = mean(EEG(repetition)+(1200/10)*(window-1):(EEG(repetition)+(1200/10)*(window+1)-1));
featLabels{featCnt} = sprintf('%s_Mean_%i',chanLabels{chanCnt},window);
featCnt = featCnt + 1; % Count up, for generic choice of feature or channels
end
chanCnt = chanCnt + 1;
end
end

Respuestas (1)

Athul Prakash
Athul Prakash el 24 de En. de 2020
I'm not sure how you have arranged your data within the matrix 'EEG' - which dimensions correspond to which attributes?
I noticed that in the following line:
features(repetition,featCnt) = mean(EEG(repetition)+(1200/10)*(window-1):(EEG(repetition)+(1200/10)*(window+1)-1));
you are indexing into EEG using just one variable 'repetition'. But you seem to be looping through dimension-3 of EEG with the same variable - this would produce the wrong result.
I would recommend understanding Matlab's indexing thoroughly before you get working on matrix math such as this. Have a look at this doc:
If you need to brush up on or practice working with loops, indexing etc, Maltab OnRamp is a good place to start.

Categorías

Más información sobre EEG/MEG/ECoG en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by