On this page
- When a static PSD hides non-stationary dynamics
- How the 2D spectrogram heatmap untangles the signal
- Time–frequency trade-off: nperseg, overlap, and FFT zero-padding
- Choosing dB, log₁₀(PSD), or linear scaling and colorbars
- Autoplot vs Igor Pro, MATLAB, and SciPy for STFT spectrograms
- Spectrogram (STFT) in Autoplot
- Frequently asked questions
When a static PSD hides non-stationary dynamics
In a raw 1D time trace (signal_v over time_s below), every oscillation adds together on one vertical amplitude axis. You can spot a brief loudness bump near , yet by eye alone you cannot tell which frequencies exist or whether a pitch is steady or changing.
Computing an averaged 1D power spectrum only reverses the blind spot: pooling all 4 seconds into one frequency curve blurs a moving sweep across a wide flat band and dilutes brief pulses toward the noise floor. To inspect when each frequency turns on, sweeps, or fades—whether tracking seizure onset in clinical EEG spectrograms (Aboyeji et al., 2025) or forecasting peak earthquake ground motion from multi-scale P-wave STFT spectrograms (Hsu and Liu, 2025)—you need time and frequency on separate axes at once.
How the 2D spectrogram heatmap untangles the signal
The Short-Time Fourier Transform (STFT) slices the recording into short, overlapping time windows and runs an FFT power spectrum on each slice (Allen, 1977; Allen and Rabiner, 1977):
where samples set the slice width, tapers the window edges, steps each slice forward in time, and sets the zero-padded frequency grid. Valid frames require uniform sampling (step variation ) across at least 16 finite samples.
Instead of folding all 4 seconds into one 1D curve, stacking every time slice side by side turns the signal into a 2D time–frequency heatmap (Time (s) across, Frequency (Hz) up, color brightness = power):
- Horizontal axis (
Time (s)): when in the recording each slice was measured (0to4 s), matching the horizontal axis of the waveform above. - Vertical axis (
Frequency (Hz)): how fast the signal oscillates at that moment (0 Hzat the bottom up to450 Hzat the top), splitting slow and fast waves vertically rather than adding them together. - Color (
Power (dB re max)): vibration strength at each(time, frequency)cell (0 dBbright yellow = strongest component;-80 dBdark purple = quiet noise floor).
Looking at the spectrogram output below for that exact 1D waveform, all three hidden components separate on sight:
- Flat horizontal yellow stripe at
120 Hz: a steady, unchanging tone oscillating from all the way to . - Rising diagonal yellow band (
30 Hzto340 Hz): a frequency sweep (chirp) starting slow at and pitching linearly upward, crossing the120 Hzcarrier near . - Isolated bright yellow oval at
400 Hzaround1.8 s: the short high-frequency burst that produced the amplitude bump in the raw time trace—pinpointed cleanly in both onset (1.5–2.1 s) and pitch (400 Hz).
Time–frequency trade-off: nperseg, overlap, and FFT zero-padding
Every spectrogram parameter balances how sharply localized ridges look against how closely two simultaneous frequencies can be separated (Gabor, 1946; Harris, 1978):
| Control | Physical role | Typical effect | Watch out for |
|---|---|---|---|
nperseg | Window duration | Longer frames narrow true frequency width () | Excessively long windows blur fast chirps diagonally and widen brief bursts across time |
Overlap | Frame hop | Higher overlap (75%–90%) smooths frame-to-frame transitions | Overlapping segments re-use the same samples and do not improve intrinsic frequency sharpness |
FFT Pad | Zero-padding factor () | Interpolates bin spacing (1×, 2×, 4×) | Finer bin spacing reduces scalloping visual steps but cannot resolve two tones inside one main lobe |
Window & Detrend | Sidelobe taper & per-segment baseline removal | Hann balances resolution and leakage; Constant strips DC drift | Boxcar spills strong narrowband ridges across adjacent frequencies at -13 dB sidelobes |
Notice why FFT Pad works differently from doubling nperseg. Zero-padding inserts interpolated spectral samples cleanly along a single main lobe without observing the signal over a longer duration; if two frequencies differ by less than the window main-lobe width ( for Hann), increasing padding from 1× to 4× renders a smoother ridge without splitting them apart.
Choosing dB, log₁₀(PSD), or linear scaling and colorbars
Raw PSD power spans orders of magnitude between coherent tones and background noise floors, so color mapping directly determines what features stay visible. Three intensity modes address distinct comparisons:
dBrelative to peak (Dyn Range): normalizes power by the peak cell and clamps values below (20to140 dB). UsedBto reveal faint transients and harmonics alongside dominant carriers without zero-floor blowouts.log₁₀(PSD): takes the un-normalized base-10 logarithm of segment density (). Chooselog₁₀(PSD)when comparing signal amplitude across multiple experimental runs on a fixed colorbar range, because normalizing by each trace's own hides global power changes.Linear PSD: plots untransformed directly. Best for checking where dominant energy concentrates when faint sidebands should stay visually suppressed.
Because a spectrogram is rendered inside a 2D color grid, colormap perception and scale discipline follow the same rules as general matrix plots—choose sequential perceptually uniform palettes (Viridis by default) and match colorbar ranges across panels as described in how to make a scientific heat map.
Autoplot vs Igor Pro, MATLAB, and SciPy for STFT spectrograms
Match the tool to whether your task centers on interactive uniform-grid inspection or custom time–frequency research transforms:
| Capability | Autoplot (Spectrogram) | Igor Pro | MATLAB / SciPy |
|---|---|---|---|
| Mac execution | Native Apple silicon (macOS 15+) | 9.05 Intel under Rosetta 2; 10 is Windows-only | Native macOS binaries and Python scripts |
| STFT controls | Window, Detrend, nperseg, Overlap, FFT Pad (1×–4×), Min/Max Freq | FFT / STFT wave procedures in Igor procedures | spectrogram, stft, pspectrum, Wavelet Toolbox (cwt) |
| Intensity scaling | Live switch across dB (Dyn Range), , Linear PSD | Manual log/dB matrix transform after FFT | Computed explicitly before plotting |
| Best role | Interactive spectrogram styling, results readout, and vector export on CSVs | Legacy .pxp/.ibw experiments and custom Igor scripts | Continuous wavelets, reassigned/synchrosqueezed STFTs, cross-spectrograms |
For real uniform-time CSV or delimited recordings on Apple silicon—especially when replacing everyday plotting and spectrogram checks from Intel-only Igor Pro—Autoplot keeps STFT computation, Viridis/sequential colorbars, grid export, and figure formatting in one interactive canvas. Keep MATLAB or custom SciPy scripts when you need continuous wavelet transforms (CWT), reassigned or synchrosqueezed spectra for razor-sharp chirp ridges, phase extraction, or cross-channel coherence.
Spectrogram (STFT) in Autoplot
Autoplot's Spectrogram (STFT) analysis (Layers → Run Analysis → Spectrogram (STFT) inside any Heat Map figure, Plus — free for 30 days) runs windowed STFT PSD computation locally on your Mac:
- Inputs (
Data): choose a finite numericSignal( finite samples) and optional uniformTime (opt.)(step deviation to infer automatically and preserve ), or supply a positiveRate (Hz)when time is omitted. - STFT & scaling controls: select
Window(Hann,Hamming,Blackman,Flat-Top,Boxcar),Detrend(Constant,Linear,None),nperseg(, blank for auto up to256),Overlap(0%–90%),FFT Pad(1×,2×,4×),Scale(dB,log₁₀(PSD),Linear PSD),Dyn Range(20–140 dBindBmode), and optional[Min Freq, Max Freq]in Hz, then clickRun(Rerun). - Results & exports (
Figure Inspector → Results,Visual): inspectfs, , ,nperseg,overlap,nfft, and grid dimensions (F × T), customize colormap and colorbar inAxes/Range/Visual, or export flattened(time, frequency, value)columns toDerived VariablesviaExport Spectrogram Data. AI Assistant Execute also drives Spectrogram setup and runs without sending raw array values off your Mac. - Where it stops: requires uniform 1D real signals ( step variation); continuous wavelets (
CWT), phase/complex STFT outputs, synchrosqueezed transforms, cross-spectrograms, and 2D density/surface fits (disabled while aSpectrogramlayer is selected) require either a separate scalar/joint-density Heat Map layer or a Python/MATLAB script.
Frequently asked questions
| Does increasing FFT Pad improve true frequency resolution? | No: FFT Pad appends zeros to extend the DFT length (), which interpolates closer display bins () along the same spectral main lobe. To genuinely separate two closely spaced sinusoids, increase nperseg so each frame observes more signal cycles. |
|---|---|
| When should I choose log₁₀(PSD) instead of dB? | Choose dB (Dyn Range) when studying relative features inside one trace, because dB rescales power relative to that spectrogram's peak cell . Choose when comparing two separate recordings on an identical color scale so overall signal amplitude shifts remain visible. |
| Why do short transients smear in frequency or narrowband chirps smear in time? | That trade-off is set by the Gabor uncertainty limit: short nperseg windows pinpoint burst onset tightly in time at the expense of wide frequency lobes, whereas long nperseg windows narrow frequency lines while averaging across changing chirp intervals. Tune nperseg for the dominant feature scale, then raise Overlap (75%–90%) for smooth frame stepping. |
| Can Autoplot run continuous wavelet transforms or phase spectrograms? | No: Spectrogram (STFT) computes real one-sided PSD magnitude maps from uniformly sampled 1D signals (scipy.signal.spectrogram). Export derived (time, frequency, value) grids or use PyWavelets / scipy.signal.stft in Python when you need variable-Q wavelet scales, complex phase maps, or reassigned time–frequency ridges. |
Sources
Algorithm details (compute_spectrogram, uniform grid check, offset alignment, scaling="density" / mode="psd" dB clamping, , and Linear PSD modes) and UI labels (Spectrogram (STFT), nperseg, FFT Pad, Dyn Range, Min Freq, Max Freq, Export Spectrogram Data) were verified directly against Autoplot 2.5.2 source (math_logic.py, HeatMapCardRow.swift, HeatMapResultsPanel.swift, and Autoplot's Spectrogram documentation) on 27 November 2026. Underlying STFT computation wraps SciPy's scipy.signal.spectrogram. Time–frequency resolution trade-offs draw on D. Gabor, "Theory of communication. Part 1: The analysis of information," Journal of the Institution of Electrical Engineers — Part III 93(26), 429–441 (1946), DOI 10.1049/ji-3-2.1946.0074; DFT STFT formulation and filter-bank synthesis draw on J. B. Allen, "Short term spectral analysis, synthesis, and modification by discrete Fourier transform," IEEE Transactions on Acoustics, Speech, and Signal Processing 25(3), 235–238 (1977), DOI 10.1109/TASSP.1977.1162950, and J. B. Allen and L. R. Rabiner, "A unified approach to short-time Fourier analysis and synthesis," Proceedings of the IEEE 65(11), 1558–1564 (1977), DOI 10.1109/PROC.1977.10770; window leakage and scalloping loss draw on F. J. Harris, "On the use of windows for harmonic analysis with the discrete Fourier transform," Proceedings of the IEEE 66(1), 51–83 (1978), DOI 10.1109/PROC.1978.10837; and recent biomedical EEG and seismic STFT spectrogram applications draw on S. T. Aboyeji, I. Ahmad, X. Wang, Y. Chen, C. Yao, G. Li, M. C. F. Tong, A. K. Y. Siu, G. Zhao, and S. Chen, "DCSENets: Interpretable deep learning for patient-independent seizure classification using enhanced EEG-based spectrogram visualization," Computers in Biology and Medicine 185, 109558 (2025), DOI 10.1016/j.compbiomed.2024.109558, and T.-Y. Hsu and K.-L. Liu, "Onsite early prediction of peak amplitudes of ground motion using multi-scale STFT spectrogram," Earth, Planets and Space 77, 60 (2025), DOI 10.1186/s40623-025-02194-w.