diff --git a/doc/documentation.rst b/doc/documentation.rst index 580e418d9aa..9c0ee7b50e3 100644 --- a/doc/documentation.rst +++ b/doc/documentation.rst @@ -395,6 +395,7 @@ this package. You can also find a gallery of these examples in the auto_tutorials/plot_source_alignment.rst auto_tutorials/plot_forward.rst auto_tutorials/plot_compute_covariance.rst + auto_tutorials/plot_eeg_no_mri.rst auto_tutorials/plot_mne_dspm_source_localization.rst auto_tutorials/plot_mne_solutions.rst auto_tutorials/plot_dipole_fit.rst diff --git a/doc/manual/datasets_index.rst b/doc/manual/datasets_index.rst index 8433a32c39c..3f9900dbfaa 100644 --- a/doc/manual/datasets_index.rst +++ b/doc/manual/datasets_index.rst @@ -32,6 +32,10 @@ fsaverage For convenience, we provide a function to separately download and extract the (or update an existing) fsaverage subject. +.. topic:: Examples + + :ref:`sphx_glr_auto_tutorials_plot_eeg_no_mri.py` + Brainstorm ========== Dataset fetchers for three Brainstorm tutorials are available. Users must agree to the diff --git a/doc/whats_new.rst b/doc/whats_new.rst index ac8ced90a72..8aa1676a521 100644 --- a/doc/whats_new.rst +++ b/doc/whats_new.rst @@ -19,6 +19,8 @@ Current Changelog ~~~~~~~~~ +- Add new tutorial on :ref:`sphx_glr_auto_tutorials_plot_eeg_no_mri.py` by `Alex Gramfort`_, and `Joan Massich`_ + - Add convenience ``fsaverage`` subject dataset fetcher / updater :func:`mne.datasets.fetch_fsaverage` by `Eric Larson`_ - Add ``fmin`` and ``fmax`` argument to :meth:`mne.time_frequency.AverageTFR.crop` and to :meth:`mne.time_frequency.EpochsTFR.crop` to crop TFR objects along frequency axis by `Dirk Gütlin`_ diff --git a/tutorials/plot_eeg_no_mri.py b/tutorials/plot_eeg_no_mri.py new file mode 100644 index 00000000000..7125eedfac6 --- /dev/null +++ b/tutorials/plot_eeg_no_mri.py @@ -0,0 +1,76 @@ +# -*- coding: utf-8 -*- +""" +EEG forward operator with a template MRI +======================================== + +This tutorial explains how to compute the forward operator from EEG data +using the standard template MRI subject ``fsaverage``. + +.. important:: Source reconstruction without an individual T1 MRI from the + subject will be less accurate. Do not over interpret + activity locations which can be off by multiple centimeters. + +.. contents:: This tutorial covers: + :local: + :depth: 2 + +""" + +# Authors: Alexandre Gramfort +# Joan Massich +# +# License: BSD Style. + +import os.path as op + +import mne +from mne.datasets import eegbci +from mne.datasets import fetch_fsaverage + +# Download fsaverage files +fs_dir = fetch_fsaverage(verbose=True) +subjects_dir = op.dirname(fs_dir) + +# The files live in: +subject = 'fsaverage' +trans = op.join(fs_dir, 'bem', 'fsaverage-trans.fif') +src = op.join(fs_dir, 'bem', 'fsaverage-ico-5-src.fif') +bem = op.join(fs_dir, 'bem', 'fsaverage-5120-5120-5120-bem-sol.fif') + +############################################################################## +# Load the data +# ------------- +# +# We use here EEG data from the BCI dataset. + +raw_fname, = eegbci.load_data(subject=1, runs=[6]) +raw = mne.io.read_raw_edf(raw_fname, preload=True) + + +# Clean channel names to be able to use a standard 1005 montage +ch_names = [c.replace('.', '') for c in raw.ch_names] +raw.rename_channels({old: new for old, new in zip(raw.ch_names, ch_names)}) + +# Read and set the EEG electrode locations +montage = mne.channels.read_montage('standard_1005', ch_names=raw.ch_names, + transform=True) + +raw.set_montage(montage) +raw.set_eeg_reference(projection=True) # needed for inverse modeling + +# Check that the locations of EEG electrodes is correct with respect to MRI +mne.viz.plot_alignment( + raw.info, src=src, eeg=['original', 'projected'], trans=trans, dig=True) + +############################################################################## +# Setup source space and compute forward +# -------------------------------------- + +fwd = mne.make_forward_solution(raw.info, trans=trans, src=src, + bem=bem, eeg=True, mindist=5.0, n_jobs=1) +print(fwd) + +# for illustration purposes use fwd to compute the sensitivity map +eeg_map = mne.sensitivity_map(fwd, ch_type='eeg', mode='fixed') +eeg_map.plot(time_label='EEG sensitivity', subjects_dir=subjects_dir, + clim=dict(lims=[5, 50, 100]))