Skip to content

Move evoked topo plot to plot_compare_evokeds #4746

Closed

Description

@jona-sassenhagen

Evoked topoplots should make use of plot_compare_evokeds.
I.e., something like this

%matplotlib inline

import matplotlib.pyplot as plt
import numpy as np

import mne
from mne.datasets import testing
from mne.channels.layout import _find_topomap_coords
from mne.stats.cluster_level import spatio_temporal_cluster_1samp_test as tst
from mne.defaults import DEFAULTS

data_path = testing.data_path()
fname = data_path + "/EEGLAB/test_raw.set"
montage = data_path + "/EEGLAB/test_chans.locs"

event_id = {"rt":1, "square":2}
eog = {"FPz", "EOG1", "EOG2"}
raw = mne.io.eeglab.read_raw_eeglab(fname, preload=True, eog=eog,
                                    montage=montage, event_id=event_id
                                   )
events = mne.find_events(raw)
picks = mne.pick_types(raw.info, eeg=True)
epochs = mne.Epochs(raw, events,  event_id,
                    tmax=.7, picks=picks)
evoked = epochs["square"].average()

from mne.channels.layout import find_layout
layout = find_layout(evoked.info)
pos = layout.pos.copy()

f = plt.figure()
f.set_size_inches((10, 10))

evokeds = {cond:list(epochs[cond].iter_evoked()) for cond in event_id}
ylims = (evoked.data.min() * DEFAULTS["scalings"]["eeg"],
         evoked.data.max() * DEFAULTS["scalings"]["eeg"])
ylims = (-30, 40)
ymax = np.min(np.abs(np.array(ylims)))
for pick, (pos_, ch_name) in enumerate(zip(pos, evoked.ch_names)):
    ax = plt.axes(pos_)
    mne.viz.plot_compare_evokeds(evokeds, picks=pick, axes=ax,
                         ylim=dict(eeg=ylims),
                         show=False,
                         show_sensors=False,
                        show_legend=False,
                         title='');
    ax.set_xticklabels(())
    ax.set_ylabel('')
    ax.set_xlabel('')
    ax.set_yticks((-ymax, ymax))
    ax.spines["left"].set_bounds(-ymax, ymax)
    ax.set_ylim(ylims)
    ax.set_yticklabels('')
    ax.text(-.1, 1, ch_name, transform=ax.transAxes)

ax_l = plt.axes([0, 0] + list(pos[0, 2:]))
mne.viz.plot_compare_evokeds(evokeds, ylim=dict(eeg=ylims), title='', show_sensors=False,
                     picks=0, axes=ax_l, ci=None,
                             show=False)

ax_l.set_yticks((-ymax, ymax))
ax_l.spines["left"].set_bounds(-ymax, ymax)
ax_l.set_ylim(ylims)
ax_l.lines.clear()
ax_l.patches.clear()

unknown-49

Activity

  1. mmagnuski commented on Nov 14, 2017

    @mmagnuski
    Member

    Looks beautiful!

  2. jona-sassenhagen commented on Nov 14, 2017

    @jona-sassenhagen
    ContributorAuthor

    I think so too :)

    I'm not perfectly sure how to integrate it though. (Also I would never use this kind of plot myself.)

  3. jona-sassenhagen commented on Nov 14, 2017

    @jona-sassenhagen
    ContributorAuthor

    But I will try getting around to it eventually.

  4. jona-sassenhagen commented on May 1, 2018

    @jona-sassenhagen
    ContributorAuthor

    @sappelhoff please see here. I'm still working on the code, I can just give you my code and you could take over? It's not entirely trivial though.

  5. sappelhoff commented on May 1, 2018

    @sappelhoff
    Member

    Thanks for the link Jona. I don't know if my taking over would speed up the process but I could certainly give it a try :-)

  6. jona-sassenhagen commented on May 2, 2018

    @jona-sassenhagen
    ContributorAuthor
  7. sappelhoff commented on May 3, 2018

    @sappelhoff
    Member

    What are the steps to be done? It's looking really nice already imo ...

  8. jona-sassenhagen commented on May 3, 2018

    @jona-sassenhagen
    ContributorAuthor

    The problem is making it look nice for multiple layouts and contrasts. i.e., check it on various data ...

    Then it needs to become MNE code. Hopefully it can just become the backend for the current API, i.e., swap it in for the code currently in mne.viz.plot_evoked_topo.

  9. jona-sassenhagen commented on May 31, 2018

    @jona-sassenhagen
    ContributorAuthor

    @sappelhoff would you be able to implement this eventually?

  10. sappelhoff commented on May 31, 2018

    @sappelhoff
    Member

    @jona-sassenhagen ... let's say it's on my list. But if somebody else wants to do it, I wouldn't be sad ;-)

    There is also still #5186 to do for me (although we should maybe re-decide whether it's worth it)

  11. sappelhoff commented on Aug 10, 2018

    @sappelhoff
    Member

    @jona-sassenhagen I think I won't get to it after all, sorry.

  12. jona-sassenhagen commented on Sep 23, 2018

    @jona-sassenhagen
    ContributorAuthor

    @sappelhoff @mmagnuski @agramfort I would expand the API of plot_evoked_topo to be roughly in alignment with plot_compare_evokeds.

    E.g., I would allow dict input ({"condition": list_of_evoekds} etc), and a few of the viz things.

    Makes sense?

  13. agramfort commented on Sep 23, 2018

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

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions