Spectrogram
Namespace: UTILSLIB · Library: Utilities Library · Source: dsp/spectrogram.h
#include <utils/spectrogram.h>
class UTILSLIB::Spectrogram
Computes time-frequency spectrograms via short-time Fourier transform with configurable window and overlap.
src/examples/ex_dsp_spectral/main.cpp
const MatrixXd spectrogram = Spectrogram::makeSpectrogram(signal.transpose(), 64); // frequency bins x samples
Static Methods
makeSpectrogram(signal, windowSize)
Calculates the spectrogram (tf-representation) of a given signal.
Parameters:
-
signal : Eigen::VectorXd input-signal to calculate spectrogram of.
-
windowSize : qint32 width of the Gaussian window in samples (trades time against frequency resolution).
Returns:
- Eigen::MatrixXd — Power |STFT|^2, N/2 x N for a signal of N samples: row k is the FFT bin at k * sfreq / N Hz, column j the window centred on sample j.
Example
- Start here: ex_dsp_spectral — Spectral and filtering tools of the dsp library on signals with known content.
- Full source:
src/examples/ex_dsp_spectral/main.cpp - Build target:
ex_dsp_spectral(runs under CTest)
Used in examples
ex_disp
Disp library widgets: image map, line plot and time-frequency plot of raw data.
src/examples/ex_disp/main.cpp, line 230
//tf plot example: spectrogram of the same channel
MatrixXd dataSpectrum = Spectrogram::makeSpectrogram(dataCol, raw.info.sfreq * 0.2);
TFplot tfplot(dataSpectrum, raw.info.sfreq, 0, 100, ColorMaps::Jet, times(0, 0));
ex_tf_plot
Spectrogram of one evoked channel shown as a time-frequency plot.
src/examples/ex_tf_plot/main.cpp, line 79
//tf plot
VectorXd dataCol = p_FiffEvoked.data.row(83).transpose();
MatrixXd dataSpectrum = Spectrogram::makeSpectrogram(dataCol, p_FiffEvoked.info.sfreq * 0.1);
Authors of this file
- Christoph Dinh <christoph.dinh@mne-cpp.org>