Skip to content

Conversation

@HuseyinOrkun
Copy link
Contributor

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.

…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
@welcome
Copy link

welcome bot commented Aug 9, 2022

Hello! 👋 Thanks for opening your first pull request here! ❤️ We will try to get back to you soon. 🚴🏽‍♂️

@HuseyinOrkun HuseyinOrkun marked this pull request as ready for review August 9, 2022 12:14
@HuseyinOrkun HuseyinOrkun changed the title [WIP, ENH] Use spatial_colors by default in Evoked.plot() [ENH] Use spatial_colors by default in Evoked.plot() Aug 9, 2022
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.

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

@agramfort agramfort left a comment

Choose a reason for hiding this comment

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

@HuseyinOrkun you'll also need to add a line in latest.inc file to document the improvement.

- Fixes comment in evoked.py
@drammock
Copy link
Member

before this gets merge, I'd still like to get other devs' opinion on this question:

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 the value of picks as well.

@drammock
Copy link
Member

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 RuntimeWarning? That probably shouldn't happen... I'll look at your code now.

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.

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.

@hoechenberger
Copy link
Member

before this gets merge, I'd still like to get other devs' opinion on this question:

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 the value of picks as well.

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

@drammock
Copy link
Member

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?

@hoechenberger
Copy link
Member

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?

@drammock
Copy link
Member

drammock commented Aug 12, 2022

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:

  1. Ignore picks when auto-setting spatial colors
  2. If picks is just one single channel, spatial_colors="auto" becomes False.

Anything else seems either too arbitrary or too much "magic"

@hoechenberger
Copy link
Member

If picks is just one single channel, spatial_colors="auto" becomes False.

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
@HuseyinOrkun HuseyinOrkun changed the title [ENH] Use spatial_colors by default in Evoked.plot() [WIP, ENH] Use spatial_colors by default in Evoked.plot() Aug 25, 2022
@HuseyinOrkun HuseyinOrkun marked this pull request as draft August 25, 2022 14:28
@HuseyinOrkun HuseyinOrkun changed the title [WIP, ENH] Use spatial_colors by default in Evoked.plot() [ENH] Use spatial_colors by default in Evoked.plot() Aug 25, 2022
@HuseyinOrkun HuseyinOrkun marked this pull request as ready for review August 26, 2022 06:10
@HuseyinOrkun HuseyinOrkun requested review from agramfort, drammock and hoechenberger and removed request for agramfort, drammock and hoechenberger September 5, 2022 16:06
Copy link
Member

@agramfort agramfort left a comment

Choose a reason for hiding this comment

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

Lets see if CIs are green.

fixes duplicate line
@HuseyinOrkun HuseyinOrkun changed the title [ENH] Use spatial_colors by default in Evoked.plot() [MRG, ENH] Use spatial_colors by default in Evoked.plot() Sep 6, 2022
@HuseyinOrkun
Copy link
Contributor Author

Ready to be reviewed

Copy link
Member

@hoechenberger hoechenberger left a comment

Choose a reason for hiding this comment

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

Thanks, great work! I added a few suggestions for phrasing. Otherwise I think this looks good!

HuseyinOrkun and others added 3 commits September 7, 2022 11:07
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>
@hoechenberger hoechenberger enabled auto-merge (squash) September 7, 2022 09:42
@hoechenberger hoechenberger merged commit 879829e into mne-tools:main Sep 7, 2022
@welcome
Copy link

welcome bot commented Sep 7, 2022

🎉 Congrats on merging your first pull request! 🥳 Looking forward to seeing more from you in the future! 💪

drammock added a commit that referenced this pull request Sep 9, 2022
drammock added a commit that referenced this pull request Sep 9, 2022
drammock pushed a commit to drammock/mne-python that referenced this pull request Sep 23, 2022
…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>
@drammock drammock mentioned this pull request Sep 23, 2022
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.

Use spatial_colors by default in Evoked.plot()

4 participants