Skip to content

Signal Example — Convolution

Interactive demo showing discrete convolution by sliding a kernel across a signal, with three kernel types including a Morlet wavelet to bridge filtering and time-frequency analysis.

Signal Example Convolution

What it shows

RowPlotDescription
1Signal + KernelThe input signal with the kernel overlaid at the current position — the shaded band marks the overlap region.
2OutputThe convolution result accumulated up to the current kernel position. For the Wavelet kernel, this is the amplitude envelope.

Key Concept

Convolution computes, at each time point t, the weighted sum of the signal under the kernel:

Gaussian: smooth low-pass filter — noise suppressed, slow waves preserved.

Boxcar: running average — same idea but with sharper edges in frequency.

Wavelet (Morlet): Gaussian × cos(2πfτ) — the kernel is frequency-selective. The output is the amplitude envelope: how much of Wavelet Freq is present at each time point. This is one row of a time-frequency spectrogram.

Controls

ControlApplies toDescription
Kernel PositionAllScrub the kernel across the signal — output builds up as you drag right
Kernel WidthGaussian / BoxcarTotal span of the kernel (label updates to "→ eff. X ms" in Wavelet mode)
CyclesWaveletNumber of oscillations in the kernel — more cycles = better frequency resolution, worse time resolution
Wavelet FreqWaveletThe target frequency to detect
Signal FreqAllFrequency of the input signal
NoiseAllAdditive Gaussian noise
Kernel typeAllSwitch between Gaussian, Boxcar, Wavelet (Morlet)

Things to Try

  1. Low-pass filtering: Gaussian kernel, drag position to end — output is a smoother version of the noisy input.

  2. Kernel width effect: Gaussian, widen the kernel → noise disappears, but the sine is also attenuated as the kernel begins to span whole cycles.

  3. Switch to Wavelet Freq = Signal Freq → amplitude envelope is near 1.0 (frequency detected).

  4. Mismatch frequencies (e.g. Wavelet = 8 Hz, Signal = 4 Hz) → envelope near 0.

  5. Cycles tradeoff: with two nearby signal frequencies, fewer cycles blurs them together; more cycles separates them.

  6. Link to Gaussian: set Kernel Width = value shown in "→ eff. X ms" label, then switch kernel type — you will see the same Gaussian envelope.

See Also

Code

julia
using EegFun
EegFun.signal_example_convolution()