MRG, BUG: Fix combine evokeds#7869
Conversation
15827ea to
220837f
Compare
| # We can use basic arithmetic to, for example, construct and plot | ||
| # difference ERPs. | ||
| # We can use negative weights in `mne.combine_evoked` to construct difference | ||
| # ERPs. |
There was a problem hiding this comment.
| # ERPs. | |
| # of ERPs. |
There was a problem hiding this comment.
I would say that "difference ERPs" is a valid term on its own, so no need to say "difference of ERPs" :)
mne/evoked.py
Outdated
| weights = np.ones_like(naves) / len(naves) | ||
| else: | ||
| weights = np.array(weights, float) | ||
| weights = np.squeeze(weights).astype(float) |
There was a problem hiding this comment.
| weights = np.squeeze(weights).astype(float) | |
| weights = np.array(weights).astype(float) |
I hate squeeze magic
There was a problem hiding this comment.
I don't see why we would need to use squeeze here anyway…?
There was a problem hiding this comment.
It's not really necessary. My thinking was that we are testing that ndim == 1, and I don't think the docstring explicitly says that weights must be a 1D array, so I thought using squeeze was being generous to the user. I don't mind changing it back though
|
fair enough. I am not enough an ERP person ;)
… |
|
I've examined all of the examples/tutorials that use |
|
Thx @drammock |
|
@drammock shall we backport this? at least the fix in tutorial? |
|
I've been wondering about backporting. The behavior that @SophieHerbst reported was a bug, which is a good reason to backport. On the other hand, this PR also changes the behavior and guidance around how to do evoked subtraction. I'd rather introduce a change like that with a regular release, when people are more likely to read the changelog. I think the latter consideration is stronger for me. @larsoner what is your opinion? |
* simplify/clarify tests * fix weights computation and docstring * simplify grandaverage * better warning * remove redundant test; clarify existing test * clarify tutorial * fix subtractions * clarify tutorial * update what's new * revert squeeze * some tutorial fixes
|
@drammock
(from https://mne.tools/dev/auto_tutorials/evoked/plot_10_evoked_overview.html#combining-evoked-objects, highlight by me) vs contrast = combine_evoked(evoked, weights=[-1, 1]) # Faces - scrambled
...
inverse_operator = make_inverse_operator(contrast.info, forward, noise_cov,
loose=0.2, depth=0.8)
# Compute inverse solution on contrast
stc = apply_inverse(contrast, inverse_operator, lambda2, method, pick_ori=None)As a user, what shall I do? 😭😭😭 |
I'm okay with not backporting
I'm pretty sure |
|
I agree with @larsoner. I am also not so sure it's problematic to use equal
or custom weights as
the nave of the output should still be correct. But maybe it requires
empirical evidence.
|
|
actually I guess you're right... it's only |
|
crossref #7881 |
* upstream/master: (24 commits) WIP: Fix Travis (mne-tools#7906) WIP: Prototype of notebook viz (screencast) (mne-tools#7758) MRG, FIX: Speed up I/O tests, mark some slow (mne-tools#7904) Proper attribution for Blender tutorial (mne-tools#7900) MAINT: Check usage [ci skip] (mne-tools#7902) Allow find_bad_channels_maxwell() to return scores (mne-tools#7845) Warn if NIRx directory structure has been modified from original format (mne-tools#7898) Pin pvyista to 0.24.3 (mne-tools#7899) MRG: Add support for reading and writing sufaces to .obj (mne-tools#7824) Fix _auto_topomap_coords docstring. (mne-tools#7895) MRG, FIX: Ensure Info H5-writeable (mne-tools#7887) Website contents (mne-tools#7889) MRG, ENH: Add mri_resolution="sparse" (mne-tools#7888) MRG, ENH: Allow disabling FXAA (mne-tools#7877) remove "and and" [ci skip] (mne-tools#7882) fix evoked nave → inverse guidance (mne-tools#7881) ENH: Better error messages (mne-tools#7879) FIX : EDF+ Annotation Timestamps missing sub-second accuracy (mne-tools#7875) FIX: Fix get_channel_types (mne-tools#7878) MRG, BUG: Fix combine evokeds (mne-tools#7869) ...
closes #7865
closes #7874
still WIP because I need to check the examples/tutorials to make sure they're all consistent with the docstring. Also needs what's new.