mne

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

MNE - Neurophysiology Analysis

MNE - 神经生理学分析

MNE provides sophisticated tools for filtering brain signals, epoching data, and performing source localization (mapping signals back to brain anatomy).
MNE提供了用于脑信号滤波、数据分段(Epoching)以及源定位(将信号映射回大脑解剖结构)的成熟工具。

When to Use

适用场景

  • Processing EEG/MEG recordings from clinical or research studies.
  • Analyzing event-related potentials (ERPs).
  • Source localization (finding where in the brain signals originate).
  • Connectivity analysis between brain regions.
  • Preprocessing neurophysiological data for machine learning.
  • 处理临床或研究中的EEG/MEG记录数据。
  • 分析事件相关电位(ERPs)。
  • 源定位(确定脑信号的起源位置)。
  • 脑区间连接性分析。
  • 为机器学习预处理神经生理数据。

Core Principles

核心原则

Raw → Epochs → Evoked

原始数据→分段数据→诱发响应

The standard pipeline: continuous raw data → segmented epochs → averaged evoked responses.
标准流程:连续原始数据→分段为Epochs→平均得到诱发响应。

Sensor Space vs. Source Space

传感器空间 vs 源空间

Sensor space: signals at electrodes. Source space: signals reconstructed at brain locations.
传感器空间:电极处的信号。源空间:在大脑位置重建的信号。

Frequency Analysis

频率分析

Brain signals are analyzed in frequency bands (delta, theta, alpha, beta, gamma).
脑信号按频段(delta、theta、alpha、beta、gamma)进行分析。

Quick Reference

快速参考

Standard Imports

标准导入

python
import mne
import numpy as np
python
import mne
import numpy as np

Basic Patterns

基础用法

python
undefined
python
undefined

1. Load data

1. Load data

raw = mne.io.read_raw_fif("sample_audvis_raw.fif")
raw = mne.io.read_raw_fif("sample_audvis_raw.fif")

Or: raw = mne.io.read_raw_edf("eeg.edf")

Or: raw = mne.io.read_raw_edf("eeg.edf")

2. Filter and cleaning

2. Filter and cleaning

raw.filter(l_freq=1, h_freq=40) # Bandpass filter raw.notch_filter(freqs=[50, 100]) # Remove power line noise
raw.filter(l_freq=1, h_freq=40) # Bandpass filter raw.notch_filter(freqs=[50, 100]) # Remove power line noise

3. Find events and create Epochs

3. Find events and create Epochs

events = mne.find_events(raw) epochs = mne.Epochs(raw, events, event_id={'stimulus': 1}, tmin=-0.2, tmax=0.5) epochs.average().plot() # Plot Evoked potential
events = mne.find_events(raw) epochs = mne.Epochs(raw, events, event_id={'stimulus': 1}, tmin=-0.2, tmax=0.5) epochs.average().plot() # Plot Evoked potential

4. Frequency analysis

4. Frequency analysis

epochs.compute_psd().plot()
undefined
epochs.compute_psd().plot()
undefined

Critical Rules

关键规则

✅ DO

✅ 建议

  • Filter before epoching - Apply filters to continuous data, not epochs.
  • Check data quality - Use
    raw.plot()
    to visually inspect for artifacts.
  • Set montage - Assign electrode positions for proper visualization.
  • Reject bad epochs - Remove epochs with artifacts before averaging.
  • 先滤波再分段 - 对连续数据应用滤波,而非分段后的Epochs数据。
  • 检查数据质量 - 使用
    raw.plot()
    可视化检查伪影。
  • 设置电极布局 - 分配电极位置以确保正确可视化。
  • 剔除不良分段 - 平均前移除带有伪影的Epochs。

❌ DON'T

❌ 禁忌

  • Don't filter too aggressively - Over-filtering removes signal along with noise.
  • Don't ignore reference - EEG signals are relative. Know your reference electrode.
  • Don't mix sampling rates - Ensure all channels have the same sampling rate.
  • 不要过度滤波 - 过度滤波会在去除噪声的同时丢失有效信号。
  • 不要忽略参考电极 - EEG信号是相对值,需明确参考电极。
  • 不要混合采样率 - 确保所有通道的采样率一致。

Advanced Patterns

进阶用法

Source Localization

源定位

python
undefined
python
undefined

Compute forward solution and inverse

Compute forward solution and inverse

fwd = mne.make_forward_solution(raw.info, trans, src, bem) inv = mne.minimum_norm.make_inverse_operator(raw.info, fwd, cov) stc = mne.minimum_norm.apply_inverse(evoked, inv) stc.plot()
undefined
fwd = mne.make_forward_solution(raw.info, trans, src, bem) inv = mne.minimum_norm.make_inverse_operator(raw.info, fwd, cov) stc = mne.minimum_norm.apply_inverse(evoked, inv) stc.plot()
undefined

Connectivity Analysis

连接性分析

python
from mne.connectivity import spectral_connectivity
python
from mne.connectivity import spectral_connectivity

Compute connectivity between channels

Compute connectivity between channels

con, freqs, times, n_epochs, n_tapers = spectral_connectivity( epochs, method='coh', mode='multitaper')

MNE is the gold standard for neurophysiological data analysis, enabling researchers to extract meaningful insights from the complex signals of the human brain.
con, freqs, times, n_epochs, n_tapers = spectral_connectivity( epochs, method='coh', mode='multitaper')

MNE是神经生理数据分析的黄金标准,助力研究人员从复杂的人类脑信号中提取有意义的见解。