[MRG, ENH] Use spatial_colors by default in Evoked.plot()#11017
[MRG, ENH] Use spatial_colors by default in Evoked.plot()#11017hoechenberger merged 18 commits intomne-tools:mainfrom HuseyinOrkun:spatial_colors_by_default_in_Evoked.plot()
Conversation
…ot(). Which makes spatial_colors True if channel locations exists and False otherwise. Changes docstring in plot_evoked() to include string too Adds option chek to plot_evoked for spatial_colors argument
|
Hello! 👋 Thanks for opening your first pull request here! ❤️ We will try to get back to you soon. 🚴🏽♂️ |
drammock
left a comment
There was a problem hiding this comment.
I made a couple suggestions below. I also want to ask: what should happen when user passes picks? For example, we probably don't want spatial_colors when user passes just one or a few channels as a pick. But we probably do want spatial_colors when user passes picks='mag' or picks='eeg' (i.e., all channels of one type). So I think setting spatial_colors automatically maybe should take into account picks as well. @agramfort (or other devs) what is your opinion here?
changes argument definition from str to 'auto'
agramfort
left a comment
There was a problem hiding this comment.
@HuseyinOrkun you'll also need to add a line in latest.inc file to document the improvement.
- Fixes comment in evoked.py
|
before this gets merge, I'd still like to get other devs' opinion on this question:
|
|
also, there are a lot of CI errors, here are links to a couple:
FYI our tests treat any warning as an error, unless the warning is explicitly caught/expected in the test. From a quick glance at the error summary linked above, it appears that you're raising a |
There was a problem hiding this comment.
the RuntimeWarnings seen in the CI errors indicate that one of our tests does not specify a value for spatial_colors (so they assume the old default of False). Fixed by changing the test to explicitly say spatial_colors=False probably?
The other errors you'll need to dig a bit deeper, not obvious to me why your changes here would cause the shape mismatches or the "setting array element with sequence" errors.
plot_joint() always uses spatial colors, hence unless we want to implement an inconsistency, we should either use spatial colors in evoked.plot() by default (without further preconditions), or we should reconsider plot_joint() as well |
|
Ok, I'm fine changing both of we have to. So then what would you recommend @hoechenberger? Do you think we should take picks into account or not? |
I think taking picks into account would create some sort of convolutional interaction between the two parameters. I do see your point thought that if you only have very few or a single trace, defaulting to colors may not be great. How about introducing an arbitrary threshold of, say, 3 or 5 (or even 1?); and spatial_colors defaulting to None, which will act as True for n_chs > threshold, and as False otherwise? |
After thinking more about this and reading your ideas, I'm leaning towards one of 2 possibilities:
Anything else seems either too arbitrary or too much "magic" |
I like this! |
…1, spatial_colors 'auto' becomes False - Adds spatial_colors = False to relevant tests to avoid errors arising from the change in the default argument - Fixes latest.inc issue
- Removes some wrong arguments
Adds a default 'auto' option for spatial_colors argument in Evoked.plot(). Which makes spatial_colors True if channel locations exists and False otherwise. Moves logic for checking spatial_colors argument to a private function named _check_spatial_colors. Changes docstring in plot_evoked() to include string. Adds option check to plot_evoked for spatial_colors argument. Adds changes to doc changes Adds logic for checking the number of picks, if number of picks is 1, spatial_colors 'auto' becomes False Adds spatial_colors = False to relevant tests to avoid errors arising from the change in the default argument Adds check if picks length is one or picks is None
fixes duplicate line
|
Ready to be reviewed |
hoechenberger
left a comment
There was a problem hiding this comment.
Thanks, great work! I added a few suggestions for phrasing. Otherwise I think this looks good!
Co-authored-by: Richard Höchenberger <richard.hoechenberger@gmail.com>
Co-authored-by: Richard Höchenberger <richard.hoechenberger@gmail.com>
Co-authored-by: Richard Höchenberger <richard.hoechenberger@gmail.com>
|
🎉 Congrats on merging your first pull request! 🥳 Looking forward to seeing more from you in the future! 💪 |
…11017) * Adds a default 'auto' option for spatial_colors argument in Evoked.plot(). Which makes spatial_colors True if channel locations exists and False otherwise. Changes docstring in plot_evoked() to include string too Adds option chek to plot_evoked for spatial_colors argument * simplifies code in _plot_evoked() changes argument definition from str to 'auto' * Fixes style issue * - Adds changes to doc changes - Fixes comment in evoked.py * - Fix to the location check logic * - Adds logic for checking the number of picks, if number of picks is 1, spatial_colors 'auto' becomes False - Adds spatial_colors = False to relevant tests to avoid errors arising from the change in the default argument - Fixes latest.inc issue * - Adds check if picks is None - Removes some wrong arguments * - styling * [ENH] Use spatial_colors by default in Evoked.plot() mne-tools#11017 Adds a default 'auto' option for spatial_colors argument in Evoked.plot(). Which makes spatial_colors True if channel locations exists and False otherwise. Moves logic for checking spatial_colors argument to a private function named _check_spatial_colors. Changes docstring in plot_evoked() to include string. Adds option check to plot_evoked for spatial_colors argument. Adds changes to doc changes Adds logic for checking the number of picks, if number of picks is 1, spatial_colors 'auto' becomes False Adds spatial_colors = False to relevant tests to avoid errors arising from the change in the default argument Adds check if picks length is one or picks is None * [ENH] Use spatial_colors by default in Evoked.plot() (mne-tools#11017) Adds a default 'auto' option for spatial_colors argument in Evoked.plot(). Which makes spatial_colors True if channel locations exists and False otherwise. Moves logic for checking spatial_colors argument to a private function named _check_spatial_colors. Changes docstring in plot_evoked() to include string. Adds option check to plot_evoked for spatial_colors argument. Adds changes to doc changes Adds logic for checking the number of picks, if number of picks is 1, spatial_colors 'auto' becomes False Adds spatial_colors = False to relevant tests to avoid errors arising from the change in the default argument Adds check if picks length is one or picks is None * Update latest.inc fixes duplicate line * Update doc/changes/latest.inc Co-authored-by: Richard Höchenberger <richard.hoechenberger@gmail.com> * Update mne/viz/evoked.py Co-authored-by: Richard Höchenberger <richard.hoechenberger@gmail.com> * Update mne/viz/evoked.py Co-authored-by: Richard Höchenberger <richard.hoechenberger@gmail.com> * Update doc/changes/latest.inc Co-authored-by: Richard Höchenberger <richard.hoechenberger@gmail.com>
Reference issue
Fixes #10612 with respect to comment
What does this implement/fix?
Adds a default 'auto' option for spatial_colors argument in Evoked.plot().
Which makes spatial_colors True if channel locations exists and False otherwise.
Changes docstring in plot_evoked() to include string
Adds option chek to plot_evoked for spatial_colors argument
Additional information
Any additional information you think is important.