Skip to content

Instantly share code, notes, and snippets.

@dengemann
Last active August 29, 2015 14:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dengemann/dedbf84d07d79975d5a0 to your computer and use it in GitHub Desktop.
Save dengemann/dedbf84d07d79975d5a0 to your computer and use it in GitHub Desktop.
"""
========================================
Plotting topographic maps of evoked data
========================================
Load evoked data and plot topomaps for selected time points.
"""
# Authors: Christian Brodbeck <christianbrodbeck@nyu.edu>
# Tal Linzen <linzen@nyu.edu>
# Denis A. Engeman <denis.engemann@gmail.com>
#
# License: BSD (3-clause)
print(__doc__)
import numpy as np
from mne.datasets import sample
from mne import read_evokeds
from mne.report import Report
import matplotlib.pyplot as plt
path = sample.data_path()
fname = path + '/MEG/sample/sample_audvis-ave.fif'
# load evoked and subtract baseline
condition = 'Left Auditory'
evoked = read_evokeds(fname, condition=condition, baseline=(None, 0))
# set time instants in seconds (from 50 to 150ms in a step of 10ms)
times = np.arange(0.05, 0.15, 0.01)
# If times is set to None only 10 regularly spaced topographies will be shown
# plot magnetometer data as topomaps
evoked.plot_topomap(times, ch_type='mag')
# plot gradiometer data (plots the RMS for each pair of gradiometers)
evoked.plot_topomap(times, ch_type='grad')
# plot magnetometer data as topomap at 1 time point : 100ms
# and add channel labels and title
evoked.plot_topomap(0.1, ch_type='mag', show_names=True, colorbar=False,
size=8, title='Auditory response')
report = Report()
# creates new section `foo`
report.add_section([plt.figure(i) for i in plt.get_fignums()],
['mag topo', 'grad topo', 'channel names'], section='foo')
fig = evoked.plot_topomap(0.2, ch_type='mag', show_names=True, colorbar=False,
size=2, title='Auditory response')
# adds to existing section `foo`
report.add_section([fig], ['channel names 2'], section='foo')
fig = evoked.plot_topomap(0.3, ch_type='mag', show_names=True, colorbar=False,
size=2, title='Auditory response')
# creates new section `bar`
report.add_section([fig], ['chanenl names 3'], section='bar')
report.save('report.html')
@agramfort
Copy link

the line "report.data_path = '.'" should not be necessary

ping @mainakjas

@mainakjas
Copy link

This is fixed now. Also, multiple saves should be possible @dengemann.

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