mne-tools / mne-python

MNE: Magnetoencephalography (MEG) and Electroencephalography (EEG) in Python
https://mne.tools
BSD 3-Clause "New" or "Revised" License
2.74k stars 1.33k forks source link

Repairing artifacts with regression - Using the wrong regression coefficients #12977

Closed JacPhe closed 3 days ago

JacPhe commented 5 days ago

Proposed documentation enhancement

In the aforementioned tutorial, under "Subtract the evoked response from the epoch data before regression":

I think that epochs_clean_sub = model_plain.apply(epochs) is incorrect, as this applies the regression coefficients from model_plain, which was trained on the default epochs, rather than epochs.subtract_evoked().

I think it should be epochs_clean_sub = model_sub.apply(epochs) instead. Otherwise, model_sub appears to be redundant.

welcome[bot] commented 5 days ago

Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴

scott-huberty commented 5 days ago

Huh, I think you are right @JacPhe . Would you be up for a PR to fix this?

Also just to be safe, CC'ing @wmvanvliet as the author of that tutorial... On line 152 shouldn't model_plan.apply(...) actually be model_sub.apply(...)?

https://github.com/mne-tools/mne-python/blob/a99aa9f798d878ba144b3f6f3127311841d5d2b5/tutorials/preprocessing/35_artifact_correction_regression.py#L143-L154

JacPhe commented 5 days ago

I've sent a pull request just in case, hopefully that helps!