-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
MRG +1 plot_compare_evokeds topo functionality #6211
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
Codecov Report
@@ Coverage Diff @@
## master #6211 +/- ##
==========================================
+ Coverage 87.21% 89.36% +2.14%
==========================================
Files 413 415 +2
Lines 74522 76125 +1603
Branches 12314 12957 +643
==========================================
+ Hits 64998 68031 +3033
+ Misses 6647 5200 -1447
- Partials 2877 2894 +17 |
|
done pushing commits? title still says |
I guess I need to add more tests and maybe another example, and extend the docs. But the code is ready for review. |
drammock
left a comment
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.
|
In that case, I think the user can most easily use iter_topography themselves, or loop over axes and picks and call plot_compare_evokeds manually ... If we want to support a custom layout, we need a whole new kwarg and a bunch of extra infrastructure. We might want to have an example like that though, using make_1020_rois. |
mne/viz/topo.py
Outdated
| if not do_legend: | ||
| ax.set(xticklabels=[], yticklabels=[]) | ||
| plt.setp(ax.get_xticklines(), visible=False) | ||
| plt.setp(ax.get_yticklines(), visible=False) |
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.
The legend only makes sense if you have ticks on the axes really.
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.
same comment as above about state machine vs obj-oriented approach:
tklines = list(ax.get_xticklines()) + list(ax.get_yticklines())
list(tk.set_visible(False) for tk in tklines)
drammock
left a comment
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.
LGTM as long as CIs are green
mne/viz/topo.py
Outdated
| if not do_legend: | ||
| ax.set(xticklabels=[], yticklabels=[]) | ||
| plt.setp(ax.get_xticklines(), visible=False) | ||
| plt.setp(ax.get_yticklines(), visible=False) |
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.
same comment as above about state machine vs obj-oriented approach:
tklines = list(ax.get_xticklines()) + list(ax.get_yticklines())
list(tk.set_visible(False) for tk in tklines)
drammock
left a comment
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.
can you find a way to test lines 159-161? Otherwise +1 for merge (assuming green CIs)
|
good to go as soon as CIs come back green. Thanks @jona-sassenhagen for sticking with this one! |
|
Thank you @drammock , @mmagnuski can you do another pass? |
| this_evokeds = evokeds[cond] | ||
| # this will fail if evokeds do not have the same structure | ||
| # (e.g. channel count) | ||
| res = _get_data_and_ci(this_evokeds, scaling=scaling, picks=picks, |
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.
can you write
data, ci = _get_data_and_ci(...)
it makes it explicit what is returned.
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.
then _get_data_and_ci would have to return data, None when no ci is requested, currently it returns (data, )
mne/viz/evoked.py
Outdated
| # first, copy to avoid overwriting | ||
| styles = deepcopy(styles) | ||
| colors = deepcopy(colors) | ||
| linestyles = deepcopy(linestyles) |
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.
you don't see to overwrite in this function. Can you do the copies just before the overwrites so it's clearer why you need it?
mne/viz/evoked.py
Outdated
| d = data_dict[condition].T | ||
| ax.plot(times, d, zorder=1000, label=condition, clip_on=False, | ||
| **styles[condition]) | ||
| if np.any(d > 0) or all_positive: |
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.
you should write:
if all_positive or np.any(d > 0):
so the np.any(d > 0) is done again once all_positive is True. It saves some computation.
mne/viz/evoked.py
Outdated
| **styles[condition]) | ||
| if np.any(d > 0) or all_positive: | ||
| any_positive = True | ||
| if np.any(d < 0): |
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.
idem. You should not need to do this computation once any_negative has been set to True
| (picks == 'meg' or picks in _DATA_CH_TYPES_SPLIT) or | ||
| (isinstance(picks, Iterable) and | ||
| all(pick == 'meg' or pick in _DATA_CH_TYPES_SPLIT | ||
| for pick in picks)))): |
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.
can you add a comment to explain in which case gfp is necessary?
mne/viz/evoked.py
Outdated
| for _ in range(len(ch_types))) | ||
| else: | ||
| axes = (plt.subplots(figsize=(8, 6))[1] for _ in range(len(ch_types))) | ||
| axes = ["topo" for _ in ch_types] |
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.
axes = ["topo"] * len(ch_types)
|
ok. Then maybe don't write res[-1] but rather res[1]
… |

Another attempt. It's not really hard, but it's my 3rd attempt so ...
mne.viz.plot_compare_evokeds gains the ability to plot to a topographical layout.
This will be slow for MEG data, but is often used for ERP papers.
Not ready for reviews yet.
Closes #4746
Closes #5746
Closes #6166
Closes #6039
Redo of #5568