非官方中文翻译 本页译自 MNE-Python 官方文档: 查看英文原文 ↗。 文档版权归 MNE Developers 所有(BSD-3-Clause)。

绘制 MNE 脑与头盔#

本教程展示如何生成 MNE 头盔 + 大脑图像。

# Authors: The MNE-Python contributors.
# License: BSD-3-Clause
# Copyright the MNE-Python contributors.
import mne

sample_path = mne.datasets.sample.data_path()
subjects_dir = sample_path / "subjects"
fname_evoked = sample_path / "MEG" / "sample" / "sample_audvis-ave.fif"
fname_inv = sample_path / "MEG" / "sample" / "sample_audvis-meg-oct-6-meg-inv.fif"
fname_trans = sample_path / "MEG" / "sample" / "sample_audvis_raw-trans.fif"
inv = mne.minimum_norm.read_inverse_operator(fname_inv)
evoked = mne.read_evokeds(
    fname_evoked,
    baseline=(None, 0),
    proj=True,
    verbose=False,
    condition="Left Auditory",
)
maps = mne.make_field_map(
    evoked,
    trans=fname_trans,
    ch_type="meg",
    subject="sample",
    subjects_dir=subjects_dir,
    upsampling=2,
    origin="auto",
)
time = 0.083
fig = mne.viz.create_3d_figure((512, 512), bgcolor="w", title="MNE helmet")
mne.viz.plot_alignment(
    evoked.info,
    subject="sample",
    subjects_dir=subjects_dir,
    fig=fig,
    trans=fname_trans,
    meg="sensors",
    eeg=False,
    surfaces="pial",
    coord_frame="mri",
)
evoked.plot_field(
    maps,
    time=time,
    fig=fig,
    time_label=None,
    vmax=5e-13,
    time_viewer=False,
)
mne.viz.set_3d_view(
    fig,
    azimuth=40,
    elevation=87,
    focalpoint=(0.0, -0.01, 0.04),
    roll=-105,
    distance=0.55,
)
mne helmet
Reading inverse operator decomposition from /home/circleci/mne_data/MNE-sample-data/MEG/sample/sample_audvis-meg-oct-6-meg-inv.fif...
    Reading inverse operator info...
    [done]
    Reading inverse operator decomposition...
    [done]
    305 x 305 full covariance (kind = 1) found.
    Read a total of 4 projection items:
        PCA-v1 (1 x 102) active
        PCA-v2 (1 x 102) active
        PCA-v3 (1 x 102) active
        Average EEG reference (1 x 60) active
    Noise covariance matrix read.
    22494 x 22494 diagonal covariance (kind = 2) found.
    Source covariance matrix read.
    22494 x 22494 diagonal covariance (kind = 6) found.
    Orientation priors read.
    22494 x 22494 diagonal covariance (kind = 5) found.
    Depth priors read.
    Did not find the desired covariance matrix (kind = 3)
    Reading a source space...
    Computing patch statistics...
    Patch information added...
    Distance information added...
    [done]
    Reading a source space...
    Computing patch statistics...
    Patch information added...
    Distance information added...
    [done]
    2 source spaces read
    Read a total of 4 projection items:
        PCA-v1 (1 x 102) active
        PCA-v2 (1 x 102) active
        PCA-v3 (1 x 102) active
        Average EEG reference (1 x 60) active
    Source spaces transformed to the inverse solution coordinate frame
Getting helmet for system 306m
Upsampling from 304 to 1216 vertices (upsampling=2)
    Automatic origin fit: head of radius 91.2 mm
Prepare MEG mapping...
Computing dot products for 305 coils...
Computing dot products for 1175 surface locations...
Field mapping data ready
    Preparing the mapping matrix...
    Truncating at 85/305 components to omit less than 0.0001 (9.4e-05)
Channel types:: grad: 203, mag: 102

脚本总运行时间:(0 分 4.199 秒)

图库由 Sphinx-Gallery 生成