-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
MRG, FIX: avoid spurious "showing first five" message #6288
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
… names (not types)
mne/viz/epochs.py
Outdated
| picks = picks[:5] # take 5 picks to prevent spawning many figs | ||
| else: | ||
| picks = _picks_to_idx(epochs.info, picks) | ||
| picks = [picks] if isinstance(picks, str) else 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.
Breaks some ICA stuff
https://travis-ci.org/mne-tools/mne-python/jobs/530103782
You might be able to just do picks = _picks_to_idx(epochs.info, picks) directly, it should handle single strings just fine.
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.
it's actually the following line that breaks it (the generator expression inside the all()). I'll try to find a better way.
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.
My point is really that instead of making this conditional any smarter (which your next commit did I think), you should just do picks = _picks_to_idx here, as it should already have all of the smartness built in. Then on the next line you know picks is a ndarray of int, and can just check the length.
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.
that would change the behavior. Currently we only truncate to 5 picks if the user passes a channel type. Under your suggestion, if a user asked for 8 specific channels (by name or by index) we would only return them 5 channels.
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.
Currently we only truncate to 5 picks if the user passes a channel type
I would make it so that _picks_to_idx can optionally return how it made the picks (from channel names, channel types, from None, etc.). Then call it with return_how=True and check that here.
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.
OK. I prefer picks='eeg' (or any channel type) returning the GFP since it's consistent with what @jona-sassenhagen implemented for evokeds in #6211 (see here). And since @larsoner says he's fine either way, I'll go ahead and implement that (shouldn't be too much work) and let @agramfort weigh in afterwards.
This will be an API change (same args, different behavior)... my instinct is that it's edge-case behavior anyway (not exactly a bug, but getting plots of 5 arbitrary channels was probably not desired behavior for users anyway) so maybe OK to skip the warning cycle? WDYT?
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.
I think GFP is better for lines than for images because the GFP, not starting at 0, is squished to a small subset of the color range for images. You simply see less. This is not so much an issue for line plots.
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.
ah, good point.
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.
I think GFP is better for lines than for images because the GFP, not starting at 0, is squished to a small subset of the color range for images.
When doing GFP (and really any one-sided data), we should probably switch the colormap to viridis or some other sequential rather than diverging colormap. It will help ameliorate this problem at least somewhat.
Knowing the complexity of our viz code it's entirely possible this will not be an easy change, though, so no need to do it here unless it turns out to be easy and does work well.
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.
For all-positive images like GFP, we actually use Reds here. But maybe Viridis would be better still.
Codecov Report
@@ Coverage Diff @@
## master #6288 +/- ##
==========================================
+ Coverage 88.98% 89.23% +0.24%
==========================================
Files 416 417 +1
Lines 74973 75427 +454
Branches 12353 12419 +66
==========================================
+ Hits 66718 67307 +589
+ Misses 5367 5233 -134
+ Partials 2888 2887 -1 |
|
I'm ok with the PR (review is stylistic), but switching to mean or gfp might be even better. |
| """Test plotting of epochs image.""" | ||
| epochs = _get_epochs() | ||
| epochs.plot_image(picks=[1, 2]) | ||
| epochs.plot_image(picks='mag') |
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.
We could have a test where we count the length of what epochs.plot_image returns too.
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.
I mean, 5 figs, <5 figs, >5 figs.
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.
see my (monster) comment with the table. I'm proposing that we get rid of the magic number 5 and give people what they ask for, but make it harder for them to ask for lots of figs (i.e., they only can get lots if they list channel {names|indices} individually, or pass a group_by dict with lots and lots of keys). We can (should) probably add a note to the docstring warning people not to do too many at once, and if they want to view lots of epochs imagemaps, they should consider the topo version that allows them to click through each sensor one at a time.
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.
+1
I think this table summarizes what the behavior should be. It's different from If so, I think some changes that make sense are:
|
|
Fine by me, okay for you @jona-sassenhagen ? |
|
One further complication: we should think to what extent this applies to more functions, e.g. plot_compare_evokeds and evoked.plot_image. |
|
Let me be more clear, I like @drammock 's long suggestion, but I think we should probably homogenise this across as many plotters as possible. |
|
Okay to just fix these for 0.18, and do the others in 0.19? Or should we just move all to 0.19? I don't think it's worth delaying release to try to get them all, and I'm not sure it will be so easy. |
|
My intuition would be to delay to .19. But if @drammock disagrees, I wouldn't object. |
|
Okay with me, we can backport to 0.18.1 if it ends up being simple enough anyway |
|
I worked on this a bunch yesterday. Give me 1 more day to see if I can wrap it up. If not then I'll ask to just merge the fix to the message.
I agree that it's a good idea to do a similar refactor for all plotters but I don't necessarily agree that it must all be in one PR
…On May 16, 2019 3:51:14 AM AKDT, Eric Larson ***@***.***> wrote:
Okay with me, we can backport to 0.18.1 if it ends up being simple
enough anyway
|
|
@larsoner @jona-sassenhagen I got really close to finishing the big refactor, but realized there won't be time for a proper review of it in time to release. So here's the minimal change that just fixes the info message. |
larsoner
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.
+1 for merging this for 0.18, and doing the big refactoring in 0.19.
Ultimately it's probably a good idea for the big refactoring to happen after release because often corner case viz bugs take a while to manifest and are difficult to catch in testing/review anyway.
the info message
No picks and no groupby, showing the first five channels ...is incorrectly shown when thepicksparameter toepochs.plot_info()is a (list of) channel names (the message should only happen whenpicksis a channel type or list of channel types).on current master, this (wrongly) generates the info message; after this PR it does not:
after this PR, the message is still (correctly) generated for: