relative band power

All

I am attempting to calculate relative band power for EEG channels in an EDF file following this paper:

which defines the formula for relative power (RP) as:

RP(f1,f2)= (P(f1,f2)/P(FMIN,FMAX))×100%

so far as I can tell P(f1,f2) could be calculated different ways depending on the definition of power in a band:

  1. power calculated from an epochs object calculated using compute_psd between f1 and f2
totalPower = epochs.compute_psd(picks=picks, fmin=FMIN, fmax=MAX)
bandPower = epochs.compute_psd(picks=picks, fmin=f1 fmax=f2)

# pad bandPower to same dimensions as totalPower and divide

  1. power calculated between 1 and 45Hz filtered by f1 and f2
totalPower = epochs.compute_psd(picks=picks, fmin=FMIN, fmax=FMAX)
totalPsds, totalFreqs = totalPower.get_data(return_freqs=True)
bandPsds = totalPsds[:,:,(totalFreqs >= f1) & (totalFreqs < f2)].mean(axis=-1)

I am likely showing my naivety here but both are possible in code but only one or neither method is likely conventionally correct.

Please could the group let me know what they think.

regards

Robert

with a little code, you can actually figure it out!

import numpy as np

import mne

plt.ion()

sample_data_folder = mne.datasets.sample.data_path()
sample_data_raw_file = sample_data_folder / 'MEG' / 'sample' / 'sample_audvis_raw.fif'
raw = mne.io.read_raw_fif(sample_data_raw_file, verbose=False, preload=False)
raw.crop(tmax=20).load_data()

fmin, fmax = 10, 20

psd1 = raw.compute_psd()
psd2 = raw.compute_psd(fmin=fmin, fmax=fmax)

mask = np.logical_and(psd1.freqs >= fmin, psd1.freqs <= fmax)

np.testing.assert_array_equal(psd1.get_data()[..., mask],
                              psd2.get_data())

the assertion holds, i.e., you get the same result either way.

1 Like