Skip to content

MRG, ENH: Use overlap-add in spectrum_fit mode - #7609

Merged
drammock merged 3 commits into
mne-tools:masterfrom
larsoner:spectrum-fit
Aug 11, 2020
Merged

drammock merged 3 commits into
mne-tools:masterfrom
larsoner:spectrum-fit

Conversation

@larsoner

Copy link
Copy Markdown
Member

Closes #7577.

Based on some local testing I'm not convinced it works. But @yjmantilla @sappelhoff @mmagnuski if you want to try it just pass filter_length='10s' or whatever to notch_filter. Maybe this will make it easier for people to test against cleanline or other implementations, and/or push fixes.

@yjmantilla

Copy link
Copy Markdown

Thanks , Ive been really busy but I will test this as soon as I can.

@christian-oreilly

Copy link
Copy Markdown
Contributor

I did not do a full test and rigorous comparison with Matlab cleanline, but using this PR with pyprep, it worked quite well. Before these changes, pyprep was hanging forever because of the spectrum_fit notch filtering (#7577). With this modif (and the corresponding modif in pyprep) it ran in an acceptable time and the results look reasonable.

PSD for the original data:

image

I am generally not a big fan of notch filters because they clearly over-filter. Here is the result with a standard firwin MNE notch-filter.

image

The spectral distortion is arguably even worst than on the original spectrum. Now, using the spectrum_fit through pyprep :

image

There is still a bit of overfitting, but much better. In any case, the result seems to agree with what it aims to do.

@larsoner larsoner added this to the 0.21 milestone Aug 1, 2020
@larsoner larsoner changed the title WIP, ENH: Use overlap-add in spectrum_fit mode MRG, ENH: Use overlap-add in spectrum_fit mode Aug 3, 2020
@larsoner

larsoner commented Aug 3, 2020

Copy link
Copy Markdown
Member Author

Changing this to MRG then. I think any other fixes would be to the basic routines and can be in separate PRs. This already seems to help fix something that is broken/missing in master.

@larsoner

Copy link
Copy Markdown
Member Author

Rebased again. Should be ready for review/merge @agramfort

@agramfort agramfort left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also could we have an example or tutorial showing what it does to data?

Comment thread mne/utils/docs.py Resolved
@larsoner

Copy link
Copy Markdown
Member Author

@agramfort done:

https://21675-1301584-gh.circle-artifacts.com/0/dev/auto_tutorials/preprocessing/plot_30_filtering_resampling.html#power-line-noise

Also fixed a bug with inplace division that was making it work less well for weird sample rates -- @christian-oreilly you might want to re-test it on your data. It should give better results now.

@agramfort agramfort left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@drammock ok for you the doc edits ?

@christian-oreilly

christian-oreilly commented Aug 11, 2020 •

Copy link
Copy Markdown
Contributor

Also fixed a bug with inplace division that was making it work less well for weird sample rates -- @christian-oreilly you might want to re-test it on your data. It should give better results now.

Thanks @larsoner I'll rerun PyPrep on my dataset with the master once this branch is merged.

@drammock drammock left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@drammock
drammock merged commit 5898459 into mne-tools:master Aug 11, 2020
@drammock

Copy link
Copy Markdown
Member

thanks @larsoner

@larsoner
larsoner deleted the spectrum-fit branch August 11, 2020 18:30
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.

RFC: Remove "spectrum_fit" from notch filter

5 participants