Skip to content

Commit

Permalink
FIX: Fix plot_projs_topomap
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner committed Oct 25, 2016
1 parent 65a4eb0 commit 869e0d6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
4 changes: 3 additions & 1 deletion doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ BUG

- Fix computation of AR coefficients across channels in :func:`mne.time_frequency.fit_iir_model_raw` by `Eric Larson`_

- Fixed maxfilter channel names extra space bug in :func:`mne.preprocessing.maxwell_filter` by `Sheraz Khan`_
- Fix maxfilter channel names extra space bug in :func:`mne.preprocessing.maxwell_filter` by `Sheraz Khan`_

- :func:`mne.find_layout` now leaves out the excluded channels by `Jaakko Leppakangas`_

- Array data constructors :class:`mne.io.RawArray` and :class:`mne.EvokedArray` now make a copy of the info structure by `Jaakko Leppakangas`_

- Fix bug with finding layouts in :func:`mne.viz.plot_projs_topomap` by `Eric Larson`_

API
~~~

Expand Down
11 changes: 9 additions & 2 deletions mne/viz/tests/test_topomap.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


from mne import read_evokeds, read_proj
from mne.io import read_raw_fif
from mne.io import read_raw_fif, read_info
from mne.io.constants import FIFF
from mne.io.pick import pick_info, channel_indices_by_type
from mne.channels import read_layout, make_eeg_layout
Expand All @@ -39,6 +39,7 @@
data_dir = testing.data_path(download=False)
subjects_dir = op.join(data_dir, 'subjects')
ecg_fname = op.join(data_dir, 'MEG', 'sample', 'sample_audvis_ecg-proj.fif')
triux_fname = op.join(data_dir, 'SSS', 'TRIUX', 'triux_bmlhus_erm_raw.fif')

base_dir = op.join(op.dirname(__file__), '..', '..', 'io', 'tests', 'data')
evoked_fname = op.join(base_dir, 'test-ave.fif')
Expand Down Expand Up @@ -153,8 +154,14 @@ def get_texts(p):
plot_projs_topomap(projs, res=res, colorbar=True)
plt.close('all')
ax = plt.subplot(111)
plot_projs_topomap([projs[0]], res=res, axes=ax) # test axes param
plot_projs_topomap(projs[:1], res=res, axes=ax) # test axes param
plt.close('all')
plot_projs_topomap(read_info(triux_fname)['projs'][-1:]) # grads
plt.close('all')
# XXX This one fails due to grads being combined but this proj having
# all zeros in the grad values -> matplotlib contour error
# plot_projs_topomap(read_info(triux_fname)['projs'][:1]) # mags
# plt.close('all')
for ch in evoked.info['chs']:
if ch['coil_type'] == FIFF.FIFFV_COIL_EEG:
ch['loc'].fill(0)
Expand Down
6 changes: 4 additions & 2 deletions mne/viz/topomap.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ def plot_projs_topomap(projs, layout=None, cmap=None, sensors=True,
raise RuntimeError('There must be an axes for each picked projector.')
for proj_idx, proj in enumerate(projs):
axes[proj_idx].set_title(proj['desc'][:10] + '...')
ch_names = _clean_names(proj['data']['col_names'])
ch_names = _clean_names(proj['data']['col_names'],
remove_whitespace=True)
data = proj['data']['data'].ravel()

idx = []
Expand All @@ -229,7 +230,8 @@ def plot_projs_topomap(projs, layout=None, cmap=None, sensors=True,
if grad_pairs:
ch_names = [ch_names[i] for i in grad_pairs]

idx = [l.names.index(c) for c in ch_names if c in l.names]
l_names = _clean_names(l.names, remove_whitespace=True)
idx = [l_names.index(c) for c in ch_names if c in l_names]
if len(idx) == 0:
continue

Expand Down

0 comments on commit 869e0d6

Please sign in to comment.