Repository navigation
Closed
Labels
Description
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()
Reacted by Mikolaj Magnuski, Stefan Appelhoff and Dano Morrison

Activity
mmagnuski commentedon Nov 14, 2017
Looks beautiful!
jona-sassenhagen commentedon Nov 14, 2017
I think so too :)
I'm not perfectly sure how to integrate it though. (Also I would never use this kind of plot myself.)
jona-sassenhagen commentedon Nov 14, 2017
But I will try getting around to it eventually.
jona-sassenhagen commentedon May 1, 2018
@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.
sappelhoff commentedon May 1, 2018
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 :-)
jona-sassenhagen commentedon May 2, 2018
Sure, go for it. See this gist:
https://nbviewer.jupyter.org/gist/jona-sassenhagen/e54c80e16fab0c5b635f0c08bae6bef3
for my current experiments.
sappelhoff commentedon May 3, 2018
What are the steps to be done? It's looking really nice already imo ...
jona-sassenhagen commentedon May 3, 2018
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.jona-sassenhagen commentedon May 31, 2018
@sappelhoff would you be able to implement this eventually?
sappelhoff commentedon May 31, 2018
@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)
sappelhoff commentedon Aug 10, 2018
@jona-sassenhagen I think I won't get to it after all, sorry.
jona-sassenhagen commentedon 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?
agramfort commentedon Sep 23, 2018