Web Simulation

 

 

 

 

Wavelet Transform: Time–Frequency Localization

The Wavelet Transform provides time–frequency localization: it shows not only which frequencies are present (like the Fourier Transform) but when they occur. Unlike the Fourier Transform, which loses the time dimension in the frequency representation, wavelets use scales to zoom in on transients (spikes) and zoom out for slow trends.

What this simulation shows

Top panel — Raw signal: Choose a Signal source: synthetic Sine + spikes or ECG-style (QRS), or load real ECG (sample) or EEG (eyes open / eyes closed) data. For synthetic signals, red dashed lines mark spike positions and sliders (Noise, Sensitivity, Spike 1, Spike 2) are shown; for loaded data the full recording is plotted and those sliders are hidden.

Middle panel — Fourier (FFT): Magnitude vs frequency. The FFT detects the frequencies present but does not tell you when events occurred; that information is smeared across the spectrum.

Wavelet panel: The mother wavelet (Morlet, Mexican Hat, Haar, Gaussian-1, or Shannon) used for the transform.

Scalogram panel: Time on the X-axis, scale (inverse of frequency) on the Y-axis. High freq / Small scale at the top; Low freq / Large scale at the bottom. Use Run / Step to scan through the CWT; the yellow overlay on the signal shows the wavelet at the current position. Below the scalogram, Current step shows the CWT formula and coefficient for the current scale and time index.

Why wavelets for ECG/EEG

Fourier: Tells you if there is high-frequency content (e.g. a heartbeat), but not when each beat occurred. Wavelet: By scaling the mother wavelet, short wavelets catch fast transients (high temporal resolution) and long wavelets catch slow rhythms (high frequency resolution). The Mexican Hat (Ricker) wavelet matches the sharp rise/fall of a QRS complex, making it ideal for R-peak detection. Try ECG-style or ECG (sample) with Mexican Hat to see this.

QRS DETECTED

Raw signal (time domain)

Fourier transform (magnitude vs frequency)

Wavelet (mother wavelet)

Wavelet scalogram (time vs scale)

4
Current step

 

Tab description

This page demonstrates the Wavelet Transform vs the Fourier Transform. Signal: Sine + spikes or ECG-style (QRS) (synthetic; Noise, Sensitivity, Spike 1/2 sliders apply), or ECG (sample) / EEG (eyes open) / EEG (eyes closed) (loaded from data files; full recording is plotted, sliders hidden). Wavelet: Morlet, Mexican Hat, Haar, Gaussian-1, or Shannon. Run / Step scan the scalogram; the math panel below shows the CWT formula for the current step.

Usage

  • Signal: Synthetic signals let you adjust spikes and noise; loaded ECG/EEG show the full data with no sliders.
  • Spike 1 / Spike 2: (Synthetic only.) Set the time index of the two spikes. The scalogram shows bright vertical stripes at those times; the FFT does not localize them.
  • Noise / Sensitivity: (Synthetic only.) Noise adds high-frequency content; Sensitivity sets the threshold for the "QRS DETECTED" indicator.
  • Run / Step: Animate or step through the CWT. Step stops any running scan and advances one time index. At the end, Run or Step restarts from the beginning.
  • ECG/EEG + Mexican Hat: Mexican Hat is well-suited to peak detection (e.g. QRS in ECG); try it with ECG-style or loaded ECG/EEG.

Math

  • Continuous Wavelet Transform (CWT): CWT(a,b) = (1/√a) ∫ s(t) ψ((t−b)/a) dt. Scale a: small a = high frequency (short window); large a = low frequency (long window).
  • Morlet: ψ(t) = exp(−t²/2) cos(5t). Good for general time–frequency analysis.
  • Mexican Hat (Ricker): Second derivative of Gaussian; ideal for peak/edge detection (e.g. QRS in ECG).
  • Haar / Gaussian-1 / Shannon: Additional preset wavelets; the Current step panel shows the formula and |CWT(a,b)| for the selected wavelet.
  • Scale vs frequency: Y-axis is scale: top = small scale (high freq), bottom = large scale (low freq). Low scale resolves transients in time; high scale resolves slow trends.

Key concepts

  • Fourier limitation: FFT gives magnitude vs frequency but no time information—you cannot tell when a spike occurred.
  • Wavelet advantage: Variable-sized "windows": short wavelets for spikes, long wavelets for slow oscillations. The scalogram is a 2D map of time and scale (inverse frequency).
  • Windowing: In Fourier, a short window improves time resolution but worsens frequency resolution. Wavelets avoid this trade-off by using different scales for different frequency bands.