Skip to content

Add line-noise removal - #9

Merged
cbrnr merged 1 commit into
mainfrom
line-noise
Sep 4, 2026
Merged

cbrnr merged 1 commit into
mainfrom
line-noise

Conversation

@cbrnr

@cbrnr cbrnr commented Sep 4, 2026

Copy link
Copy Markdown
Owner

This implementation is roughly 50x faster than MNE-Python's notch_filter(method="spectrum_fit"). On a real-world data set (around 1 hour of data), this implementation takes around 1.4 seconds, whereas the MNE-Python implementation takes around 70 seconds.

@cbrnr

cbrnr commented Sep 4, 2026

Copy link
Copy Markdown
Owner Author

@sappelhoff maybe something you want to include in PyPREP?

@cbrnr
cbrnr merged commit 9304cdc into main Sep 4, 2026
10 checks passed
@cbrnr
cbrnr deleted the line-noise branch September 4, 2026 09:25
@sappelhoff

Copy link
Copy Markdown

Hi @cbrnr thanks for the tag.

I would have to check whether we still use the mne method in the codebase there. If we do, then switching to your revamp here would be a welcome contribution!

@cbrnr

cbrnr commented Sep 4, 2026

Copy link
Copy Markdown
Owner Author

Yes, you are using mne.filter.notch_filter(method="spectrum_fit"): https://github.com/sappelhoff/pyprep/blob/main/pyprep/prep_pipeline.py#L209-L259

@sappelhoff

Copy link
Copy Markdown

Actually, is there a reason you did not replace the mne version with this one?

@cbrnr

cbrnr commented Oct 8, 2026

Copy link
Copy Markdown
Owner Author

Yes, because (1) it doesn't produce the exact same results and (2) it takes too long until it is released (I needed it now).

@sappelhoff

Copy link
Copy Markdown

ok, understood. For pyprep, I see the benefit of adopting this, except that the pins in this package are a bit too strong for me, and I would add a couple more dependencies that would blow pyprep up. So I am thinking of vendoring the code instead (with proper license attribution, of course).

@cbrnr

cbrnr commented Oct 9, 2026

Copy link
Copy Markdown
Owner Author

If you are more specific about the pins and dependencies maybe we can relax them?

@sappelhoff

Copy link
Copy Markdown

If you are more specific about the pins and dependencies maybe we can relax them?

I'll come back to you about this if the mne-route fails (i.e., if nobody other than us wants to replace the old spectrum fit with your new code there).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants