Build a Signal
Add and remove sinusoids (frequency, amplitude, phase), see the sum and its spectrum, and rebuild a real 2-s eyes-closed epoch from its top-k Fourier components with the residual.
1 claim on this page is unverified. TODO(confirm) marks a specific statement the author has not yet checked against a
primary source. Everything else on this page has been reviewed. Treat a marked claim as
provisional and go to the cited source rather than quoting the sentence.
Modes: default — the widget below runs in default. Use Share state to put the exact view in the URL.
What it does
Sinusoid superposition and its inverse. Add sinusoids one at a time with a frequency, an amplitude and a phase; the time series of the sum and its amplitude (or power) spectrum update live, so you can see beats, phase shifts and leakage as you make them. Then load a real 2-s eyes-closed epoch from ds-eegbci (O1, 160 Hz) and rebuild it from its largest k Fourier components: a slider sets k, and the widget shows the reconstruction over the original, the residual, and which bins were used. The FFT runs in the browser with the site’s DSP library.
Controls
| Control | What it sets |
|---|---|
| Add / remove sinusoid | Components of the synthetic sum |
| Frequency, amplitude, phase | Per component (frequency in Hz, amplitude in µV, phase in degrees) |
| Epoch length | Length of the synthetic epoch (sets the bin spacing 1 / T) |
| Spectrum view | Amplitude, power or dB; bin markers on or off |
| Load real epoch | Replaces the synthetic sum with the 2-s ds-eegbci epoch |
| Top-k | Number of largest components used in the reconstruction |
| Show residual | Original minus reconstruction |
What to look for
default
- Two sinusoids at nearby frequencies produce beats in the time series and two separate lines in the spectrum; the beat rate is their difference.
- Changing a component’s phase slides the waveform in time and changes the shape of the sum, but the magnitude spectrum does not move.
- A 2-s epoch has bins 0.5 Hz apart; a component at a frequency that is not a multiple of 0.5 Hz spreads across neighbouring bins (leakage, L1.4).
- On the real epoch, the first few components carry the alpha rhythm and the slow drift; the residual shrinks as k grows and reaches zero when every bin is used.
- The reconstruction tells you which frequencies are present, not when within the epoch the alpha waxed and waned; that information lives in the phases across many bins.
Used in
- L1.2 Time and frequency domains (
default)
Data provenance
The synthetic sum is generated in the browser and carries no dataset. The real epoch is a 2-s single-channel derivative (cropped; no other processing unless the sidecar says so) of ds-eegbci (O1, eyes-closed run R02, 160 Hz, recorded with no hardware filters; ODC-By 1.0 on PhysioNet, CC0 on the OpenNeuro mirror), served from /data/widgets/w-build-a-signal/ and listed in data/manifest.json: subject S001, run R02, 50–52 s, written by data/scripts/extract_p1_widgets.py. The frame’s provenance line reads the epoch’s sidecar, which is the authoritative record if the asset is regenerated.
Open the code
site/src/components/widgets/w-build-a-signal/ — Widget.svelte, index.ts, README.md. DSP: FFT from site/src/lib/dsp/. Repository link: TODO(confirm) (GitHub org/repo, §13 item 3).