mne.time_frequency.tfr_array_morlet#
- mne.time_frequency.tfr_array_morlet(epoch_data, sfreq, freqs, n_cycles=7.0, zero_mean=False, use_fft=True, decim=1, output='complex', n_jobs=None, verbose=None)[source]#
Compute Time-Frequency Representation (TFR) using Morlet wavelets.
Same computation as
tfr_morlet
, but operates onNumPy arrays
instead ofEpochs
objects.- Parameters:
- epoch_data
array
of shape (n_epochs, n_channels, n_times) The epochs.
- sfreq
float
|int
Sampling frequency of the data.
- freqs
array
offloat
, shape (n_freqs,) The frequencies of interest in Hz.
- n_cycles
int
|array
ofint
, shape (n_freqs,) Number of cycles in the wavelet, either a fixed number or one per frequency. The number of cycles
n_cycles
and the frequencies of interestfreqs
define the temporal window length. See notes for additional information about the relationship between those arguments and about time and frequency smoothing.- zero_mean
bool
|False
If True, make sure the wavelets have a mean of zero. default False.
- use_fft
bool
Use the FFT for convolutions or not. default True.
- decim
int
|slice
, default 1 To reduce memory usage, decimation factor after time-frequency decomposition.
Note
Decimation is done after convolutions and may create aliasing artifacts.
- output
str
, default'complex'
'complex'
: single trial complex.'power'
: single trial power.'phase'
: single trial phase.'avg_power'
: average of single trial power.'itc'
: inter-trial coherence.'avg_power_itc'
: average of single trial power and inter-trial coherence across trials.
- n_jobs
int
|None
The number of jobs to run in parallel. If
-1
, it is set to the number of CPU cores. Requires thejoblib
package.None
(default) is a marker for ‘unset’ that will be interpreted asn_jobs=1
(sequential execution) unless the call is performed under ajoblib.parallel_backend()
context manager that sets another value forn_jobs
. The number of epochs to process at the same time. The parallelization is implemented across channels. Default 1.- verbose
bool
|str
|int
|None
Control verbosity of the logging output. If
None
, use the default verbosity level. See the logging documentation andmne.verbose()
for details. Should only be passed as a keyword argument.
- epoch_data
- Returns:
- out
array
Time frequency transform of epoch_data.
if
output in ('complex', 'phase', 'power')
, array of shape(n_epochs, n_chans, n_freqs, n_times)
else, array of shape
(n_chans, n_freqs, n_times)
If
output
is'avg_power_itc'
, the real values inout
contain the average power and the imaginary values contain the ITC: \(out = power_{avg} + i * itc\).
- out
See also
Notes
The Morlet wavelets follow the formulation in [1].
In spectrotemporal analysis (as with traditional fourier methods), the temporal and spectral resolution are interrelated: longer temporal windows allow more precise frequency estimates; shorter temporal windows “smear” frequency estimates while providing more precise timing information.
Time-frequency representations are computed using a sliding temporal window. Either the temporal window has a fixed length independent of frequency, or the temporal window decreases in length with increased frequency.
Figure: Time and frequency smoothing. (a) For a fixed length temporal window the time and frequency smoothing remains fixed. (b) For temporal windows that decrease with frequency, the temporal smoothing decreases and the frequency smoothing increases with frequency. Source: FieldTrip tutorial: Time-frequency analysis using Hanning window, multitapers and wavelets.
In MNE-Python, the temporal window length is defined by the arguments
freqs
andn_cycles
, respectively defining the frequencies of interest and the number of cycles: \(T = \frac{\mathtt{n\_cycles}}{\mathtt{freqs}}\)A fixed number of cycles for all frequencies will yield a temporal window which decreases with frequency. For example,
freqs=np.arange(1, 6, 2)
andn_cycles=2
yieldsT=array([2., 0.7, 0.4])
.To use a temporal window with fixed length, the number of cycles has to be defined based on the frequency. For example,
freqs=np.arange(1, 6, 2)
andn_cycles=freqs / 2
yieldsT=array([0.5, 0.5, 0.5])
.New in version 0.14.0.
References
Examples using mne.time_frequency.tfr_array_morlet
#
Time-frequency on simulated data (Multitaper vs. Morlet vs. Stockwell vs. Hilbert)