Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example showing all the eeg helmets #6158

Merged
merged 24 commits into from
Apr 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8be92ab
Add plot_montage (that uses the same code as plot_eeg_no_mri)
massich Apr 16, 2019
22c2b41
MAINT: Use version-based permalink for download (#6161)
massich Apr 23, 2019
79fb4dc
use unit='auto'
massich Apr 18, 2019
9b01b71
use auto and transform=False
massich Apr 18, 2019
fac9c01
fix
massich Apr 18, 2019
96d1070
MRG: Fix inconsistencies with compute_proj_raw (#6160)
larsoner Apr 17, 2019
cce5cec
ENH: Add the ids='all' as an option for mne.event.shift_time_events …
Nichalas Apr 17, 2019
1690d14
nilearn was updated
agramfort Apr 18, 2019
fa08e93
Raise ValueError if TFR freqs <= 0 (#6169)
DiGyt Apr 20, 2019
8dc00bf
init (#6181)
jona-sassenhagen Apr 22, 2019
fd1d227
MRG+1: better title in plot_compare_evokeds (closes #6165) (#6173)
drammock Apr 22, 2019
09eeb1e
This commit adds additional explanation to the contributing guide. (#…
ikojcic Apr 22, 2019
2e0d870
DOC: make sure you get a warning when reading onsets which are not ti…
agramfort Apr 23, 2019
18a4587
[MRG] RealTime client refactor (#6141)
teonbrooks Apr 23, 2019
748ff19
ENH: Add MNE-fsaverage (#6174)
massich Apr 23, 2019
79ccebc
update example to use fetch_fsaverage
massich Apr 23, 2019
c88bf12
Merge branch 'master' into plot_eeg_helmets
massich Apr 23, 2019
c9f75ae
whats new + couple words
massich Apr 23, 2019
2226da4
Merge branch 'master' into plot_eeg_helmets
massich Apr 23, 2019
72c12e0
document 'auto'
massich Apr 23, 2019
d4613b8
Cross reference the example
massich Apr 23, 2019
f5553d4
fix cross references
massich Apr 23, 2019
8f16135
I forgot one
massich Apr 23, 2019
f0044f3
FIX: Spelling [ci skip]
larsoner Apr 23, 2019
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
4 changes: 3 additions & 1 deletion doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ Current
Changelog
~~~~~~~~~

- Add new tutorial on :ref:`sphx_glr_auto_tutorials_plot_eeg_no_mri.py` by `Alex Gramfort`_, and `Joan Massich`_
- Add example on how to load standard montage :ref:`plot_montage` by `Joan Massich`_

- Add new tutorial on :ref:`plot_eeg_no_mri` by `Alex Gramfort`_, and `Joan Massich`_

- Add convenience ``fsaverage`` subject dataset fetcher / updater :func:`mne.datasets.fetch_fsaverage` by `Eric Larson`_

Expand Down
47 changes: 47 additions & 0 deletions examples/visualization/plot_montage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
"""
.. _plot_montage:

Plotting sensor layouts of EEG Systems
======================================

This example illustrates how to load all the EEG system montages
shipped in MNE-python, and display it on fsaverage template.
""" # noqa: D205, D400
# Authors: Alexandre Gramfort <[email protected]>
# Joan Massich <[email protected]>
#
# License: BSD Style.

from mayavi import mlab
import os.path as op

import mne
from mne.channels.montage import get_builtin_montages
from mne.datasets import fetch_fsaverage
from mne.viz import plot_alignment

subjects_dir = op.dirname(fetch_fsaverage())

###############################################################################
# check all montages
#

for current_montage in get_builtin_montages():

montage = mne.channels.read_montage(current_montage,
unit='auto',
transform=False)

info = mne.create_info(ch_names=montage.ch_names,
sfreq=1,
ch_types='eeg',
montage=montage)

fig = plot_alignment(info, trans=None,
subject='fsaverage',
subjects_dir=subjects_dir,
eeg=['projected'],
)
mlab.view(135, 80)
mlab.title(montage.kind, figure=fig)
20 changes: 13 additions & 7 deletions mne/channels/montage.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from ..io.open import fiff_open
from ..io.constants import FIFF
from ..utils import (_check_fname, warn, copy_function_doc_to_method_doc,
_clean_names)
_clean_names, _check_option)

from .layout import _pol_to_cart, _cart_to_sph

Expand Down Expand Up @@ -132,9 +132,9 @@ def read_montage(kind, ch_names=None, path=None, unit='m', transform=False):
path : str | None
The path of the folder containing the montage file. Defaults to the
mne/channels/data/montages folder in your mne-python installation.
unit : 'm' | 'cm' | 'mm'
Unit of the input file. If not 'm' (default), coordinates will be
rescaled to 'm'.
unit : 'm' | 'cm' | 'mm' | 'auto'
Unit of the input file. When 'auto' the montage is normalized to
a sphere of radius equal to the average brain size. Defaults to 'auto'.
transform : bool
If True, points will be transformed to Neuromag space. The fidicuals,
'nasion', 'lpa', 'rpa' must be specified in the montage file. Useful
Expand Down Expand Up @@ -209,6 +209,8 @@ def read_montage(kind, ch_names=None, path=None, unit='m', transform=False):

.. versionadded:: 0.9.0
"""
_check_option('unit', unit, ['mm', 'cm', 'm', 'auto'])

if path is None:
path = op.join(op.dirname(__file__), 'data', 'montages')
if not op.isabs(kind):
Expand Down Expand Up @@ -332,12 +334,16 @@ def read_montage(kind, ch_names=None, path=None, unit='m', transform=False):
kind)
selection = np.arange(len(pos))

if unit == 'mm':
if unit == 'auto': # rescale to 0.085
pos -= np.mean(pos, axis=0)
pos = 0.085 * (pos / np.linalg.norm(pos, axis=1).mean())
elif unit == 'mm':
pos /= 1e3
elif unit == 'cm':
pos /= 1e2
elif unit != 'm':
raise ValueError("'unit' should be either 'm', 'cm', or 'mm'.")
elif unit == 'm': # montage is supposed to be in m
pass

names_lower = [name.lower() for name in list(ch_names_)]
fids = {key: pos[names_lower.index(fid_names[ii])]
if fid_names[ii] in names_lower else None
Expand Down
4 changes: 4 additions & 0 deletions tutorials/plot_eeg_no_mri.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
"""
.. _plot_eeg_no_mri:

EEG forward operator with a template MRI
========================================

Expand All @@ -10,6 +12,8 @@
subject will be less accurate. Do not over interpret
activity locations which can be off by multiple centimeters.

.. note:: :ref:`plot_montage` show all the standard montages in MNE-Python.

.. contents:: This tutorial covers:
:local:
:depth: 2
Expand Down