Skip to content

Signal Example — Power Spectrum

Interactive demo showing how a time-domain signal maps to a power spectrum via the FFT, and illustrating frequency resolution, spectral leakage, and windowing.

Signal Example 1

What it shows

RowPlotDescription
1Time DomainThe composed signal (up to 2 s displayed).
2Power SpectrumOne-sided FFT power spectrum. Dashed lines mark the true frequencies; the orange band is one frequency-resolution bin (Δf = 1/T).

Controls

ControlRangeDescription
Freq 11–60 HzFrequency of the first sine component
Amp 10–2Amplitude of the first component
Freq 21–60 HzFrequency of the second sine component
Amp 20–2Amplitude of the second component (0 = silent)
Noise0–2Noise standard deviation
Epoch1–10 sEpoch length → sets frequency resolution Δf = 1/T
HanningtoggleApply Hanning window to suppress spectral leakage
Log scaletoggleLogarithmic y-axis (makes sidelobes visible)

Key Concepts

Frequency resolution (Rayleigh frequency): Δf = 1/T where T is the epoch length. To resolve two frequencies, they must be at least Δf apart. The orange band on the spectrum shows the current bin width.

Spectral leakage: When a frequency does not land exactly on a bin, energy spreads into neighbouring bins. This happens whenever the signal frequency is not an integer multiple of Δf.

Windowing: A Hanning window tapers the signal to zero at both ends, eliminating the discontinuity that causes leakage. The cost is a slightly wider main lobe. For EEG, a Hanning (or similar) window is almost always applied before FFT.

Both resolution and leakage matter in EEG: alpha (8–12 Hz) and beta (13–30 Hz) bands must be resolved from each other, and window choice affects how cleanly you can estimate power in narrow frequency bands.

See Also

Code

julia
using EegFun
EegFun.signal_example_spectrum()