NaN in alpha frequency band

Data load

data=mne.io.read_raw_cnt('data.cnt',preload=True)
data.drop_channels(['A1','A2','NC', 'X1', 'X2', 'X3', 'X4'])
data.set_montage('standard_1005',match_case=False)
data.set_eeg_reference()

Power spectral density
data.plot_psd(fmin=0.2, fmax=45);

When i try to get alpha band like this

from mne.time_frequency import psd_welch
psds, freqs = psd_welch(data,  fmin=0.2, fmax=45)
psds /= np.sum(psds, axis=-1, keepdims=True)
psds_band = psds[ :, (freqs >= 8.5) & (freqs < 11.5)].mean(axis=-1)
psds_band

I got NaNs. Though there is no NaNs in other frequency bands. Any idea

Hello @talhaanwarch, could you share the data you used?

Hi, @richard please download it from here

If you look at freqs, you’ll find that it’s

array([ 3.90625,  7.8125 , 11.71875, 15.625  , 19.53125, 23.4375 ,
       27.34375, 31.25   , 35.15625, 39.0625 , 42.96875])

So the requested frequencies that satisfy

(freqs >= 8.5) & (freqs < 11.5)

do not exist.

If you pick a different frequency band, like 8–12 Hz, it works.

Best wishes,
Richard

2 Likes