pybispectra.utils.compute_tfr#

pybispectra.utils.compute_tfr(data: ndarray, sampling_freq: int | float, freqs: ndarray, tfr_mode: str = 'morlet', n_cycles: ndarray | int | float = 7.0, zero_mean_wavelets: bool | None = None, use_fft: bool = True, multitaper_time_bandwidth: int | float = 4.0, output: str = 'power', n_jobs: int = 1, verbose: bool = True) tuple[ndarray, ndarray] | tuple[ndarray, ndarray, ndarray][source]#

Compute the time-frequency representation (TFR) of data.

Parameters:
datandarray, shape of [epochs, channels, times]

Real-valued data to compute the TFR of.

sampling_freqint | float

Sampling frequency (in Hz) of data.

freqsndarray, shape of [frequencies]

Frequencies (in Hz) to return the TFR for.

tfr_mode"morlet" | "multitaper" (default "morlet")

Mode for computing the TFR. See mne.time_frequency.tfr_array_morlet() and mne.time_frequency.tfr_array_multitaper().

n_cyclesndarray, shape of [frequencies] | int | float (default 7.0)

Number of cycles in the wavelet when computing the TFR. If an array, the number of cycles is given for each frequency, otherwise a fixed value across all frequencies is used.

zero_mean_waveletsbool | None (default None)

Whether or not to use wavelets with a mean of 0. If None, the default argument of mne.time_frequency.tfr_array_morlet() and mne.time_frequency.tfr_array_multitaper() is used according to tfr_mode.

use_fftbool default (True)

Whether or not to use the fast Fourier transform for convolutions.

multitaper_time_bandwidthint | float (default 4.0)

Product between the temporal window length (in seconds) and the frequency bandwidth (in Hz). Only used if tfr_mode = "multitaper". See mne.time_frequency.tfr_array_multitaper() for more information.

output"power" | "complex" (default "power")

Type of TFR output to return.

Note

If output = "complex" and tfr_mode = "multitaper", returning weights for each taper requires MNE version 1.10 or higher.

Added in version 1.3.

n_jobsint (default 1)

Number of jobs to run in parallel. If -1, all available CPUs are used.

verbosebool (default True)

Whether or not to report the status of the processing.

Returns:
tfrndarray, shape of [epochs, channels (, tapers), frequencies, times]

TFR power or complex coefficients of data. The tapers dimension is only present if output = "complex" and tfr_mode = "multitaper".

freqsndarray of float, shape of [frequencies]

Frequencies (in Hz) in tfr.

weightsndarray, shape of [tapers, frequencies]

Taper weights. Only returned if output = "complex" and tfr_mode = "multitaper".

Notes

This function acts as a wrapper around the MNE TFR computation functions mne.time_frequency.tfr_array_morlet() and mne.time_frequency.tfr_array_multitaper().