JOVANA
Explore Library Glossary Getting Started Three Levels Fields How it works Mission
Join the mission
All guides

Time–Frequency Analysis: STFT, Wavelets, and the Uncertainty Floor

When rhythms come and go within a trial, you need a spectrum that moves — and a clear-eyed grasp of the time–frequency resolution you can never simultaneously have.

Why static spectra fail for brain signals

A single PSD assumes the process is stationary over the whole record, but the interesting events in a BCI are transient: a mu rhythm suppresses at movement onset, a beta burst appears and vanishes, a P300 rides a single stimulus. Collapsing time hides exactly the dynamics you care about. Time–frequency analysis estimates a spectrum as a function of time, S(t,f).

The STFT and its fixed tiling

The short-time Fourier transform slides a fixed window across the signal and Fourier-transforms each position. It tiles the time–frequency plane into identical rectangles: the same absolute time resolution and the same absolute frequency resolution at every frequency.

X(t,f) = \sum_{n} x_n\, w_{n-t}\, e^{-i2\pi f n}, \qquad \text{spectrogram} = |X(t,f)|^2

The STFT and its spectrogram.

To see how frequencies change over time, slide a window along the signal and take a Fourier transform inside each position. The squared result is the spectrogram — a picture of power across time and frequency. The window size fixes the time–frequency trade-off once and for all.

X(t,f)
The short-time Fourier transform at time t, frequency f.
w_{n-t}
The sliding window centred at time t.
e^{-i2\pi f n}
The Fourier kernel.
|X(t,f)|^{2}
The spectrogram — power at each time and frequency.

The fixed window is the STFT's weakness for neural data. A window long enough to resolve a 2 Hz difference in the delta band (needs ~0.5 s) blurs a fast gamma burst in time; a window short enough to localize the gamma burst cannot resolve low-frequency structure.

Wavelets: constant-Q, log-frequency tiling

The Morlet (complex) wavelet transform fixes this by scaling the window with frequency: high frequencies use short wavelets (good time, coarse frequency), low frequencies use long wavelets (good frequency, coarse time). The ratio of centre frequency to bandwidth — the quality factor Q — is held constant, matching the (roughly) logarithmic spacing of neural bands.

\psi(t) = \frac{1}{\sqrt{\pi f_b}}\; e^{\,i2\pi f_c t}\; e^{-t^2/f_b}, \qquad \Delta f \approx \frac{f}{n_{co}}

The complex Morlet wavelet; the cycle count n_co sets the time–frequency tradeoff.

A wavelet is a little wave-packet — a sinusoid inside a Gaussian bubble — that you stretch or squeeze to probe different frequencies. Unlike the STFT's fixed window, wavelets automatically use short windows for fast frequencies and long ones for slow frequencies. The cycle count sets the trade-off.

\psi(t)
The Morlet wavelet — the waveform used to probe the signal.
f_c
The wavelet's centre frequency.
f_b
The bandwidth parameter — the width of the Gaussian.
n_{co}
The number of cycles, setting time-vs-frequency precision.
Heisenberg boxes: the wavelet/STFT tradeoff between time and frequency resolution.

The analytic signal: instantaneous amplitude and phase

For a narrowband signal, the Hilbert transform builds the analytic signal, whose modulus and argument are the instantaneous amplitude and phase. This is the workhorse for phase-based connectivity and phase–amplitude coupling in Guide 4. The catch: instantaneous phase is only physically meaningful after band-pass filtering to a band narrow enough that the signal is locally sinusoidal.

z(t) = x(t) + i\,\mathcal{H}\{x\}(t) = a(t)\,e^{i\phi(t)}, \qquad f(t) = \frac{1}{2\pi}\frac{d\phi}{dt}

The analytic signal and instantaneous frequency.

By adding a 90°-shifted (Hilbert) copy of the signal as an imaginary part, you turn a real oscillation into a rotating complex number: its length is the instantaneous amplitude and its spinning angle is the phase. How fast the angle turns is the instantaneous frequency.

z(t)
The analytic signal — the complex version of x.
\mathcal{H}\{x\}
The Hilbert transform — the 90°-shifted copy of the signal.
a(t)
Instantaneous amplitude — the signal's envelope.
f(t)=\tfrac{1}{2\pi}\tfrac{d\phi}{dt}
Instantaneous frequency — the rate the phase \phi turns.

The uncertainty floor you cannot beat

None of these methods can localize arbitrarily well in both time and frequency at once. The Gabor–Heisenberg limit says the product of the time spread and frequency spread of any window is bounded below. STFT, wavelets, and Hilbert differ only in how they distribute this fixed uncertainty across the plane — not in whether they can escape it.

\Delta t\;\Delta f \;\ge\; \frac{1}{4\pi}

Time–frequency uncertainty; equality holds for a Gaussian (Morlet/Gabor) window.

A hard physical limit: you can't know both exactly when and exactly at what frequency something happened. Sharpen the timing and you blur the frequency, and vice versa. No analysis trick beats this floor; a Gaussian window comes closest (equality).

\Delta t
Uncertainty in time.
\Delta f
Uncertainty in frequency.
\tfrac{1}{4\pi}
The smallest their product can be.

Reading a time–frequency map

The final practical step is normalization. Raw wavelet power is dominated by the 1/f background (Guide 5), so time–frequency maps are usually shown as change from a pre-event baseline — decibel or percent change — which is exactly the ERD/ERS framework. Choose a baseline window that is truly task-free, and beware that a poorly chosen baseline can flip the sign of your effect.