Skip to content

Instantly share code, notes, and snippets.

@deep-introspection
Last active February 26, 2020 13:44
Show Gist options
  • Save deep-introspection/65ed71b001cdde1f757f3bf47dbf1993 to your computer and use it in GitHub Desktop.
Save deep-introspection/65ed71b001cdde1f757f3bf47dbf1993 to your computer and use it in GitHub Desktop.
Plot spatiotemporal maps of Antoine Rémond (60ies).
#!/usr/bin/env python
# coding=utf-8
"""Spatio-temporal maps of evoked activity."""
# ==============================================================================
# title : run_spatio_temporal_maps.py
# description : Plot spatiotemporal maps of Antoine Rémond (60ies).
# authors : Guillaume Dumas
# date : 2020-02-25
# usage : python run_spatio_temporal_maps.py
# python_version : 3.7
# license : BSD (3-clause)
# ==============================================================================
import mne
import numpy as np
import matplotlib.pyplot as plt
evoked = mne.read_evokeds("mmn-ave.fif")
# Select EGI sensor on the midline axis
sensors = ['E17', 'E16', 'E6', 'E55', 'E62', 'E75', 'E81']
times = evoked.times
# Classic evoked plot
evoked.pick(sensors).plot(spatial_colors=True)
plt.show()
# Antoine Rémond spatio-temporal maps
plt.figure()
data = evoked.pick(sensors).data
plt.imshow(data, interpolation='bessel', resample=True, cmap=plt.cm.bwr)
vmax = np.abs(data).max()
plt.contour(data, antialiased=True, colors='black',
extent=[0, len(times), -0.5, len(sensors)-0.5],
levels = np.linspace(-vmax, vmax, 7))
plt.axis('auto')
plt.xticks(range(0, len(times), 200), times[range(0, len(times), 200)])
plt.yticks(range(len(sensors)), sensors)
plt.plot([200, 200], [-0.5, len(sensors)-0.5], 'k')
plt.clim([-vmax, +vmax])
plt.show()
@deep-introspection
Copy link
Author

Screenshot 2020-02-25 at 18 00 45

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