Skip to main content

MultitaperTfr

Namespace: RTPROCESSINGLIB  ·  Library: DSP Library

Python equivalent

mne.time_frequency.tfr_multitaper in MNE-Python.

#include <dsp/multitaper_tfr.h>

class UTILSLIB::MultitaperTfr

Sliding-window multitaper time-frequency representation.

Slides a fixed-length analysis window across the data and computes a multitaper PSD at each position, yielding a time-frequency power map per channel.

src/examples/ex_dsp_spectral/main.cpp
const MultitaperTfrResult tfr = MultitaperTfr::compute(signal, kSFreq, 128, 32); // 128-sample windows, 32-sample hop

Static Methods​

compute(matData, sfreq, windowSize, stepSize, halfBandwidth, nTapers)​

Compute sliding-window multitaper TFR for every channel of a data matrix.

Parameters:

  • matData : const Eigen::MatrixXd & Data matrix (n_channels × n_times).

  • sfreq : double Sampling frequency in Hz.

  • windowSize : int Analysis window length in samples (default 256).

  • stepSize : int Step size in samples; -1 → windowSize / 2.

  • halfBandwidth : double Half-bandwidth parameter (NW); default 4.0.

  • nTapers : int Number of DPSS tapers; -1 → floor(2*halfBandwidth - 1).

Returns:


computeArray(matData, sfreq, vecFreqs, nCycles, timeBandwidth, zeroMean)​

Compute multitaper power at every sample with frequency-specific DPSS wavelets, as mne.time_frequency.tfr_array_multitaper(..., output="power") does for one epoch.

Parameters:

  • matData : const Eigen::MatrixXd & Data matrix (n_channels × n_times).

  • sfreq : double Sampling frequency in Hz.

  • vecFreqs : const Eigen::RowVectorXd & Frequencies of interest in Hz.

  • nCycles : double Number of cycles in each wavelet (default 7).

  • timeBandwidth : double Time-bandwidth product; floor(timeBandwidth - 1) tapers (default 4).

  • zeroMean : bool Make each wavelet zero mean (default true).

Returns:


Example​

Used in examples​

ex_dsp_spectral​

Spectral and filtering tools of the dsp library on signals with known content.

src/examples/ex_dsp_spectral/main.cpp, line 145
const MultitaperTfrResult tfr = MultitaperTfr::compute(signal, kSFreq, 128, 32); // 128-sample windows, 32-sample hop
const RowVectorXd tfrMean = tfr.tfrData[0].rowwise().mean().transpose();
ok &= expect(std::fabs(frequencyOfMax(tfrMean, tfr.vecFreqs) - 20.0) < 2.0 && tfr.vecTimes.size() == tfr.tfrData[0].cols(),
QString("multitaper TFR: %1 windows, strongest band near 20 Hz").arg(tfr.vecTimes.size()));

Authors of this file​