mne.time_frequency.psd_array_multitaper resolution

macOS 14.5

Hi, i’m a begginer in ephy and i’m trying to find a way to change the resoluton of my psd with mne.time_frequency.psd_array_multitaper() function.

My signal is 10 minutes of preproced data 1kHz (raw 30kHz). And i wanted to have a psd with one point per frequence (freq min = 0 and max =100). Actually i’ve 60001 point that i’m not very understanding why…?

There is my code :
pp2_psd2, frequencies_pp2 = mne.time_frequency.psd_array_multitaper(pp2.get_data()[ch_indices], sfreq=pp2.info[‘sfreq’], fmin=0, fmax=100)

Do you have ideas of what is my probelme come from ?

Thanks very much

Dear Clemence,

With this function, you are not calculating a single PSD, but a time-frequency decomposition, which is giving you the frequency content over time.

It makes sense that the routine returns 60001 points since that is your time axis ( 10 minutes sampled at 1 KHz). However, there should also be a second dimension to your output such that the two-dimensional matrix returned is time * frequency. It might help to have a look at the outputs of the function you are calling (mne.time_frequency.psd_array_multitaper — MNE 1.7.1 documentation)

Have a look at the following tutorial on creating a single PSD
https://www.nmr.mgh.harvard.edu/mne/0.14/auto_examples/time_frequency/plot_compute_raw_data_spectrum.html#sphx-glr-auto-examples-time-frequency-plot-compute-raw-data-spectrum-py

Kind regards,
Steven

Dear Steven,
Thanks you very much for your answer.
I was copy past the wrong function in my message but i talk about the psd_array_multitaper function and not tfr one.

but if i well understand the multitaper method is not adapted to compute single psd ? when i’m using the function “compute_psd(method=‘multitaper’, fmin=0, fmax=100, tmin=None, tmax=None)” and the same with method=‘welch’, i’ve differents outputs:
Multitaper : <Power Spectrum (from Raw, multitaper method) | 64 channels × 60001 freqs, 0.0-100.0 Hz>
Welch : <Power Spectrum (from Raw, welch method) | 64 channels × 205 freqs, 0.0-99.6 Hz>

I don’t really understand why and the difference

Best regards
Clémence

Dear Clémence,

That makes sense indeed. The difference between Welch and Multitaper is that the Welch method uses a sliding window over the data, for which the calculated PSDs are averaged. This sliding window defines the maximum frequency resolution. The multitaper method does not use a sliding window but instead uses multiple tapers on the data, from which the PSD results are averaged in one PSD, giving a higher frequency resolution. Especially for this length of data with the amount of samples, the differences in resolution can thus be quite severe.

If you want to read a bit more on the frequency resolution, I think this page explains it quite well with MNE examples: Bandpower of an EEG signal

Kind regards,
Steven