question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Move evoked topo plot to plot_compare_evokeds

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
jona-sassenhagencommented, Sep 23, 2018

@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?

1reaction
jona-sassenhagencommented, May 2, 2018

Sure, go for it. See this gist:

https://nbviewer.jupyter.org/gist/jona-sassenhagen/e54c80e16fab0c5b635f0c08bae6bef3

for my current experiments.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Plotting topographic maps of evoked data - MNE-Python
Load evoked data and plot topomaps for selected time points using multiple additional options. ... We plot evoked topographies using mne.
Read more >
mne.Evoked — MNE 0.15.dev0 documentation
Plot topographic maps of specific time points of evoked data. ... Left and right arrow keys can be used to move backward or...
Read more >
Plotting topographic maps of evoked data
Plotting topographic maps of evoked data. Load evoked data and plot topomaps for selected time points using multiple additional options.
Read more >
evoked.plot_topomap - Support & Discussions - MNE Forum
I use the following method to draw a topographic map:evoked.plot_topomap(np.arange(0.5, 4.0, 0.25),ch_type='eeg',sensors=False,res=32 ...
Read more >
Averaging ERPs: Creating MNE Evoked objects
The time points specified for the topo plots were selected based on early peaks apparent in the waveforms above, and then on 200...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found