Averaging PSD across electrodes for global bandpower

MNE-Python version: 0.22.1
operating system: Windows 10

I am calculating PSD using psd_welch for visualization and to use as parameters in a machine learning application. In my code, I calculate PSD and average it across electrodes to get global bandpower in the five common freq. bands. Is it common, or at all informative, to do such averaging? Want to make sure this is the PSD used in most BCI-type application…

Thank you!
-nv

`

Code Snippet

	freq_bands = {'Delta':[1.5,4.5],'Theta':[4.5,8.5],'Alpha':[8.5,12.5],'Beta':[12.5,30.5],'Gamma':[30.5,40.]}
	psds,freqs = mne.time_frequency.psd_welch(self.data,picks='eeg',fmin=0.5,fmax=40.) # calculate PSDs
	psds /= np.sum(psds,axis=-1,keepdims=True) # Normalize PSDs
	bandpower = []
	for fmin,fmax in freq_bands.values(): # Calculate bandpower for bands of interest
		psds_band = psds[:,(freqs>=fmin) & (freqs < fmax)].mean(axis=-1)
		bandpower.append(psds_band.reshape(len(psds),-1))

	# Get global means and alpha/theta ratio
	bandpower_global_means = [np.mean(band) for band in bandpower] # average across electrodes for global mean
	bandpower_global_means.append(float(bandpower_global_means[2]) / float(bandpower_global_means[1])) # alpha/theta ratio

`

for BCI you would not do this. You would use a spatial filter with for example a CSP

https://mne.tools/stable/generated/mne.decoding.CSP.html

See an example in:

https://mne.tools/dev/auto_examples/decoding/decoding_csp_eeg.html

Note that this is not the start of the art these days. Riemannian techniques provided
by : https://pyriemann.readthedocs.io/
should be more performant.

HTH
Alex

1 Like

@agramfort Thank you for getting back. Apologies, I think my use of the term BCI was confusing. I’m not looking to do decoding right now, more just calculating the power of each frequency band at the most basic level to compare between sessions (e.g. alpha was higher in session 1 compared to session 2). Would running psd_welch on the data and then averaging across electrodes still work for that?

Thank you,
-nv

yes it works this way then

Alex

1 Like