[Eeglablist] Calculate band power for each single epoch and average them

Steven Dong (HARMAN Connected Services) v-jendo at microsoft.com
Tue May 28 15:47:05 PDT 2019


Hello

This should be a really easy task, but I am trying to calculate the Fz Theta/Pz Alpha (cognitive workload) for each trial. This is not event-locked, which I am doing 2-second epoch with 1-second overlap on the continuous data.
The following code was adapted and modified based on the code I found online, but it only gave overall power of each frequency band. And I think the Fz Theta/Pz Alpha (cognitive workload) was not accurate.
I would like to learn how I can modify so I can do get the power of alpha and theta from each epoch, get the ration, and them calculate the average.
Or is there another function I should use to achieve this.

Thanks,
Steven Dong

bandFilePath = ‘’

for n = 1:length(ALLEEG)
        EEG = ALLEEG(n);
        disp(EEG.setname);
        EEG=eeg_regepochs(EEG,'recurrence',1,'limits',[-1 1], 'rmbase', NaN);
        M = [];
        for x = 1:EEG.nbchan
                [spectra,freqs] = spectopo(EEG.data(x,y,:), 0, EEG.srate);
                % Set the following frequency bands: delta=1-4, theta=4-8, alpha=8-13, beta=13-30, gamma=30-80.
                deltaIdx = find(freqs>1 & freqs<4);
                thetaIdx = find(freqs>4 & freqs<8);
                alphaIdx = find(freqs>8 & freqs<13);
                lowerbetaIdx  = find(freqs>13 & freqs<18);
                higherbetaIdx = find(freqs>18 & freqs<30);
                gammaIdx = find(freqs>30 & freqs<80);
                % Compute absolute power.
                deltaPower = mean(10.^(spectra(deltaIdx)/10));
                thetaPower = mean(10.^(spectra(thetaIdx)/10));
                alphaPower = mean(10.^(spectra(alphaIdx)/10));
                lowerbetaPower  = mean(10.^(spectra(lowerbetaIdx)/10));
                higherbetaPower  = mean(10.^(spectra(higherbetaIdx)/10));
                gammaPower = mean(10.^(spectra(gammaIdx)/10));
                % Write to matrix M
                M(1,x) = deltaPower;
                M(2,x) = thetaPower;
                M(3,x) = alphaPower;
                M(4,x) = lowerbetaPower;
                M(5,x) = higherbetaPower;
                M(6,x) = gammaPower;
        end
        fileName = strcat(bandFilePath, EEG.filename(1:end-4),'.csv');
        csvwrite(fileName,M);
end



More information about the eeglablist mailing list