pythonmne-python

Frequency step in psd_multitaper vs psd_welch


The frequency step in the return values of psd_welch is 1.953125 while in psd_multitaper it is 0.00164441 - 3 orders of magnitude difference:

import mne
psds,freqs = mne.time_frequency.psd_multitaper(edf)
np.diff(freqs)
==> array([0.00164441, 0.00164441, 0.00164441, 0.00164441, 0.00164441, ...])
psds,freqs = mne.time_frequency.psd_welch(edf)
np.diff(freqs)
==> array([1.953125, 1.953125, 1.953125, 1.953125, 1.953125, 1.953125, ...])

Why? How do I control it?

PS. See also discussion.


Solution

  • psd_multitaper - no go

    The frequencies are determined by edf.info["sfreq"] which can only be changed by edf.resample() which also modified the upper frequency limit edf.info["lowpass"].

    psd_welch - easy

    Use n_fft argument. It defaults to 256. So, if you want to halve the step from 1.953125 to 0.9765625 pass n_fft=512.