I. Motivation

For neural signals, the Fourier transform serves primarily as a computational backbone for convolution rather than a final analytical endpoint. Our goal is to uncover not just the frequency content, but the time-frequency representation of the signal. Simply put, for a specific frequency band, we want to extract three traces:

  1. the instantaneous power at every time point,
  2. the instantaneous phase at every time point,
  3. the bandpass-filtered signal.

This is achieved through continuous wavelet transform (CWT). CWT is performed by convolving the signal with a Morlet Wavelet defined by a specific frequency.

The Continuous Wavelet Transform (CWT) is primarily used for Time-Frequency Representation (TFR), for the analysis of traces. In this context, feature extraction means isolating specific time-frequency characteristics. It’s not the ML sense of feature extraction. However, because CWT utilizes a redundant set of basis functions, the extracted features (trace values over time) are highly correlated. This redundancy makes them less suitable as direct features for many machine learning and statistical models. For regression analysis, statisticians typically prefer the Discrete Wavelet Transform (DWT), which uses a discrete set of scales and translations to provide a more parsimonious and orthogonal signal representation. DWT is explained in this post.

The Goal: We need a method for Time-Frequency Representation (TFR) that balances temporal and frequency precision.

II. Algorithm overview

  • Input: time series signal, wavelet parameters (frequency, number of cycles)
  • Output: three time series traces (instantaneous power, instantaneous phase, bandpass-filtered signal)
  • Computational backbone: Convolution (continuosly many inner products)

III. The Morlet Wavelet

To localize frequency information in time, we must restrict the sine wave so it does not extend infinitely.

1. Definition

A Morlet wavelet is created by multiplying a Sine Wave by a Gaussian Window (taper).

  • Sine Wave: Provides the frequency specificity.
  • Gaussian Window: Localizes the wave in time and dampens the edges to zero to prevent artifacts.

2. The Gaussian Formula

The shape of the taper is defined by:

\[GaussWin(t) = a e^{-(t-m)^2 / (2s^2)}\]
  • \( a \): Amplitude.
  • \( t \): Time.
  • \( m \): Time offset (usually 0).
  • \( s \): Standard deviation (width) of the Gaussian.

3. The Standard Deviation (s)

The width of the wavelet \( s \) is determined by the frequency \( f \) and the number of cycles \( n \):

\[s = \frac{n}{2\pi f}\]
  • \( n \): Number of cycles. This is the critical user-defined parameter that controls the trade-off between temporal and frequency precision.

IV. The Limitation of Real Wavelets

A standard “real-valued” Morlet wavelet has a major flaw: the result of convolution depends on the phase alignment between the wavelet and the signal.

  • If the signal and wavelet are phase-aligned (peaks match peaks), the dot product is positive.
  • If they are 90° out of phase (peaks match zero-crossings), the dot product is zero.
  • If they are 180° out of phase (peaks match troughs), the dot product is negative.

Consequence: You cannot reliably estimate the “power” (energy) of the signal because the value fluctuates based on phase lag, not just signal strength.


V. Complex Wavelets & Euler’s Formula

To extract stable estimates of Power and Phase independent of alignment, we use Complex Morlet Wavelets.

1. Complex Sine Waves

Instead of a real sine wave, we use a complex sine wave defined by Euler’s Formula:

\[e^{i\theta} = \cos(\theta) + i\sin(\theta)\]

This creates a “corkscrew” shape that spirals through time in 3 dimensions (Time, Real, Imaginary).

2. The Complex Morlet Wavelet Formula

Combining the Gaussian taper with the complex sine wave:

\[cmw(t) = A e^{-t^2 / (2s^2)} e^{i2\pi ft}\]
  • Real Part: \( \cos(2\pi ft) \times \text{Gaussian} \)
  • Imaginary Part: \( \sin(2\pi ft) \times \text{Gaussian} \)

VI. Feature Extraction (Geometry of the Dot Product)

When you convolve a Complex Wavelet with neural data, the result at every time point is a Complex Number. This number describes a vector in the complex plane.

From this single vector, we extract three distinct features:

1. Bandpass Filtered Signal (Real Axis)

The projection of the vector onto the Real Axis. This is equivalent to applying a standard bandpass filter with a Gaussian frequency response.

2. Instantaneous Power (Vector Length)

The Squared Magnitude of the vector. This tells you “how much” of that frequency is present, regardless of phase alignment.

  • Formula: \( \text{Power} = \text{abs}(Z)^2 \) or \( Z \cdot \text{conj}(Z) \)
  • Note: The conjugate method is computationally faster for large matrices.

3. Instantaneous Phase (Vector Angle)

The Angle of the vector relative to the positive real axis. This tells you the timing of the oscillation.

  • Formula: \( \theta = \text{angle}(Z) = \arctan(\text{imag} / \text{real}) \)

VII. The Uncertainty Principle (Parameter ( n ))

The number of cycles \( n \) defines the width of the Gaussian taper. This parameter is governed by the Heisenberg uncertainty principle for time-frequency analysis: You cannot maximize both temporal and frequency precision simultaneously.

Cycles (( n )) Gaussian Width Temporal Precision Frequency Precision Best For…
Low (e.g., 3) Narrow High (Sharp timing) Low (Broad spectrum) Transient bursts / ERPs
High (e.g., 10) Wide Low (Blurred timing) High (Sharp spectrum) Sustained oscillations

Variable Cycles

It is common to use variable cycles (e.g., increasing from 3 to 10 as frequency increases). This adjusts the precision balance across the spectrum:

  • Allows for better time precision at low frequencies.
  • Allows for better frequency precision at high frequencies.

Source: Cohen, M. X. Analyzing Neural Time Series Data: Theory and Practice. The MIT Press, 2014. (Chapters 12 & 13).