Skip to content

Conversation

@jona-sassenhagen
Copy link
Contributor

@jona-sassenhagen jona-sassenhagen commented Apr 24, 2019

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

@jona-sassenhagen
Copy link
Contributor Author

@codecov
Copy link

codecov bot commented Apr 25, 2019

Codecov Report

Merging #6211 into master will increase coverage by 2.14%.
The diff coverage is 90.86%.

@@            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

@drammock
Copy link
Member

done pushing commits? title still says WIP

@jona-sassenhagen
Copy link
Contributor Author

done pushing commits? title still says WIP

I guess I need to add more tests and maybe another example, and extend the docs. But the code is ready for review.

Copy link
Member

@drammock drammock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot_2019-04-25_06-37-47

@jona-sassenhagen jona-sassenhagen changed the title WIP plot_compare_evokeds topo functionality MRG plot_compare_evokeds topo functionality Apr 25, 2019
@jona-sassenhagen
Copy link
Contributor Author

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)
Copy link
Contributor Author

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.

Copy link
Member

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)

Copy link
Member

@drammock drammock left a 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)
Copy link
Member

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)

@jona-sassenhagen jona-sassenhagen changed the title MRG plot_compare_evokeds topo functionality WIP plot_compare_evokeds topo functionality Apr 26, 2019
@jona-sassenhagen jona-sassenhagen changed the title WIP plot_compare_evokeds topo functionality MRG plot_compare_evokeds topo functionality Apr 26, 2019
Copy link
Member

@drammock drammock left a 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)

@drammock drammock changed the title MRG plot_compare_evokeds topo functionality MRG +1 plot_compare_evokeds topo functionality Apr 26, 2019
@drammock
Copy link
Member

good to go as soon as CIs come back green. Thanks @jona-sassenhagen for sticking with this one!

@jona-sassenhagen
Copy link
Contributor Author

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,
Copy link
Member

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.

Copy link
Member

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, )

# first, copy to avoid overwriting
styles = deepcopy(styles)
colors = deepcopy(colors)
linestyles = deepcopy(linestyles)
Copy link
Member

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?

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:
Copy link
Member

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.

**styles[condition])
if np.any(d > 0) or all_positive:
any_positive = True
if np.any(d < 0):
Copy link
Member

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)))):
Copy link
Member

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?

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]
Copy link
Member

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)

@agramfort
Copy link
Member

agramfort commented Apr 27, 2019 via email

@agramfort agramfort merged commit 3d33e8e into mne-tools:master Apr 27, 2019
@agramfort
Copy link
Member

thx @jona-sassenhagen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

5 participants