Morlet Wavelet Transform and Averaging

I wish to apply a particular type of preprocessing applied by a research paper on my data though the specifics can vary:

The Morlet wavelet transform (with a wave number of 6) was used to compute spectral power as a function of time for all EEG signals during word presentation (0 - 1600 ms) and a 1000 ms buffer was included on both sides of the data to minimize edge effects. Frequencies were sampled logarithmically at 46 intervals between 2 and 100 Hz. Power values were then down-sampled by taking a moving average across 100 ms time windows from stimulus onset and sliding the window every 50 ms, resulting in 31 total time windows with 16 non-overlapping time windows.

Does the following code work except for the (very significant) buffering part?

frequencies = np.logspace(*np.log10([2, 100]), num=46)
power, itc = mne.time_frequency.tfr_morlet(epoch, freqs=frequencies, n_cycles=6, use_fft=True, decim=3, average=True)

I think MNE has no means to calculate a moving window average.

Hello WhosePolter,

I am not sure what they mean by “buffer”. I assume that they intended to mirror the data on both ends to avoid edge artifacts. Otherwise they might just include a longer time window and use the shorter time window for the stats part only. The downsampling part depends on your sampling rate. Do you know the sampling rate of this paper? Depending on your machine, you might not need to downsample at all (you will get a warning about aliasing effects after downsampling).

Hope this helps?

Best,

Carina

1 Like

@CarinaFo Thanks! My interpretation aligns with your second assessment; they simply trimmed 1000 ms (the buffer zone) each from both the start and end since they were expectedly contaminated by edge effects on the transform. I wonder if there is anything to be lost if I skip the downsampling altogether; from a theoretical perspective, the information ought to be richer but I might miss trends. What say you?

that’s also how I interpret it.

To me it seems odd to do this smoothing step. It undermines one of the unique features of the wavelet transform, i.e., its multiresolution property (better time resolution at high frequencies, better spectral resolution at low frequencies). The sliding-window-averaging will wipe out the better time resolution at high frequencies.