Bench modeSteps, parts, and safety only. Big type for a phone at the bench.
Phase 1: First contactExplainer14 min

What the spectrum did

The plotter turned a wiggling line into a plot with a bump at 10 Hz. Here is what a spectrum is, why it can see alpha when your eye cannot, and the two things it trades away.

AssumesProject B: One channel of youSpineDecoding / signal processing / ML

You are skimming: the title, the first figure, and the short version. Switch to Read in the header for the full page, or Deep to open every deep dive.

Look at five seconds of eyes-closed EEG and you might, if you squint, see a wobble about ten times a second. Look at its spectrum and there is an unmistakable hill at 10 Hz. The spectrum did not add information. It rearranged the same information so that the question “how much of this signal repeats ten times a second?” has a direct answer. Let’s build that idea from sinusoids up.

Any signal is a sum of sinusoids

That sentence is the whole of Fourier’s idea, and it is literally true for any signal you can record. Take three pure tones at different frequencies and amplitudes and add them. The sum looks like a mess. Now ask, for each frequency, how much of that frequency is present. You get three spikes, exactly where you put the tones, exactly as tall as you made them.

Build a signal, read its spectrum
This interactive needs JavaScript. If you are reading a printout, the caption describes what it shows.
Figure 1. Three sinusoids and their sum, above; the spectrum of the sum, below. The spectrum recovers exactly what went in.
Try this
  1. Set tone 3’s amplitude to zero. Its spike vanishes.
  2. Move tone 1 to 10 Hz and tone 2 to 10.5 Hz. Watch the two spikes merge into one lump. That is frequency resolution, and the deep dive explains it.
  3. Turn the noise up. The spikes are still there, standing on a floor. That is why the spectrum sees alpha when your eye cannot.

The is the algorithm that does the “ask for each frequency” part quickly. What it returns, for each frequency, is an amplitude and a phase. Square the amplitude and you have power. Plot power against frequency and you have the .

Predict before you look

A signal has a 10 Hz sinusoid buried in noise five times its size. Will the spectrum show a peak at 10 Hz?

Yes, clearly. Noise spreads its power across every frequency; a sinusoid concentrates all of its power at one. Over a two-second window, the 10 Hz bin collects everything the sinusoid has, while each noise bin gets only a small share. The peak stands well above the floor. This is the same reason radio works.

What the axes mean

The horizontal axis is frequency in hertz, from zero to half your sampling rate (the ; more on that in Phase 2). The vertical axis is usually power per hertz, called , and it is usually plotted in decibels because EEG power spans several orders of magnitude between 1 Hz and 40 Hz. A 10 dB rise is ten times the power. Alpha’s hill is typically 10 to 20 dB above the surrounding floor in a good eyes-closed recording.

The floor itself slopes down from left to right. EEG has more power at low frequencies than high, roughly following one over frequency, and every spectrum you ever plot will show that slope before it shows anything else.

The two trades

Time for frequency. To tell 10 Hz from 10.5 Hz you need to watch for at least two seconds, because that is how long it takes the two to drift half a cycle apart. In general, frequency resolution in hertz is one over the window length in seconds. A ten-second window resolves 0.1 Hz. A quarter-second window resolves 4 Hz, which cannot separate alpha from beta. So a spectrum of a long window is sharp but tells you nothing about when things happened; a spectrum of a short window knows when but is blurry. The , which slides a short window along the signal, is the compromise everyone uses.

Sharpness for confidence. One spectrum of one two-second window is noisy: the height of every bin wobbles by a large fraction from one window to the next. cuts the recording into overlapping windows, computes each spectrum, and averages them. The average is smoother and its peaks are trustworthy, at the cost of the frequency resolution of the shorter windows. The plotter and the simulator both use it.

Deep dive Why the window has to be tapered 4 min

The FFT assumes the stretch of signal you gave it repeats forever. If the stretch starts at one value and ends at another, the imaginary repetition has a jump at every seam, and jumps have energy at all frequencies. That energy smears across the spectrum as “leakage,” burying small peaks. A such as the Hann window multiplies the stretch by a smooth bump that goes to zero at both ends, so the seams vanish. The price is slightly wider peaks. Every serious spectrum uses a window; the interactive above does.

Deep dive Phase, the half the plot throws away 3 min

The FFT gives each frequency an amplitude and a phase. The spectrum plots only amplitude. Phase says where in its cycle each sinusoid was at the start of the window, and for a single channel it is mostly uninteresting. Between two channels it becomes very interesting: two regions oscillating at the same frequency with a fixed phase relationship are probably talking. Phase-locking measures are a large part of Phase 3 and 4.

Deep dive Bins, zero-padding, and other things people get confused by 3 min

An FFT of N samples at rate fs gives N/2 useful frequency bins spaced fs/N apart. Zero-padding (appending zeros before the FFT) gives more bins but not more resolution; it interpolates the same underlying curve more finely, which is cosmetic. Real resolution comes only from a longer recording. Power in a bin depends on the window and the normalization, which is why absolute PSD values differ between software packages and why you should compare spectra computed the same way.

Recall
Why does a spectrum reveal a sinusoid the eye cannot see in a noisy trace?
The sinusoid puts all its power in one frequency bin while noise spreads its power over every bin, so over a window of a few seconds the sinusoid's bin stands well above the noise floor.
Recall
What determines the frequency resolution of a spectrum, and what does a spectrogram trade for time information?
Resolution in hertz is one over the window length in seconds. A spectrogram uses short windows, gaining time localization and losing frequency sharpness.
Recall
What does Welch's method do and what does it cost?
It averages the spectra of many overlapping short windows, giving a smoother, more trustworthy estimate at the cost of the frequency resolution of the shorter windows.
Explain it to your roommate

Explain what this page was about to your roommate in three sentences. No jargon they would not know.