Continuos Wavelet Transform (CWT)

Is there any example that show how to apply CWT on mne.epochs?
This page: mne.time_frequency.tfr.cwt — MNE 0.23.0 documentation explain which kind of input should I give to the function and it seems it does not accept epochs, is it correct? Thus, should I provide the raw data in the shape n_chan, n_timepoints? And what should I provide to Ws? Thanks in advance!

I don’t think we have an example of that in the docs (yet). You can certainly apply cwt() to each epoch’s data individually, either in a for-loop or by passing the cwt function and the full epochs data array to np.apply_along_axis() (caveat: untested).

Internally we use CWT on epoch data via mne.connectivity.spectral_connectivity(..., mode='cwt_morlet') but if you aren’t doing it for connectivity purposes then that won’t help you.

1 Like

@Res The cwt is a lower-level function, if you want to perform time-frequency on epochs with Morlet wavelets then you can use mne.time_frequency.tfr_morlet. You can find it in the docs for example here

1 Like

I understood that CWT is the continuous wavelet transform which is different from the one implemented with tfr_morlet, am I correct?

@Res cwt is a low-level function that does convolution with wavelets. By low-level I mean that it works on numpy arrays, does not work automatically on epochs (AFAIR) etc. mne.time_frequency.tfr_morlet also does convolution with wavelets (Morlet wavelets specifically) but works on raw and epochs objects (so it saves you a lot of additional work). The convolution is implemented as multiplication in frequency domain if you use use_fft=True but that is an implementation detail (I’m not sure if use_fft=True is the default, but it is usually faster so I’d recommend always using it).

1 Like