I was wondering whether there was a way to extract the GFP for all subjects loaded. So far I am only able to plot it for all channels of an individual with
if length(size(EEG.data))==3
gfp = std(mean(EEG.data,3));
end
but I would like to get it from all my subjects (now 24). So how should I access ALLEEG.data and loop through all of the sets?

2 commentaires

Walter Roberson
Walter Roberson le 5 Sep 2021
Modifié(e) : Walter Roberson le 5 Sep 2021
Instead of doing length(size), use ndims(EEG.data)
Is ALLEEG a struct array, so ALLEEG(7).data would be the 7th subject ?
What should be done if the data does not have exactly 3 dimensions ?
Yes, exactly, each number of ALLEEG corresponds to the index of a subject. So the 7th would be ALLEEG(7).
About the dimensions, it is indeed important that they have the 3 dimensions because actually I have been running into errors when there were only 2 dimensions (so maybe only 1 trial) and you cannot plot it (being x=time, y=GFP(microvolts)).
Can this then be saved so that every cell array in the struct is averaged and the GFP can be plotted for all subjects?

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 6 Sep 2021

0 votes

nEEG = numel(ALLEEG);
where_3d = find(arrayfun(@(IDX) ndims(ALLEEG(IDX).data)) == 3, 1:nEEG));
results = cell(nEEG, 1);
results(where_3d) = arrayfun(@(IDX) std(mean(ALLEEG(IDX).data,3)), where_3d, 'uniform', 0);
This will return empty cells for the places where data is not 3D; it is not clear to me what you want to do with those places.
Can this then be saved so that every cell array in the struct is averaged and the GFP can be plotted for all subjects?
What you presented earlier does not have cell arrays inside the struct.
We need to create cell arrays here because mean() along the third dimension creates a 2d result, and std() of that is going to create a row vector, so for each entry, gfp is going to be a row vector with as many columns as ALLEEG.data has columns for that entry.
We as outsiders do not know that the number of columns is consistent between tne struct members.
I do not understand what is to be averaged? Do you mean like
mean(std(mean(ALLEEG(IDX).data,3)))
?? Taking the std() of the mean() is already a bit odd; taking the mean() of the std() of the mean() is decidedly odd.

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by