-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add regression-based approach to removing EOG artifacts #11046
Conversation
Can you make a sibling PR to deprecate https://github.com/mne-tools/mne-sandbox/blob/master/mne_sandbox/preprocessing/eog.py#L6 ? Ignore codespell for now, @drammock is on it |
The example script shows the function in action on the MNE-sample data. For some more thorough evaluation, perhaps https://osf.io/2qgrd/ is better suited. This dataset contains EEG data with the subject performing guided eye movements as well as periods of rest. The idea is that the EOG correction procedure should remove as much signal variation during the eye movements as possible while keeping the resting state data as-is. Here is a script that operates on this dataset: https://gist.github.com/wmvanvliet/8c9bc44d46ebf51a54ea0ef35d97398b And here are the results of that script: Both ICA and this new regression approach seem to perform excellent. |
@larsoner If you have time, could you take a look at the |
Do you think it's worth adding this as a new |
The comparison figures for the external dataset look nice. Can you show which figures the example produces? If they are good enough (i.e. show that regression effectively removes ocular artifacts), then I would not add the new dataset. |
Indeed the figures from the other dataset demonstrate the effectiveness much better. I do like the regression weight from the example though. Would it be possible to create two similar figures like you showed for the other dataset in the left column (eye blinks before and after removal)? |
@wmvanvliet can you share the link to the rendered doc when you have it? 🙏 |
Nice! Please include this figure in the example! |
If we just stick with plain regression, without implementing fancier techniques such as RAAA or SGEYESUB, then the sample dataset is actually fine I think. |
@agramfort working on it right now! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @wmvanvliet! I have some minor suggestions, after that this is good to go! Thanks a lot for this great addition!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, forgot the example. Only some minor things though.
good to go from your end ?
|
CI not happy yet :( |
Can you post links to the rendered docs? |
CI pass! All is ready from my end, unless someone has some more nitpicks. |
You still have |
Sorry for being overzealous in marking your comments as resolved. I indeed missed some things. I went over them again and I think I got them all now. |
Updated example, code is now rendering as it should: https://output.circle-artifacts.com/output/job/7861b8ab-d51b-473f-8a37-37ca66c10e3c/artifacts/0/dev/auto_examples/preprocessing/eog_regression.html |
No problem @wmvanvliet, thanks for going through everything once again! Re the example, sorry that I keep nitpicking, but I think the line
and end with
|
That was intentional. Why should that sentence be a comment and not just a paragraph block? |
That's fine of course, but right now it is not a sentence, that's why I thought it was supposed to be a comment. Can you change it to a proper sentence? |
Done :) |
Perfect, thanks a lot! |
Thanks @wmvanvliet ! |
* upstream/main: MAINT: Fix CircleCI error (mne-tools#11205) [circle deploy] Add regression-based approach to removing EOG artifacts (mne-tools#11046) [DOC, MRG] Minor documentation improvements and remove glossary entry for array-like (mne-tools#11207) Fix `include_tmax` not considered in `mne.io.Raw.crop` to check `tmax` in bounds (mne-tools#11204) MAINT: Fix notebook backend (mne-tools#11206) MRG: Fix displayed Raw duration in Jupyter notebook (mne-tools#11203) add EpochsSpectrum.average() (mne-tools#11198)
* upstream/main: MAINT: Fix CircleCI error (mne-tools#11205) [circle deploy] Add regression-based approach to removing EOG artifacts (mne-tools#11046) [DOC, MRG] Minor documentation improvements and remove glossary entry for array-like (mne-tools#11207) Fix `include_tmax` not considered in `mne.io.Raw.crop` to check `tmax` in bounds (mne-tools#11204) MAINT: Fix notebook backend (mne-tools#11206) MRG: Fix displayed Raw duration in Jupyter notebook (mne-tools#11203) add EpochsSpectrum.average() (mne-tools#11198) reduce memory [circle deploy] (mne-tools#11199) [BUG, MRG] Fix bug in find_bads_muscle (mne-tools#11197) BUG: Fix bug with long legend labels (mne-tools#11181)
…-args * upstream/main: Fix mesh display in tutorial (mne-tools#11200) MAINT: Add arm64 CI using CirrusCI (mne-tools#11209) Fix spatial colors (mne-tools#11201) MAINT: Fix CircleCI error (mne-tools#11205) [circle deploy] Add regression-based approach to removing EOG artifacts (mne-tools#11046) [DOC, MRG] Minor documentation improvements and remove glossary entry for array-like (mne-tools#11207) Fix `include_tmax` not considered in `mne.io.Raw.crop` to check `tmax` in bounds (mne-tools#11204) MAINT: Fix notebook backend (mne-tools#11206) MRG: Fix displayed Raw duration in Jupyter notebook (mne-tools#11203) add EpochsSpectrum.average() (mne-tools#11198)
* upstream/main: (64 commits) MAINT: Better check (mne-tools#11229) MAINT: Fix link and update instantiation note (mne-tools#11228) BUG: Add estimated fiducials when missing / assumed head coords (mne-tools#11212) Fix tfr db (mne-tools#11223) MAINT: Update link (mne-tools#11222) add CPGRL doc section (mne-tools#11216) Don't insert superfluous newlines in subprocess log messages (mne-tools#11219) purge _get_args helper func (mne-tools#11215) Standardize topomap args (mne-tools#11123) MAINT: Ensure no datasets are downloaded in tests (mne-tools#11213) MAINT: Fix Cirrus caching (mne-tools#11211) Fix mesh display in tutorial (mne-tools#11200) MAINT: Add arm64 CI using CirrusCI (mne-tools#11209) Fix spatial colors (mne-tools#11201) MAINT: Fix CircleCI error (mne-tools#11205) [circle deploy] Add regression-based approach to removing EOG artifacts (mne-tools#11046) [DOC, MRG] Minor documentation improvements and remove glossary entry for array-like (mne-tools#11207) Fix `include_tmax` not considered in `mne.io.Raw.crop` to check `tmax` in bounds (mne-tools#11204) MAINT: Fix notebook backend (mne-tools#11206) MRG: Fix displayed Raw duration in Jupyter notebook (mne-tools#11203) ...
This adds the
mne.preprocessing.eog_regression
function to regress EOG channels out of other channels. This provides a way to remove eye artifacts without zapping out a complete PCA or ICA component from the data. This could be useful when you don't have many channels.closes #11028
Todo:
eog_regression
function or.fit()
/.apply()
object.