Sampling Explorer
Sample a continuous signal at an adjustable rate with or without an anti-alias filter, compute alias frequencies, and decimate a real 500 Hz recording with and without filtering.
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: hardware · math — the widget below runs in hardware. Use Share state to put the exact view in the URL.
What it does
Two views of one idea. In hardware mode a continuous synthetic signal (a sum of sinusoids plus seeded noise) is sampled at a rate you set, with an optional anti-alias low-pass in front of the sampler; you see the continuous signal, the samples, the reconstruction from those samples, and the spectrum before and after sampling. In math mode a calculator gives the alias frequency for any tone and rate (with the 140 Hz at 200 Hz case from L1.1 preset), and a real 500 Hz posterior-channel snippet from ds-iowapd is decimated to 100 Hz with and without anti-alias filtering, using the site’s own resample and decimateNaive routines. All computation runs in the browser; the synthetic signal is seeded, so a shared state reproduces the identical view.
Controls
| Control | What it sets |
|---|---|
| Signal components | Frequency and amplitude of each sinusoid in the continuous signal; noise level (hardware) |
| Sampling rate | The rate at which the continuous signal is sampled (hardware), or the rate in the alias calculator (math) |
| Anti-alias filter | On/off: a low-pass below the new Nyquist frequency applied before sampling or before decimation |
| Tone frequency | The frequency whose alias is computed (math) |
| Real snippet | Which trace to decimate: the 160 Hz ds-eegbci snippet or the 500 Hz ds-iowapd snippet (math) |
| Target rate | The decimation target (100 Hz for the 500 Hz snippet) (math) |
| Cutoff fraction | Where the anti-alias cutoff sits relative to the Nyquist frequency (a device’s usable band ends at the cutoff, not at fs/2) |
| Reconstruction | Linear (connect the dots) or sinc reconstruction from the samples, with a reconstruction-error readout (hardware) |
| Predicted by folding | Overlay of where the original spectrum’s content lands after naive decimation, on top of the decimated spectrum (math) |
| Spectrum axes | Linear or log power; frequency range up to the current Nyquist frequency |
What to look for
hardware
- A component above half the sampling rate does not vanish: its samples trace out a slower sinusoid, and a new line appears in the sampled spectrum at the alias frequency.
- With the anti-alias filter on, that component is removed before sampling; the sampled spectrum stays clean and the component is gone, not moved.
- The reconstruction from the samples matches the continuous signal only while every component lies below the Nyquist frequency.
- Broadband noise above the Nyquist frequency folds into the band you kept and raises its floor.
- Lower the rate until a component you care about is lost: the rate you need is set by the highest frequency of interest plus room for the filter’s transition band.
math
- The alias frequency is the distance from the tone to the nearest multiple of the sampling rate: 140 Hz at 200 Hz gives 60 Hz.
- Sweep the tone across the Nyquist frequency and watch the alias reflect back toward zero.
- Decimating the 500 Hz
ds-iowapdsnippet to 100 Hz without filtering moves its 60 Hz mains line to 40 Hz (the distance to 100 Hz); with the anti-alias filter on, the line is removed instead. - Content between the new Nyquist frequency (50 Hz) and the old one folds into 0–50 Hz and is then indistinguishable from brain activity.
- The 160 Hz
ds-eegbcisnippet has nothing above 80 Hz to fold, which is why it cannot host the demonstration.
Used in
- L0.3 Amplifiers, sampling and recording (
hardware) - L1.1 Sampling, Nyquist and aliasing (
math)
Data provenance
The synthetic signal in hardware mode is generated in the browser from a seed and carries no dataset. The two real snippets are 10-s single-channel derivatives (cropped; no other processing unless the sidecar says so) of public datasets, served from /data/widgets/w-sampling-explorer/ and listed in data/manifest.json:
snippet160:ds-eegbciS001, channel O1, eyes-closed run R02, 50–60 s, 160 Hz, recorded with no hardware filters (ODC-By 1.0 on PhysioNet, CC0 on the OpenNeuro mirror).snippet500:ds-iowapdsub-001, channel Oz, task-Rest, 180–190 s, 500 Hz, raw (0.1 Hz online high-pass; online reference Pz; 60 Hz mains with harmonics below the 250 Hz Nyquist frequency; CC0).
Both were written by data/scripts/extract_p1_widgets.py and are listed in data/manifest.json with SHA-256 and size; the frame’s provenance line reads each snippet’s sidecar (dataset, subject, run, start time, license, DOI), which is the authoritative record if the assets are regenerated.
Open the code
site/src/components/widgets/w-sampling-explorer/ — Widget.svelte, index.ts, README.md. DSP: resample and decimateNaive from site/src/lib/dsp/. Repository link: TODO(confirm) (GitHub org/repo, §13 item 3).