Skip to content

[DO NOT MRG] plot_compare_evoked improved line colouring - #4526

Closed
jona-sassenhagen wants to merge 41 commits into
mne-tools:masterfrom
jona-sassenhagen:plt_comp_ev_seq2
Closed

jona-sassenhagen wants to merge 41 commits into
mne-tools:masterfrom
jona-sassenhagen:plt_comp_ev_seq2

Conversation

@jona-sassenhagen

Copy link
Copy Markdown
Contributor

Redo of #4221

Good for parametric and complex factorial designs.

See gist

@jona-sassenhagen

Copy link
Copy Markdown
Contributor Author

@mmagnuski can you eventually check if the API works for you? I remember your ICON poster

@codecov-io

codecov-io commented Sep 2, 2017 •

Copy link
Copy Markdown

Codecov Report

Merging #4526 into master will decrease coverage by 0.06%.
The diff coverage is 84.95%.

@@            Coverage Diff             @@
##           master    #4526      +/-   ##
==========================================
- Coverage   87.85%   87.79%   -0.07%     
==========================================
  Files         349      349              
  Lines       65819    66194     +375     
  Branches    11319    11503     +184     
==========================================
+ Hits        57826    58112     +286     
- Misses       5119     5186      +67     
- Partials     2874     2896      +22

@agramfort

Copy link
Copy Markdown
Member

I propose to complete this once we have metadata in + kword file in datasets. This gist will make an amazing tutorial ! really nice @jona-sassenhagen 👍

@jona-sassenhagen

Copy link
Copy Markdown
Contributor Author

Yeah, makes sense.

We can in fact reproduce the full analysis in Dufau, Grainger, ... 2015 in a few lines of code with MNE. I'd like to demonstrate how to use the cluster correction, cause it seems to confuse many newcomers, but is very hip in ERPland these days.

@jona-sassenhagen jona-sassenhagen mentioned this pull request Sep 13, 2017
2 tasks done
@agramfort

Copy link
Copy Markdown
Member

@jona-sassenhagen can you rebase?

what's left to do here?

@jona-sassenhagen

Copy link
Copy Markdown
Contributor Author

Well you said:

I propose to complete this once we have metadata in + kword file in datasets

?

@jona-sassenhagen

Copy link
Copy Markdown
Contributor Author

Or do you just mean the tutorial.

@agramfort

agramfort commented Sep 13, 2017 via email

Copy link
Copy Markdown
Member

@larsoner

Copy link
Copy Markdown
Member

Yeah this is highly related to / mutually dependent on #4414, and we don't want that in before release. So we'll have to wait. But after we release, as far as I'm concerned this can go in first then we can simplify #4414

@jona-sassenhagen

Copy link
Copy Markdown
Contributor Author

Eric, try the plot_metadata_epochs tutorial with this :)

@larsoner

larsoner commented Oct 19, 2017 via email

Copy link
Copy Markdown
Member

@jona-sassenhagen

Copy link
Copy Markdown
Contributor Author

I just did both - is there anything wrong?

@jona-sassenhagen

Copy link
Copy Markdown
Contributor Author

Oh god, there are tons of errors.

@larsoner

Copy link
Copy Markdown
Member

You need to make some change (even a trivial rewrite / typo fix) tutorials/plot_epochs_metadata.py otherwise Circle won't re-render it until merge, see:

https://6222-1301584-gh.circle-artifacts.com/0/tmp/circle-artifacts.1VuPluS/html/auto_tutorials/plot_metadata_epochs.html

@jona-sassenhagen

jona-sassenhagen commented Oct 19, 2017 via email

Copy link
Copy Markdown
Contributor Author

@larsoner

Copy link
Copy Markdown
Member

@jona-sassenhagen

Copy link
Copy Markdown
Contributor Author

Ugh, these look terrible :D They're supposed to look like this:

unknown-29

unknown-33

@larsoner

Copy link
Copy Markdown
Member

CircleCI doesn't have viridis, its matplotlib is too old

@jona-sassenhagen

Copy link
Copy Markdown
Contributor Author

Oh wow, we are green, but I need to rebase from my own 2-line PR.

:|

@agramfort

agramfort commented Oct 20, 2017 via email

Copy link
Copy Markdown
Member

@larsoner

Copy link
Copy Markdown
Member

@jona-sassenhagen once it comes back can you check CircleCI and post a link?

@jona-sassenhagen

Copy link
Copy Markdown
Contributor Author

I will try :D

@jona-sassenhagen

Copy link
Copy Markdown
Contributor Author

Hm. Something is wrong here.

@jona-sassenhagen

Copy link
Copy Markdown
Contributor Author

I get the same for my local Python 2.7 :(

@larsoner

Copy link
Copy Markdown
Member

Time to work on those debugging skills

@jona-sassenhagen

Copy link
Copy Markdown
Contributor Author

@mmagnuski

Copy link
Copy Markdown
Member

BTW - is the legend a parasite axis (or something like this)? They are much harder to customize (change position etc.), I thinkI had this problem with plot_joint in the past.

@jona-sassenhagen

Copy link
Copy Markdown
Contributor Author

It's an mpl_toolkits.axes_grid1.inset_locator.inset_axes (if you mean the channels), the function is plot_legend.

@jona-sassenhagen

Copy link
Copy Markdown
Contributor Author

Oh nice. We are green.

@jona-sassenhagen jona-sassenhagen changed the title [WIP] plot_compare_evoked improved line colouring [MRG] plot_compare_evoked improved line colouring Nov 14, 2017
@jona-sassenhagen

Copy link
Copy Markdown
Contributor Author

Any chance we can get this merged before tomorrow morning? :)

Comment thread tutorials/plot_metadata_epochs.py Outdated
@@ -1,4 +1,6 @@
"""
.. _tut_metadata_epochs:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

don't add this, there is a standard ref tag automagically inserted based on filename sphx_glr_auto_tutorials_plot_metadata_epochs.py

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ugh, how did this end up there? Must have come with the rebase or something. I didn't do it manually.

Comment thread tutorials/plot_visualize_evoked.py Outdated
# We plot a MEG channel with a strong auditory response.
#
# For move advanced plotting using :func:`mne.viz.plot_compare_evokeds`
# see also :ref:`tut_metadata_epochs`.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This too - I didn't put it here.

Should the line be changed? @larsoner

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@agramfort did:

cfb5ce6

It's fine to leave the new sentences but remove the _tut_ ref and replace it with the standard one. You can check correctness locally with cd doc/; make html_dev-noplot, you should only see 5 (I think?) warnings about gallery images missing in manual/.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh ok.

@larsoner larsoner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Other than my minor gripes LGTM, but I don't fully appreciate/understand all the use cases, so @mmagnuski I'll rely on your judgment here

Comment thread mne/viz/evoked.py Outdated
if colors is None:
raise ValueError(
"If `split_legend` is True, `colors` must not be None.")
import matplotlib.lines as mlines

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

let's move this to the top of the function so the nested imports / namespace is clear

Comment thread mne/viz/evoked.py Outdated
ax_cb.set_xticks(())
ax_cb.set_ylabel(cmap_label)
fig.cbar = ax_cb
fig.ts_ax = axes

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would prefer to avoid figure.axes cause we have a varying number of axes.

But based on when it's created it should always be the last axis of the figure. It seems cleaner/more standard to get it as figure.axes[-1].

@jona-sassenhagen

Copy link
Copy Markdown
Contributor Author

There, very green.

@mmagnuski

Copy link
Copy Markdown
Member

@jona-sassenhagen I'll take a look this evening, be patient! :)

@jona-sassenhagen

Copy link
Copy Markdown
Contributor Author

Thanks @mmagnuski !

Comment thread mne/viz/evoked.py Outdated
if ci is True:
ci = .95
elif ci is not False and not (isinstance(ci, np.float) or callable(ci)):
raise TypeError('ci must be float or callable, got ' + str(type(ci)))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nitpick: "ci must be None, bool, float or callable ..."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed, merge if you want.

for n_letters in letters:
evokeds[n_letters] = epochs["NumberOfLetters == " + n_letters].average()

style_plot["colors"] = {n_letters: int(float(n_letters))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I like how colors are created now, as a side not the int(float(n_letters)) would not be necessary if NumberOfLetters in metadata was of int type.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, I probably should have done it like that.

@mmagnuski mmagnuski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Very cool, wholeheartedly approve!

@mmagnuski

Copy link
Copy Markdown
Member

This already got at least +3 so far so I'll go ahead and merge.
(but I hope for float color option in the future :) - and my nitpicks could be adressed in this future PR if you agree @jona-sassenhagen)

@jona-sassenhagen

Copy link
Copy Markdown
Contributor Author

Thanks everyone for reviews!

@jona-sassenhagen

Copy link
Copy Markdown
Contributor Author

The travis build timed out ... restarted.

@mmagnuski

Copy link
Copy Markdown
Member

codecov now complains, but previously all was green. My understanding of codecov is quite limited (I am often confused by why for the same PR one time it is green and another it compains) - so I refer to your intuitions @jona-sassenhagen @larsoner.

@agramfort

Copy link
Copy Markdown
Member

@mmagnuski don't merge. I spend a significant of time yesterday to simplify this code.

see #4755

let me know If I miss some commits there and If none I'll close this PR

@agramfort agramfort changed the title [MRG] plot_compare_evoked improved line colouring [DO NOT MRG] plot_compare_evoked improved line colouring Nov 15, 2017
@jona-sassenhagen
jona-sassenhagen deleted the plt_comp_ev_seq2 branch March 10, 2018 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants