Time Frequency analysis (STFT or Morlet) and details on tfr_array_morlet()

Hi all,

I’m working on the analysis of temporal frequencies (TF) in EEG, and I used the function tfr_array_morlet() with n_cycles = 6. My aim is to extract power from the 8-30 Hz band to analyze alpha and beta oscillations.

  • Reading the documentation for tfr_morlet(), I understand that n_cycles only affects the length of the Morlet wavelet (as well as freqs), is this correct or is there something else?

  • I have a long period (up to 9s), and tfr_array_morlet() takes a long time to execute, even if I use a large number of n_jobs. If I only need one or two electrodes, is it possible to execute this function only with the electrode of interest, or is it necessary to send data from all the electrodes to obtain a better/equal result?

  • I used to use the Short-Time Fourier Transform (STFT) because I better understood the mathematical procedure behind the concept. In this case, increasing the window length increases frequency resolution, but reduces temporal resolution. What are the advantages and disadvantages of STFT compared with Morlet? Is time resolution better with the Morlet transform?

  • Finally, how do you choose the method for calculating the time-frequency transform for the eeg signal, and which one do you think is the most reliable?

  • After TF, I used mne.EvokedArray() to transforme my array in MNE object (adapting frequency sample as new_sf = (initial array of time sample - 1) / length of epoch (seconds) ) and plot the topography with .plot_topomap(), is correct ?

Thanks for your explanations and help!

Johan

Hi,

Here are some short answers.

Reading the documentation for tfr_morlet(), I understand that n_cycles only affects the length of the Morlet wavelet (as well as freqs), is this correct or is there something else?

Yes, it’s correct and effectively it means that you can control the tradeoff between time and frequency resolution.

I used to use the Short-Time Fourier Transform (STFT) because I better understood the mathematical procedure behind the concept. In this case, increasing the window length increases frequency resolution, but reduces temporal resolution. What are the advantages and disadvantages of STFT compared with Morlet? Is time resolution better with the Morlet transform?

In practice I believe people prefer Morlet wavelets because they can be adaptive that is, use a different n_cycles per frequency. Check this tutorial for an example, but note that you can adjust it to your needs. You should find some details on relevant literature if you are not sure what to do.

Finally, how do you choose the method for calculating the time-frequency transform for the eeg signal, and which one do you think is the most reliable?

I think it depends on the question you have and ultimately on which method better helps your “understand” your data.

I have a long period (up to 9s), and tfr_array_morlet() takes a long time to execute, even if I use a large number of n_jobs. If I only need one or two electrodes, is it possible to execute this function only with the electrode of interest, or is it necessary to send data from all the electrodes to obtain a better/equal result?

You can pass as many electrodes as you like, the results shouldn’t be affected. On a related note, you should consider whether you need single-trial or trial-averaged data and set output accordingly.

After TF, I used mne.EvokedArray() to transforme my array in MNE object (adapting frequency sample as new_sf = (initial array of time sample - 1) / length of epoch (seconds) ) and plot the topography with .plot_topomap(), is correct ?

I am not sure what you mean by adapting the sampling (?) frequency, but in principle what you are doing should work. You could also use mne.viz.plot_topomap() to avoid the transformation if you are unsure how to do it properly.

Hope this helps,

1 Like

@sotpapad Thank you for your time, it’s very helpful!

For the last question on topography, it was just a matter of knowing how to indicate the right time step to create a MNE object, when we lose temporal resolution due to TF (morlet or STFT). I note that I can use mne.viz.plot_topomap() directly, thank you.

Have a nice day.

Johan

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.