You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
compute_spectra: a detrend argument, and a home without matplotlib #689
At edf694c, compute_spectra (functions/sigprocfunc/spectopo.py) calls scipy's welch with detrend=False, as EEGLAB's spectopo does, and has no argument to change that. A caller that needs Welch's method with each window detrended by its own mean (scipy's detrend="constant") cannot get it from eegprep. NEMAR's nemar-spectrum plugin needs exactly that, because its spectrum view specifies a mean detrend and leaves out the 0 Hz row (nemarOrg/nemar-process#91, epic nemarOrg/nemar-cli#2324). For now the plugin cuts the Welch windows itself, removes each window's mean, and passes each window to compute_spectra as one epoch of a 3-D call. The result matches scipy's welch(detrend="constant") within 1e-9 dB, but the caller is repeating work that welch already does.
Requests:
Add a detrend argument to compute_spectra and pass it through to welch (and to spectopo if that is convenient). Keep the default at False so EEGLAB parity is unchanged.
Move compute_spectra, or the numeric core it calls, out of spectopo.py into a module that does not import matplotlib. spectopo.py imports matplotlib.pyplot at module level, so a headless pipeline that only wants the numbers also loads a plotting library. The current import path could stay as a re-export.
Once a commit includes the argument, nemar-process will re-pin eegprep and drop its own window cutting; a strict xfail there turns green on that day.
Agentic AI tools were used. Workflows follow the Research Skills (doi:10.5281/zenodo.20696515). The author assumes full responsibility for this content and associated changes.
Add keyword detrend (False | "constant" | "linear") to compute_spectra, forwarded to scipy.signal.welch. Default unchanged, so EEGLAB parity is preserved. spectopo signature left unchanged (EEGLAB-mirrored).
Test: detrend="constant" matches welch(..., detrend="constant") within 1e-9 dB and removes a DC offset.
Activity
claude commentedon Nov 25, 2026
🤖 Plan:
compute_spectralives insrc/eegprep/functions/sigprocfunc/spectra.py(no Matplotlib import, Export headless spectrum summaries #603);spectopo.pyre-exports it.detrend(False|"constant"|"linear") tocompute_spectra, forwarded toscipy.signal.welch. Default unchanged, so EEGLAB parity is preserved.spectoposignature left unchanged (EEGLAB-mirrored).detrend="constant"matcheswelch(..., detrend="constant")within 1e-9 dB and removes a DC offset.Name sccn/eegprep#689 for the detrend gap
Add detrend argument to compute_spectra
P6: nemar-quality and nemar-spectrum plugins (#91)