Reading BEM surfaces from a forward solution

Plot BEM surfaces used for forward solution generation.

# Author: Jaakko Leppakangas <>
# License: BSD (3-clause)
import os.path as op
from mayavi import mlab

import mne
from mne.datasets.sample import data_path


data_path = data_path()
fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_raw.fif')
raw =
subjects_dir = op.join(data_path, 'subjects')


Opening raw data file /home/ubuntu/mne_data/MNE-sample-data/MEG/sample/sample_audvis_raw.fif...
    Read a total of 3 projection items:
        PCA-v1 (1 x 102)  idle
        PCA-v2 (1 x 102)  idle
        PCA-v3 (1 x 102)  idle
    Range : 25800 ... 192599 =     42.956 ...   320.670 secs
Current compensation grade : 0

Here we use mne.viz.plot_trans() with trans=None to plot only the surfaces without any transformations. For plotting transformation, see Head model and forward computation.

mne.viz.plot_trans(, trans=None, subject='sample',
                   subjects_dir=subjects_dir, meg_sensors=[], eeg_sensors=[],
                   head='outer_skin', skull=['inner_skull', 'outer_skull'])
mlab.view(40, 60)


Using surface from /home/ubuntu/mne_data/MNE-sample-data/subjects/sample/bem/sample-5120-5120-5120-bem.fif.
Using /home/ubuntu/mne_data/MNE-sample-data/subjects/sample/bem/flash/ for head surface.
Using /home/ubuntu/mne_data/MNE-sample-data/subjects/sample/bem/flash/ for head surface.

Total running time of the script: ( 0 minutes 0.487 seconds)

Generated by Sphinx-Gallery