-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
MRG: [DOC] MNE does no longer auto apply average ref #7474
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
Conversation
| # XXX: IS THIS TRUE? | ||
| # For these reasons, when performing inverse imaging, *MNE-Python will | ||
| # automatically average-reference the EEG channels if they are present and no | ||
| # reference strategy has been specified*. If you want to perform inverse |
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.
note: I am uncertain about how to change the lines above. Will MNE-Python or will it NOT apply auto average refs?
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.
As far as I can tell, it is not automatically applied:
_check_referenceis called in_apply_inversehere_check_reference(here) calls_needs_eeg_average_ref_proj(here), which returns True if (1) there are EEG channels present, and (2) a custom ref has not been applied, and (3) EEG average reference proj is not already there.
Instead, the user will get a ValueError.
In fact, it doesn't even seem to be possible any more to avoid this constraint by setting average reference to an empty list:
raw = mne.io.read_raw_fif(sample_data_raw_file, verbose=False).crop(tmax=30).load_data()
raw = raw.set_eeg_reference([])
mne.minimum_norm.inverse._check_reference(raw)
# ValueError: EEG average reference is mandatory for inverse modeling, use set_eeg_reference method.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.
Thanks @drammock
Codecov Report
@@ Coverage Diff @@
## master #7474 +/- ##
=======================================
Coverage 90.08% 90.08%
=======================================
Files 454 454
Lines 82539 82608 +69
Branches 13051 13066 +15
=======================================
+ Hits 74353 74420 +67
- Misses 5360 5361 +1
- Partials 2826 2827 +1 |
|
mne-python/mne/channels/channels.py Line 281 in 25f6e5e
class SetChannelsMixin(MontageMixin) has a set_eeg_reference method which is just pointing to mne.set_eeg_reference.
Instead of duplicating the docstring in that class method, can we somehow "import it" from the original |
You can take a look at |
|
Cool, this decorator would be perfect for it: Line 900 in 25f6e5e
except for two things:
perhaps the decorator could be extended with an optional parameter to delete a list of params by indices (currently, it's only deleting the first param, index 0) ... and extend the param deletion to a deletion of return values as well? |
Maybe but it's not too difficult just to split the docstring into needed parts. Also we have to be wary of adding complexity to our docstring modifiers since they are executed on import. See how I dealt with this sort of thing recently in MaxFilter: https://github.com/mne-tools/mne-python/blob/master/mne/preprocessing/maxwell.py#L63-L93 There is a function that uses all the same params except for a couple (e.g., https://github.com/mne-tools/mne-python/blob/master/mne/utils/docs.py#L298-L384 |
|
okay, thanks. Ready from my side. |
|
@sappelhoff you have a "double line break" error in the docstring test. to iterate more quickly to find a solution, you can do |
I tried several things now but couldn't find the issue :-/ |
|
ok !
… |
|
@sappelhoff I fixed the double line break error (locally, at least). The problem was that there was a line break between the end of the |
cd8a202 to
8e396b9
Compare
|
Thanks a lot @drammock |
|
Thanks @sappelhoff |
closes #7471
These are the files I could catch that did still assume MNE-Python to auto apply an average ref projection. Also, the docstr of
set_eeg_referencewas still assuming that.I wasn't sure with
tutorials/preprocessing/plot_55_setting_eeg_reference.py--> see my inline "todo" comment there marked withXXXPS: What was the PR that removed the auto average ref behavior of MNE?