Skip to content

Some channels in PSD plot colors nearly invisible with spatial_colors=True in v1.9.0 #13285

Closed

Description

@Mojackhak

I’ve also encountered the same issue (#6686) with almost white colors when using spatial_colors=True in mne==1.9.0.
As pointed out by bboyth on the MNE Discourse, modifying the _rgb function in
.../env/lib/site-packages/mne/viz/evoked.py helped resolve the issue for me too.

Here’s the modified version of _rgb that worked:

def _rgb(x, y, z):
    """Transform x, y, z values into RGB colors."""
    rgb = np.array([x, y, z]).T
    rgb -= np.nanmin(rgb, 0)
    rgb /= np.maximum(np.nanmax(rgb, 0), 1e-16)  # avoid div by zero
    # Modification to avoid invisible colors:
    # Reduce RGB intensity for overly light colors
    rgb[rgb.sum(axis=1) > 2.5] = rgb[rgb.sum(axis=1) > 2.5] - 0.3
    return rgb

Would it be possible to consider integrating this fix (or a similar safeguard) into a future release?

Image

Activity

  1. larsoner commented on Jun 13, 2025

    @larsoner
    Member

    @Mojackhak seems reasonable to me, do you want to open a PR to add the fix?

  2. Mojackhak commented on Jun 13, 2025

    @Mojackhak
    ContributorAuthor

    Thanks! That sounds great — I've just opened PR #13286 with the fix.

  3. drammock commented on Jun 13, 2025

    @drammock
    Member

    Reminder to us for later: perhaps we'll eventually use https://trygvrad.github.io/gsoc-2024-bivariate-colormaps-summary/ but although part of that work is merged into matplotlib since 3.10, it's not exposed in the API yet :( The "flat" map seems a reasonable choice on first glance.

  4. Mojackhak commented on Jun 13, 2025

    @Mojackhak
    ContributorAuthor

    Thanks for the note — good to know this might be integrated in the future. The "flat" map does look promising!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions