<jupyter_start><jupyter_text>Plotting topographic maps of evoked dataLoad evoked data and plot topomaps for selected time points using multipleadditional options.<jupyter_code># Authors: <NAME> <<EMAIL>>
#          <NAME> <<EMAIL>>
#          <NAME> <<EMAIL>>
#          <NAME> <<EMAIL>>
#
# License: BSD (3-clause)
# sphinx_gallery_thumbnail_number = 5

import numpy as np
import matplotlib.pyplot as plt
from mne.datasets import sample
from mne import read_evokeds

print(__doc__)

path = sample.data_path()
fname = path + '/MEG/sample/sample_audvis-ave.fif'

# load evoked corresponding to a specific condition
# from the fif file and subtract baseline
condition = 'Left Auditory'
evoked = read_evokeds(fname, condition=condition, baseline=(None, 0))<jupyter_output><empty_output><jupyter_text>Basic `plot_topomap` options----------------------------We plot evoked topographies using :func:`mne.Evoked.plot_topomap`. The firstargument, ``times`` allows to specify time instants (in seconds!) for whichtopographies will be shown. We select timepoints from 50 to 150 ms with astep of 20ms and plot magnetometer data:<jupyter_code>times = np.arange(0.05, 0.151, 0.02)
evoked.plot_topomap(times, ch_type='mag', time_unit='s')<jupyter_output><empty_output><jupyter_text>If times is set to None at most 10 regularly spaced topographies will beshown:<jupyter_code>evoked.plot_topomap(ch_type='mag', time_unit='s')<jupyter_output><empty_output><jupyter_text>Instead of showing topographies at specific time points we can computeaverages of 50 ms bins centered on these time points to reduce the noise inthe topographies:<jupyter_code>evoked.plot_topomap(times, ch_type='mag', average=0.05, time_unit='s')<jupyter_output><empty_output><jupyter_text>We can plot gradiometer data (plots the RMS for each pair of gradiometers)<jupyter_code>evoked.plot_topomap(times, ch_type='grad', time_unit='s')<jupyter_output><empty_output><jupyter_text>Additional `plot_topomap` options---------------------------------We can also use a range of various :func:`mne.viz.plot_topomap` argumentsthat control how the topography is drawn. For example:* ``cmap`` - to specify the color map* ``res`` - to control the resolution of the topographies (lower resolution  means faster plotting)* ``outlines='skirt'`` to see the topography stretched beyond the head circle* ``contours`` to define how many contour lines should be plotted<jupyter_code>evoked.plot_topomap(times, ch_type='mag', cmap='Spectral_r', res=32,
                    outlines='skirt', contours=4, time_unit='s')<jupyter_output><empty_output><jupyter_text>If you look at the edges of the head circle of a single topomap you'll seethe effect of extrapolation. By default ``extrapolate='box'`` is used whichextrapolates to a large box stretching beyond the head circle.Compare this with ``extrapolate='head'`` (second topography below) whereextrapolation goes to 0 at the head circle and ``extrapolate='local'`` whereextrapolation is performed only within some distance from channels:<jupyter_code>extrapolations = ['box', 'head', 'local']
fig, axes = plt.subplots(figsize=(7.5, 2.5), ncols=3)

for ax, extr in zip(axes, extrapolations):
    evoked.plot_topomap(0.1, ch_type='mag', size=2, extrapolate=extr, axes=ax,
                        show=False, colorbar=False)
    ax.set_title(extr, fontsize=14)<jupyter_output><empty_output><jupyter_text>More advanced usage-------------------Now we plot magnetometer data as topomap at a single time point: 100 mspost-stimulus, add channel labels, title and adjust plot margins:<jupyter_code>evoked.plot_topomap(0.1, ch_type='mag', show_names=True, colorbar=False,
                    size=6, res=128, title='Auditory response',
                    time_unit='s')
plt.subplots_adjust(left=0.01, right=0.99, bottom=0.01, top=0.88)<jupyter_output><empty_output><jupyter_text>Animating the topomap---------------------Instead of using a still image we can plot magnetometer data as an animation(animates only in matplotlib interactive mode)<jupyter_code>evoked.animate_topomap(ch_type='mag', times=times, frame_rate=10,
                       time_unit='s')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12512007684918347, 'fraction_numerical': 0.01536983669548511, 'mean_word_length': 5.01010101010101, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '315998', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1370, 'n_tokens_neox': 1290, 'n_words': 379, 'path': 'stable/_downloads/6d7b5624e4fa6fee90fb68aca9314f7f/plot_evoked_topomap.ipynb', 'repo_name': 'drammock/mne-tools.github.io', 'size': '4256'}