Calculate absolute power using mne

I know the PSD can be computed using either psd_welch or psd_multitaper.

And the average band power power, which equal to an area under certain region, can be calculated using the module simps of the scipy.

from scipy.integrate import simps

# Frequency resolution
freq_res = freqs[1] - freqs[0]  # = 1 / 4 = 0.25

# Compute the absolute power by approximating the area under the curve
delta_power = simps(psd[idx_delta], dx=freq_res)

But, I am wondering whether there is any build module to compute the absolute or relative band power of a signal. This question is especially of great interest since I would like to get the absolute power per channel and per epoch

Appreciate if someone can point me to the appropriate material/link

Based on the tutorial sleep stage classification,
absolute and relative power can calculated as below

from mne.time_frequency import psd_welch
# specific frequency bands
FREQ_BANDS = {"delta": [0.5, 4.5],
                  "theta": [4.5, 8.5],
                  "alpha": [8.5, 11.5],
                  "sigma": [11.5, 15.5],
                  "beta": [15.5, 30]}
 
psds, freqs = psd_welch(epochs, picks='eeg', fmin=0.5, fmax=30.)

 # Normalize the PSDs
    psds /= np.sum(psds, axis=-1, keepdims=True)

    X = []
    for fmin, fmax in FREQ_BANDS.values():
        psds_band = psds[:, :, (freqs >= fmin) & (freqs < fmax)].mean(axis=-1)
        X.append(psds_band.reshape(len(psds), -1))
1 Like

yes or have a look at https://github.com/mne-tools/mne-features/

Alex

1 Like