in neural/visuals.py [0:0]
def plot_score_per_time_topo(scores_per_time,
labels,
info,
sfreq=120,
ref=None,
path=None,
title=None):
"""
input:
-- scores_per_time : list of score_per_time arrays of shape (S, T, C)
-- labels: list of labels of same len as scores
-- ref: reference score_per_time, as in an upper bound
"""
n_models = len(scores_per_time)
n_subjects, n_times, n_channels = scores_per_time[0].shape
fig, axes = plt.subplots(n_models, 2)
for idx in range(n_models):
# current elements
score_per_time = scores_per_time[idx]
if ref is not None:
score_per_time = ref - score_per_time
label = labels[idx]
# take mean over subjects
evo_data = score_per_time.mean(0).T # (C, T)
evo = mne.EvokedArray(evo_data, info=info, tmin=-.500)
# plot time course
mne.viz.plot_evoked(
evo,
spatial_colors=True,
scalings=dict(mag=1.),
show=False,
axes=axes[idx, 0],
titles='')
# ax[0].set_ylim(-.01, .11)
axes[idx, 0].set_xlabel('time')
axes[idx, 0].set_ylabel('$\\Delta{}r$')
axes[idx, 0].set_title('Feature %s' % label)
# plot topo
vmax = evo_data.mean(1).max()
im, _ = mne.viz.plot_topomap(
evo_data.mean(1),
evo.info,
cmap='RdBu_r',
vmin=-vmax,
vmax=vmax,
show=False,
axes=axes[idx, 1])
plt.colorbar(im, ax=axes[idx, 1])
plt.tight_layout()
if path is not None:
plt.savefig(path / "sensors_feature_importance.pdf")