Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions examples/preprocessing/eeg_bridging.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import LinearSegmentedColormap

import mne

Expand Down Expand Up @@ -236,13 +237,25 @@
# 04-modality-specific-files/03-electroencephalography.html\
# #electrodes-description-_electrodestsv>`_ file.
# Since the impedances are not stored for this dataset, we will fake
# them to demonstrate how they would be plotted.
# them to demonstrate how they would be plotted. Here, the impedances
# are plotted as is typical at the end of a setup; most channels are
# good but there are a few that need to have their impedance lowered.
# The impedances should ideally all be less than 25 KOhm before
# starting an experiment when using active systems and less than 5 KOhm
# when using a passive system.

rng = np.random.default_rng(11) # seed for reproducibility
raw = raw_data[1]
impedances = rng.random((len(raw.ch_names,))) * 10
# typically impedances < 25 kOhm are acceptable for active systems and
# impedances < 5 kOhm are desirable for a passive system
impedances = rng.random((len(raw.ch_names,))) * 30
impedances[10] = 80 # set a few bad impendances
impedances[25] = 99
cmap = LinearSegmentedColormap.from_list(name='impedance_cmap',
colors=['g', 'y', 'r'], N=256)
fig, ax = plt.subplots(figsize=(5, 5))
im, cn = mne.viz.plot_topomap(impedances, raw.info, axes=ax)
im, cn = mne.viz.plot_topomap(impedances, raw.info, axes=ax,
cmap=cmap, vmin=25, vmax=75)
ax.set_title('Electrode Impendances')
cax = fig.colorbar(im, ax=ax)
cax.set_label(r'Impedance (k$\Omega$)')
Expand Down
3 changes: 3 additions & 0 deletions mne/viz/topomap.py
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,8 @@ def _plot_topomap(data, pos, vmin=None, vmax=None, cmap=None, sensors=True,
vmin, vmax = _setup_vmin_vmax(data, vmin, vmax, norm)
if cmap is None:
cmap = plt.get_cmap('Reds' if norm else 'RdBu_r')
elif isinstance(cmap, str):
cmap = plt.get_cmap(cmap)

outlines = _make_head_outlines(sphere, pos, outlines, (0., 0.))
assert isinstance(outlines, dict)
Expand Down Expand Up @@ -2687,6 +2689,7 @@ def plot_bridged_electrodes(info, bridged_idx, ed_matrix, title=None,
else:
topomap_args = topomap_args.copy() # don't change original
topomap_args.setdefault('image_interp', 'voronoi')
topomap_args.setdefault('cmap', 'summer_r')
topomap_args.setdefault('names', info.ch_names)
topomap_args.setdefault('show_names', True)
topomap_args.setdefault('contours', False)
Expand Down