Time and frequency domains
Any signal as a sum of sinusoids; reading amplitude, phase and frequency; the DFT and its bins; resolution as 1/T; amplitude versus power versus dB.
Prerequisites: L1.1 · Sampling, Nyquist and aliasing
Objectives
- Describe any signal as a sum of sinusoids
- Read amplitude, phase and frequency
- Compute a DFT and interpret its bins
- Relate frequency resolution to epoch length
- Distinguish amplitude, power and dB
Why this matters
Every spectrum, filter, wavelet and coherence value in the rest of this curriculum rests on one idea: a signal can be written as a sum of sinusoids, and the sum can be undone. If you can say what a Fourier coefficient is, which frequency a given bin holds, why a two-second epoch cannot resolve two rhythms half a hertz apart, and whether a plot shows amplitude, power or decibels, the later material is bookkeeping. If you cannot, every later plot is a picture you have to take on trust.
Concepts
A sinusoid has three numbers
A sinusoid is completely described by its amplitude A (how big), its frequency f (how many cycles per second, in hertz) and its phase φ (where in the cycle it is at time zero): x(t) = A · cos(2π f t + φ). Amplitude is measured in the signal’s units (µV here); frequency is the reciprocal of the period; phase is an angle, and shifting the phase slides the wave in time without changing its shape. Two sinusoids of the same frequency and different phases add to another sinusoid of that frequency; two of different frequencies add to something that is not a sinusoid, and two close frequencies produce beats, a slow waxing and waning at the difference frequency, which is exactly what alpha “spindling” in a raw trace looks like.
Any signal as a sum of sinusoids
The Fourier series says that a periodic signal is a sum of sinusoids at multiples (harmonics) of its fundamental frequency, each with its own amplitude and phase. The Fourier transform extends this to any signal by letting the frequencies become continuous. The practical claim for us is narrower and exact: any finite recording of N samples can be written as a sum of N/2 + 1 sinusoids at fixed frequencies, and that representation loses nothing. The widget makes the claim concrete: add sinusoids and watch the waveform; then load a real two-second epoch and rebuild it from its largest components.
The DFT and its bins
The discrete Fourier transform of N samples x[n] gives N complex coefficients
X[k] = Σ x[n] · exp(−2πi k n / N), for n = 0 … N−1,
one for each bin k. Bin k corresponds to the frequency k · fs / N. Bin 0 is the mean (DC); the bins run up to the Nyquist frequency at k = N/2. Coefficients above N/2 mirror those below for a real signal, so numpy.fft.rfft returns only the N/2 + 1 unique ones. The FFT is an algorithm that computes the same coefficients quickly; “FFT” and “DFT” name the same numbers.
The spacing between bins, the frequency resolution, is
Δf = fs / N = 1 / T,
where T is the epoch length in seconds. This is the single most useful relationship in the lesson: resolution depends only on how long you recorded, not on the sampling rate. A 2-s epoch has 0.5 Hz bins whether it was sampled at 160 Hz or 2500 Hz; the sampling rate only decides how far the bins extend (to fs/2). To tell 10 Hz from 10.5 Hz you need at least two seconds of data; to tell 10 Hz from 10.1 Hz you need ten.
Which bin holds a given frequency? k = f · N / fs = f · T. At fs = 256 Hz with a 2-s epoch, N = 512 and Δf = 0.5 Hz, so 10 Hz sits at bin k = 10 · 2 = 20 (counting from bin 0 = DC). A frequency that is not a whole multiple of Δf sits between bins, and its energy spreads over the neighbours: that spreading is leakage, the subject of L1.4.
Magnitude, phase, and the complex number
Each coefficient X[k] is a complex number, and the intuition that suffices for this curriculum is that a complex number is an arrow: its length is the magnitude |X[k]| and its angle is the phase. The magnitude tells you how much of that frequency is present; the phase tells you where in its cycle the sinusoid is at the start of the epoch. Phase is what averaging destroys or preserves (evoked versus induced activity, L4.1) and what connectivity measures compare (L5.2); for now, note only that the widget’s phase slider changes the waveform without changing the magnitude spectrum, because magnitude and phase are independent pieces of information.
Scaling conventions differ between libraries. With the definition above, a sinusoid of amplitude A occupying a single bin produces a magnitude of A · N / 2 in that bin, so amplitude is recovered as 2 · |X[k]| / N; other conventions divide by N or by the square root of N inside the transform. Always check what your library returns before reading an amplitude off a spectrum.
Amplitude, power and decibels
- Amplitude spectrum: |X[k]|, scaled to the signal’s units (µV). Linear in the signal: doubling the signal doubles it.
- Power spectrum: |X[k]|², in µV². Power is amplitude squared; a sinusoid of amplitude A has mean power A² / 2. Doubling the signal quadruples it. A power spectral density (µV²/Hz, L1.3) is power per unit bandwidth, so that its integral over a band gives band power in µV².
- Decibels: a logarithmic ratio. For power, dB = 10 · log10(P / P₀); for amplitude, dB = 20 · log10(A / A₀), and the two agree because power is amplitude squared. A factor of 2 in power is about 3 dB, a factor of 10 in power is 10 dB, a factor of 10 in amplitude is 20 dB. Decibels are always relative to a reference (a baseline, another condition, a fixed unit); a dB axis with no stated reference is unreadable.
Spectra are usually plotted with power on a logarithmic axis because EEG power falls steeply with frequency (L1.7) and a linear axis shows nothing above the alpha peak. Read the axis label every time: µV, µV², µV²/Hz, dB, log10 — each one changes what a “difference” between two curves means.
Reconstruction from the top components
Sorting a real epoch’s coefficients by magnitude and rebuilding the signal from the largest k of them is a compact summary of everything above. The first few components of an eyes-closed occipital epoch are the alpha rhythm and its slow drift; adding more fills in the rest; the residual falls as k grows and reaches zero at k = N/2 + 1. It also shows what the DFT does not do: it does not tell you when the alpha waxed and waned within the epoch, because that information lives in the phases across many bins. Time-frequency methods (Level 4) exist to recover it.
Three facts to keep: bin spacing is 1 / T; a 10 Hz component in a 2-s epoch at 256 Hz is bin 20; power is amplitude squared and decibels are ten times the log of a power ratio. Everything else in the lesson follows from the definition of the transform.
The data behind this lesson
- The widget’s real epoch is a 2-s eyes-closed segment from
ds-eegbciS001 R02 at O1 (50–52 s; 160 Hz, no hardware filters; ODC-By 1.0), so its 0.5 Hz bins extend to 80 Hz;data/manifest.jsonrecords it.
Explore
Add a 10 Hz sinusoid, then a 10.5 Hz one, and watch the beats in the time series and two separate lines in the spectrum; drag a phase slider and confirm the spectrum does not move. Add a component at a frequency that is not a multiple of 0.5 Hz and watch it spread across bins. Then load the real epoch and raise k from 1: note how few components carry the alpha, and how the residual shrinks.
Practice
Time and frequency domains: the FFT of a real 2-s epoch, reconstruction from the top-k components, resolution versus epoch length nb-1-2-fft
Downloads from ds-eegbci.
The notebook computes the NumPy FFT of a real epoch, labels the bins in hertz, reconstructs the epoch from its top-k components, and repeats the analysis for epoch lengths of 1, 2 and 8 s to show the resolution change directly.
Exercises
Exercise ex-1-2-resolution-and-bin
NumericAn epoch is 2 s long and sampled at 256 Hz. (1) What is the frequency resolution of its DFT, in Hz? (2) Which bin index holds 10 Hz, counting bin 0 as DC?
Pitfalls
No pitfall for this lesson: Spec §6 lists no pitfall for this lesson (§5.3 exemption).
In other tools
In other toolsFieldTrip — names only
The equivalents of what this lesson does, for a reader who works in another toolbox. Function names only: their own documentation is the place to learn how to call them.
FieldTrip
ft_freqanalysis(mtmfft/fourier)FieldTrip
Names checked 2026-09-18 against FieldTrip 20251218.
Reading
- Cohen (2014). Analyzing Neural Time Series Data. unverified