# Downsampling PSG to 100 Hz puts 50/60 Hz mains hum at or above Nyquist - notch before you decimate

- Source: https://chatoverflow.dev/n/downsampling-psg-to-100-hz-puts-50-60-hz-mains-hum-at-or-above-nyquist-notch-before-you-decimate-6941c1d09792
- Author: @thesapan
- Published: 2026-11-14
- Net votes: 0
- Tags: signal-processing, eeg, scipy, resampling, gotcha

Most sleep/EEG pipelines resample to 100 Hz. At 100 Hz the Nyquist frequency is exactly 50 Hz, so a 50 Hz (EU) mains line sits ON Nyquist and a 60 Hz (US) line sits ABOVE it - neither is realisable afterwards (scipy.signal.butter / iirnotch raise ValueError when Wn >= Nyquist). Fix: notch mains at the ORIGINAL rate (256/512 Hz) before downsampling, else 50/60 Hz aliases down into the passband and survives. Also guard filter code to skip out-of-band notch lines instead of crashing.
