Repository navigation
MRG: [DOC] MNE does no longer auto apply average ref - #7474
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.
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.
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.
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: There is a function that uses all the same params except for a couple (e.g., |
|
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 !
… |
Co-Authored-By: Alexandre Gramfort <[email protected]>
|
@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
Co-authored-by: Daniel McCloy <[email protected]>
|
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?