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:
- data
ndarray, shape of [epochs, channels, times] Real-valued data to compute the TFR of.
- sampling_freq
int|float Sampling frequency (in Hz) of
data.- freqs
ndarray, 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()andmne.time_frequency.tfr_array_multitaper().- n_cycles
ndarray, shape of [frequencies] |int|float(default7.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_wavelets
bool|None(defaultNone) Whether or not to use wavelets with a mean of 0. If
None, the default argument ofmne.time_frequency.tfr_array_morlet()andmne.time_frequency.tfr_array_multitaper()is used according totfr_mode.- use_fft
booldefault (True) Whether or not to use the fast Fourier transform for convolutions.
- multitaper_time_bandwidth
int|float(default4.0) Product between the temporal window length (in seconds) and the frequency bandwidth (in Hz). Only used if
tfr_mode = "multitaper". Seemne.time_frequency.tfr_array_multitaper()for more information.- output
"power"|"complex"(default"power") Type of TFR output to return.
Note
If
output = "complex"andtfr_mode = "multitaper", returning weights for each taper requires MNE version 1.10 or higher.Added in version 1.3.
- n_jobs
int(default1) Number of jobs to run in parallel. If
-1, all available CPUs are used.- verbose
bool(defaultTrue) Whether or not to report the status of the processing.
- data
- Returns:
- tfr
ndarray, shape of [epochs, channels (, tapers), frequencies, times] TFR power or complex coefficients of
data. Thetapersdimension is only present ifoutput = "complex"andtfr_mode = "multitaper".- freqs
ndarrayoffloat, shape of [frequencies] Frequencies (in Hz) in
tfr.- weights
ndarray, shape of [tapers, frequencies] Taper weights. Only returned if
output = "complex"andtfr_mode = "multitaper".
- tfr
Notes
This function acts as a wrapper around the MNE TFR computation functions
mne.time_frequency.tfr_array_morlet()andmne.time_frequency.tfr_array_multitaper().