Skip to content

Vertical placement of channel traces seems off in raw butterfly plot #10083

Closed

Description

@hoechenberger

MWE:

# %%
from pathlib import Path
import mne
import numpy as np


sample_dir = Path(mne.datasets.sample.data_path())
sample_fname = sample_dir / 'MEG' / 'sample' / 'sample_audvis_raw.fif'
raw = mne.io.read_raw_fif(sample_fname, preload=True)

# %%

fig = (
    raw.copy()
       .pick_types(eeg=True, eog=True, stim=True)
       .plot(butterfly=True, show_scrollbars=False, start=0,
             duration=1, show=False)
)

output

It appears as if the stim channel has a lot of signals, and the EOG channel were flat.

However, the following code reveals that this ain't so:

# %%
fig = (
    raw.copy()
       .pick_types(stim=True)
       .plot(butterfly=True, show_scrollbars=False, start=0,
             duration=1, show=False)
)

output

# %%
fig = (
    raw.copy()
       .pick_types(eog=True)
       .plot(butterfly=True, show_scrollbars=False, start=0,
             duration=1, show=False)
)

output

cc @drammock

Activity

  1. larsoner commented on Dec 3, 2021

    @larsoner
    Member

    It appears as if the stim channel has a lot of signals, and the EOG channel were flat.

    How do you know which is supposed to be which? To me I see three sets of signals, which I'd expect. But I wouldn't expect it to be in the order you gave in pick_types because that function does not reorder channels, or set the plotting order.

    If you want specifically ordered channels, you need to pass order=..., probably in your case something like:

    order = np.concatenate([
        mne.pick_types(raw.info, eeg=True),
        mne.pick_types(raw.info, eog=True),
        mne.pick_types(raw.info, stim=True)])
    raw.plot(order=order)
    

    gets you closer to what you want. However, I'm not sure if butterfly will respect this, it might just be non-butterfly mode.

    If this is the case, I would just update the doc for the order param to say that it isn't used in butterfly mode, because butterfly mode has to group by channel type. (I guess we could go based on the order we see each channel type first in the instance, but I think this has disadvantages, too, so probably shouldn't be the default.)

  2. hoechenberger commented on Dec 3, 2021

    @hoechenberger
    MemberAuthor

    How do you know which is supposed to be which?

    Based on the ordinate labels. The respective butterfly traces should oscillate around the respective channel type label, or be clipped if they're exceeding a certain amplitude.

    It's misleading if, like in the first picture, the eog label is perfectly aligned with a flat line, when in fact this line represents the stim channels.

    Similarly, the labelling seems to indicate there's many traces in the stim channels, while actually these belong to eeg.

    And the EOG trace is centered around the eeg label.

  3. hoechenberger commented on Dec 3, 2021

    @hoechenberger
    MemberAuthor

    @larsoner Will you be around at today's dev meeting? We can discuss there.

  4. larsoner commented on Dec 3, 2021

    @larsoner
    Member

    Oh wow I didn't even see the labels because of image transparency and GitHub dark mode. Agreed those labels are wrong :)

  5. larsoner commented on Dec 3, 2021

    @larsoner
    Member

    No I can't, but it seems like a straightforward bug to me. The fix is hopefully similarly straightforward, but with viz, who knows!

  6. hoechenberger commented on Dec 3, 2021

    @hoechenberger
    MemberAuthor

    No I can't,

    Bummer!

    The fix is hopefully similarly straightforward, but with viz, who knows!

    Yeah I have no idea honestly :) Maybe @drammock has an immediate intuition?

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions