MNE-Python version: 0.22.1
operating system: Windows 10
Hello,
I would like to calculate band power for resting-state data. I found a script from the sleep stage classification tutorial that is designed for epoch objects which generates the following error when applied to continuous data: “IndexError: too many indices for array: array is 2-dimensional, but 3 were indexed”
https://mne.tools/stable/auto_tutorials/clinical/60_sleep.html
# 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))
return np.concatenate(X, axis=1)
To adjust this so it accepts continuous data, do I just need to remove one of the colons in “psds_band=” as follows? It runs, but I want to make sure that this is correct/valid.
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))
Thank you for your time,
Dps