Reshape EEG data to wide format with new aggregate column names
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I'm using EEG lab to calculate relative spectral power for various bands. This went well, but now I'm stuck on how to reshape this the way I need it. I have 20 participants, and I want each participant to have only one row of data.
As such, I'm trying to convert this matrix so that the columns are a combination of electrode and frequency band. For example, each participant would have one row of data with columns labelled F7.relativeAlpha, F7.relativeBeta, and so on (see below for example). Any help would be greatly appreciated! I added an example of what I'm trying to create vs what I have currently.
I've tried unsuccessfully with the reshape function and with the unstack function.
RelativePowerWide = unstack(RelativePowerResults,'ID','RelativeDelta')
0 Commenti
Risposta accettata
Voss
il 28 Gen 2025
% a table
ID = ["01-02";"01-02";"01-02";"01-02";"01-02";"01-02";"01-02";"01-12";"01-12";"01-12";"01-12";"01-12";"01-12"];
Electrode = {'F7';'FP1';'FP2';'F8';'F3';'Fz';'F4';'F7';'FP2';'F8';'F3';'Fz';'F4'};
N = numel(ID);
RelativeDelta = rand(N,1);
RelativeTheta = rand(N,1);
RelativeBeta = rand(N,1);
RelativeGamma = rand(N,1);
T = table(ID,Electrode,RelativeDelta,RelativeTheta,RelativeBeta,RelativeGamma)
% unstack
Tnew = unstack(T,"Relative"+["Delta","Theta","Beta","Gamma"],'Electrode');
% adjust new variable names if needed
vars = Tnew.Properties.VariableNames(2:end);
vars = regexprep(vars,'(.*)_(.*)','$2.$1');
Tnew.Properties.VariableNames(2:end) = vars;
Tnew
Più risposte (0)
Vedere anche
Categorie
Scopri di più su EEG/MEG/ECoG in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!