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

使用电流源密度(CSD)变换 EEG 数据#

本脚本展示如何使用 CSD [1] [2] [3] [4]。CSD 对传感器信号取空间拉普拉斯(x 与 y 方向的导数),作用相当于 MEG 中的平面梯度计。计算这些空间导数可减小点扩散;CSD 变换后的数据地形图更锐利、更清晰,从而减轻容积传导的负面影响。

# Authors: Alex Rockhill <aprockhill@mailbox.org>
#
# License: BSD-3-Clause
# Copyright the MNE-Python contributors.
import matplotlib.pyplot as plt
import numpy as np

import mne
from mne.datasets import sample

print(__doc__)

data_path = sample.data_path()

加载示例受试者数据

meg_path = data_path / "MEG" / "sample"
raw = mne.io.read_raw_fif(meg_path / "sample_audvis_raw.fif")
raw = raw.pick(picks=["eeg", "eog", "ecg", "stim"], exclude="bads").load_data()
events = mne.find_events(raw)
raw.set_eeg_reference(projection=True).apply_proj()
Opening raw data file /home/circleci/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
Ready.
Reading 0 ... 166799  =      0.000 ...   277.714 secs...
Finding events on: STI 014
320 events found on stim channel STI 014
Event IDs: [ 1  2  3  4  5 32]
EEG channel type selected for re-referencing
Adding average EEG reference projection.
1 projection items deactivated
Average reference projection was added, but has not been applied yet. Use the apply_proj method to apply it.
Created an SSP operator (subspace dimension = 1)
1 projection items activated
SSP projectors applied...
General
Filename(s) sample_audvis_raw.fif
MNE object type Raw
Measurement date 2002-12-03 at 19:01:10 UTC
Participant Unknown
Experimenter MEG
Acquisition
Duration 00:04:38 (HH:MM:SS)
Sampling frequency 600.61 Hz
Time points 166,800
Channels
EEG
EOG
Stimulus
Head & sensor digitization 146 points
Filters
Highpass 0.10 Hz
Lowpass 172.18 Hz
Projections Average EEG reference (on)


绘制原始数据与 CSD 变换后的原始数据:

  • Raw plots
  • Raw plots
Fitted sphere radius:         91.2 mm
Origin head coordinates:      -4.2 16.4 51.8 mm
Origin device coordinates:    1.5 18.2 -10.1 mm

同时查看功率谱密度:

raw.compute_psd().plot(picks="data", exclude="bads", amplitude=False)
raw_csd.compute_psd().plot(picks="data", exclude="bads", amplitude=False)
  • EEG
  • Current source density
Effective window size : 3.410 (s)
Plotting power spectral density (dB=True).
Effective window size : 3.410 (s)
Plotting power spectral density (dB=True).

CSD 也可用于诱发(平均)数据。这里先分段并平均,以便演示。

event_id = {
    "auditory/left": 1,
    "auditory/right": 2,
    "visual/left": 3,
    "visual/right": 4,
    "smiley": 5,
    "button": 32,
}
epochs = mne.Epochs(raw, events, event_id=event_id, tmin=-0.2, tmax=0.5, preload=True)
evoked = epochs["auditory"].average()
Not setting metadata
320 matching events found
Setting baseline interval to [-0.19979521315838786, 0.0] s
Applying baseline correction (mode: mean)
Created an SSP operator (subspace dimension = 1)
1 projection items activated
Using data from preloaded Raw for 320 events and 421 original time points ...
0 bad epochs dropped

先看 CSD 如何影响头皮地形图:

times = np.array([-0.1, 0.0, 0.05, 0.1, 0.15])
evoked_csd = mne.preprocessing.compute_current_source_density(evoked)
evoked.plot_joint(title="Average Reference", show=False)
evoked_csd.plot_joint(title="Current Source Density")
  • Average Reference, 0.093 s, 0.205 s, 0.320 s
  • Current Source Density, 0.095 s, 0.208 s, 0.310 s
Fitted sphere radius:         91.2 mm
Origin head coordinates:      -4.2 16.4 51.8 mm
Origin device coordinates:    1.5 18.2 -10.1 mm
Projections have already been applied. Setting proj attribute to True.
Projections have already been applied. Setting proj attribute to True.

CSD 有 stiffness 与 lambda2 参数,分别影响平滑程度与样条灵活性。看看它们如何影响解:

fig, ax = plt.subplots(4, 4, layout="constrained")
fig.set_size_inches(10, 10)
for i, lambda2 in enumerate([0, 1e-7, 1e-5, 1e-3]):
    for j, m in enumerate([5, 4, 3, 2]):
        this_evoked_csd = mne.preprocessing.compute_current_source_density(
            evoked, stiffness=m, lambda2=lambda2
        )
        this_evoked_csd.plot_topomap(
            0.1, axes=ax[i, j], contours=4, time_unit="s", colorbar=False, show=False
        )
        ax[i, j].set_title(f"stiffness={m}\nλ²={lambda2}")
stiffness=5 λ²=0, stiffness=4 λ²=0, stiffness=3 λ²=0, stiffness=2 λ²=0, stiffness=5 λ²=1e-07, stiffness=4 λ²=1e-07, stiffness=3 λ²=1e-07, stiffness=2 λ²=1e-07, stiffness=5 λ²=1e-05, stiffness=4 λ²=1e-05, stiffness=3 λ²=1e-05, stiffness=2 λ²=1e-05, stiffness=5 λ²=0.001, stiffness=4 λ²=0.001, stiffness=3 λ²=0.001, stiffness=2 λ²=0.001
Fitted sphere radius:         91.2 mm
Origin head coordinates:      -4.2 16.4 51.8 mm
Origin device coordinates:    1.5 18.2 -10.1 mm
Fitted sphere radius:         91.2 mm
Origin head coordinates:      -4.2 16.4 51.8 mm
Origin device coordinates:    1.5 18.2 -10.1 mm
Fitted sphere radius:         91.2 mm
Origin head coordinates:      -4.2 16.4 51.8 mm
Origin device coordinates:    1.5 18.2 -10.1 mm
Fitted sphere radius:         91.2 mm
Origin head coordinates:      -4.2 16.4 51.8 mm
Origin device coordinates:    1.5 18.2 -10.1 mm
Fitted sphere radius:         91.2 mm
Origin head coordinates:      -4.2 16.4 51.8 mm
Origin device coordinates:    1.5 18.2 -10.1 mm
Fitted sphere radius:         91.2 mm
Origin head coordinates:      -4.2 16.4 51.8 mm
Origin device coordinates:    1.5 18.2 -10.1 mm
Fitted sphere radius:         91.2 mm
Origin head coordinates:      -4.2 16.4 51.8 mm
Origin device coordinates:    1.5 18.2 -10.1 mm
Fitted sphere radius:         91.2 mm
Origin head coordinates:      -4.2 16.4 51.8 mm
Origin device coordinates:    1.5 18.2 -10.1 mm
Fitted sphere radius:         91.2 mm
Origin head coordinates:      -4.2 16.4 51.8 mm
Origin device coordinates:    1.5 18.2 -10.1 mm
Fitted sphere radius:         91.2 mm
Origin head coordinates:      -4.2 16.4 51.8 mm
Origin device coordinates:    1.5 18.2 -10.1 mm
Fitted sphere radius:         91.2 mm
Origin head coordinates:      -4.2 16.4 51.8 mm
Origin device coordinates:    1.5 18.2 -10.1 mm
Fitted sphere radius:         91.2 mm
Origin head coordinates:      -4.2 16.4 51.8 mm
Origin device coordinates:    1.5 18.2 -10.1 mm
Fitted sphere radius:         91.2 mm
Origin head coordinates:      -4.2 16.4 51.8 mm
Origin device coordinates:    1.5 18.2 -10.1 mm
Fitted sphere radius:         91.2 mm
Origin head coordinates:      -4.2 16.4 51.8 mm
Origin device coordinates:    1.5 18.2 -10.1 mm
Fitted sphere radius:         91.2 mm
Origin head coordinates:      -4.2 16.4 51.8 mm
Origin device coordinates:    1.5 18.2 -10.1 mm
Fitted sphere radius:         91.2 mm
Origin head coordinates:      -4.2 16.4 51.8 mm
Origin device coordinates:    1.5 18.2 -10.1 mm

参考文献#

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

图库由 Sphinx-Gallery 生成