EEG-Xplain 深度解读:EEG基础模型的可解释性框架——从黑盒到白盒的神经解码

EEG-Xplain 深度解读:EEG基础模型的可解释性框架

论文信息

项目 内容
标题 EEG-Xplain: Decoding Neural Black-Boxes of EEG Foundation Models
arXiv 2609.15687 (2026-09-14)
目标模型 BIOT, LaBraM, EEGMamba
评估数据 Mumtaz2016, TUAB
方法 梯度+扰动+激活三类归因
输出 空间地形图+时序热力图+频域贡献+LLM报告

1. 核心问题

EEG基础模型性能出色但完全是黑盒——限制了临床信任和神经科学验证。

1.1 EEG基础模型现状

模型 架构 预训练数据 性能 可解释性
BIOT Transformer 20亿EEG样本 SOTA ❌ 黑盒
LaBraM Transformer 2500小时EEG SOTA ❌ 黑盒
EEGMamba SSM (Mamba) 多数据集 高效 ❌ 黑盒

1.2 为什么可解释性重要

场景 黑盒风险 可解释性价值
临床诊断 误诊无法追溯 医生需理解决策依据
DMS部署 误触发不可解释 需向用户/法规解释
算法改进 不知哪部分有效 精准优化关键组件
伪相关 可能依赖噪声/伪迹 识别并消除虚假依赖
法规合规 GDPR”算法解释权” 满足解释要求

2. 方法论

2.1 统一归因框架

graph TB
    A[EEG输入信号] --> B[EEG基础模型<br/>BIOT/LaBraM/EEGMamba]
    B --> C[模型输出]
    
    C --> D[空间归因<br/>关键EEG通道]
    C --> E[时序归因<br/>决策相关时间段]
    C --> F[频域归因<br/>EEG节律贡献]
    
    D --> D1[脑地形图]
    E --> E1[归因热力图]
    F --> F1[频谱扰动分析]
    
    D1 & E1 & F1 --> G[结构化归因输出]
    G --> H[LLM 自然语言报告]
    H --> I[可读解释报告]

2.2 三维归因方法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
import torch
import torch.nn as nn
import numpy as np
from typing import Tuple

class EEGXplainer:
"""
EEG-Xplain 统一归因框架

三类归因方法:
1. 梯度归因 (Gradient-based)
2. 扰动归因 (Perturbation-based)
3. 激活归因 (Activation-based)

三个维度:
1. 空间(通道)— 哪些EEG通道最重要
2. 时序(时间)— 哪些时间段最相关
3. 频域(节律)— 哪些频段贡献最大
"""

def __init__(self, model: nn.Module):
self.model = model
self.model.eval()

def gradient_attribution(
self,
eeg_input: torch.Tensor,
target_class: int,
) -> torch.Tensor:
"""
梯度归因:输入对输出的梯度

Args:
eeg_input: (B, C, T) EEG信号
target_class: 目标类别

Returns:
attribution: (B, C, T) 归因分数
"""
eeg_input.requires_grad_(True)

output = self.model(eeg_input)
target_score = output[:, target_class].sum()

gradients = torch.autograd.grad(
target_score, eeg_input,
retain_graph=True,
create_graph=False,
)[0]

# Integrated Gradients
attribution = gradients * eeg_input

return attribution.detach()

def perturbation_attribution(
self,
eeg_input: torch.Tensor,
target_class: int,
method: str = "channel",
) -> torch.Tensor:
"""
扰动归因:逐步遮蔽输入区域,观察输出变化

method:
- "channel": 逐通道遮蔽(空间)
- "time": 逐时间段遮蔽(时序)
- "frequency": 逐频段遮蔽(频域)
"""
B, C, T = eeg_input.shape
baseline_output = torch.softmax(
self.model(eeg_input), dim=1
)[:, target_class]

attribution = torch.zeros(C, T)

if method == "channel":
for c in range(C):
perturbed = eeg_input.clone()
perturbed[:, c, :] = 0 # 遮蔽通道c
perturbed_output = torch.softmax(
self.model(perturbed), dim=1
)[:, target_class]
attribution[c, :] = (baseline_output - perturbed_output).mean().item()

elif method == "time":
window_size = T // 20 # 20个时间窗
for c in range(C):
for w in range(0, T, window_size):
perturbed = eeg_input.clone()
perturbed[:, c, w:w+window_size] = 0
perturbed_output = torch.softmax(
self.model(perturbed), dim=1
)[:, target_class]
drop = (baseline_output - perturbed_output).mean().item()
attribution[c, w:w+window_size] = drop

elif method == "frequency":
# 频域扰动
fft_input = torch.fft.rfft(eeg_input, dim=-1)
freq_bands = {
"delta": (0.5, 4), # δ
"theta": (4, 8), # θ
"alpha": (8, 13), # α
"beta": (13, 30), # β
"gamma": (30, 100), # γ
}

freq_attribution = {}
for band, (low, high) in freq_bands.items():
perturbed_fft = fft_input.clone()
freqs = torch.fft.rfftfreq(T, d=1/250) # 假设250Hz
mask = (freqs >= low) & (freqs <= high)
perturbed_fft[:, :, mask] = 0

perturbed = torch.fft.irfft(perturbed_fft, n=T, dim=-1)
perturbed_output = torch.softmax(
self.model(perturbed), dim=1
)[:, target_class]
freq_attribution[band] = (baseline_output - perturbed_output).mean().item()

return freq_attribution

return attribution

def activation_attribution(
self,
eeg_input: torch.Tensor,
target_class: int,
) -> dict:
"""
激活归因:分析中间层激活模式
"""
activations = {}

def hook_fn(name):
def fn(module, input, output):
activations[name] = output.detach()
return fn

# 注册hook
hooks = []
for name, module in self.model.named_modules():
if "attention" in name or "encoder" in name:
hooks.append(module.register_forward_hook(hook_fn(name)))

# 前向
output = self.model(eeg_input)

# 移除hook
for h in hooks:
h.remove()

return {
"layer_activations": activations,
"attention_weights": self._extract_attention(activations),
}

def _extract_attention(self, activations: dict) -> torch.Tensor:
"""提取注意力权重"""
for name, act in activations.items():
if "attention" in name and act.dim() >= 3:
# (B, Heads, Seq, Seq) → 平均
return act.mean(dim=1)
return None


class LLMReportGenerator:
"""
LLM 自然语言报告生成

将结构化归因输出转为可读报告
"""

TEMPLATE = """
EEG 模型决策分析报告
=====================

输入信号: {channels}通道, {duration}秒
模型: {model_name}
预测类别: {prediction} (置信度: {confidence:.1%})

空间分析:
- 关键通道: {top_channels}
- 脑区分布: {brain_regions}

时序分析:
- 关键时间段: {key_segments}
- 最相关时间窗: {peak_window}

频域分析:
- 主导节律: {dominant_rhythm} ({rhythm_contribution:.1%})
- 节律贡献排序: {rhythm_ranking}

可靠性评估:
- AOPC: {aopc:.3f} (越高越可靠)
- 方法一致性: {consistency}/3

神经生理验证:
- 与已知标志一致: {physio_match}
- 潜在伪相关: {artifacts}

结论: {summary}
"""

def generate(self, attributions: dict, prediction: str) -> str:
return self.TEMPLATE.format(
channels=attributions.get("num_channels", "N/A"),
duration=attributions.get("duration", "N/A"),
model_name=attributions.get("model", "N/A"),
prediction=prediction,
confidence=attributions.get("confidence", 0),
top_channels=attributions.get("top_channels", "N/A"),
brain_regions=attributions.get("brain_regions", "N/A"),
key_segments=attributions.get("key_segments", "N/A"),
peak_window=attributions.get("peak_window", "N/A"),
dominant_rhythm=attributions.get("dominant_rhythm", "N/A"),
rhythm_contribution=attributions.get("rhythm_contribution", 0),
rhythm_ranking=attributions.get("rhythm_ranking", "N/A"),
aopc=attributions.get("aopc", 0),
consistency=attributions.get("consistency", 0),
physio_match=attributions.get("physio_match", "N/A"),
artifacts=attributions.get("artifacts", "N/A"),
summary=attributions.get("summary", "N/A"),
)


# 测试
if __name__ == "__main__":
# 模拟EEG基础模型
class DummyEEGModel(nn.Module):
def __init__(self, channels=19, num_classes=3):
super().__init__()
self.conv = nn.Conv1d(channels, 64, 3, 1, 1)
self.fc = nn.Linear(64, num_classes)
def forward(self, x):
x = self.conv(x)
return self.fc(x.mean(dim=-1))

model = DummyEEGModel(channels=19)
xplainer = EEGXplainer(model)

eeg = torch.randn(4, 19, 500) # 19通道, 2秒@250Hz

# 梯度归因
grad_attr = xplainer.gradient_attribution(eeg, target_class=1)
print(f"梯度归因: {grad_attr.shape}")

# 扰动归因(通道)
chan_attr = xplainer.perturbation_attribution(eeg, 1, "channel")
print(f"通道归因: {chan_attr.shape}")

# 频域归因
freq_attr = xplainer.perturbation_attribution(eeg, 1, "frequency")
print(f"频域归因: {freq_attr}")

# LLM报告
report_gen = LLMReportGenerator()
report = report_gen.generate({
"num_channels": 19,
"duration": "2.0s",
"model": "LaBraM",
"confidence": 0.87,
"top_channels": "F3, F4, Cz",
"brain_regions": "前额叶, 中央区",
"dominant_rhythm": "alpha",
"rhythm_contribution": 0.42,
"rhythm_ranking": "alpha(42%) > beta(28%) > theta(18%) > delta(8%) > gamma(4%)",
"aopc": 0.234,
"consistency": 3,
"physio_match": "是(α不对称性与情绪一致)",
"artifacts": "无",
"summary": "模型决策基于前额叶α不对称性,与已知情绪标志一致",
}, "stress")
print(report)

3. 关键结果

3.1 三个维度的归因

维度 方法 输出 价值
空间 通道扰动 脑地形图 哪些脑区驱动决策
时序 窗口扰动 热力图 哪些时间窗关键
频域 频段扰动 节律贡献比 δ/θ/α/β/γ哪个主导

3.2 评估指标

指标 说明 理想值
AOPC 扰动后曲线下面积 高=归因可靠
跨方法一致性 梯度/扰动/激活一致性 3/3=最可靠
神经生理验证 与已知标志是否一致 是=模型学到真信号
伪相关检测 是否依赖噪声/伪迹 无=模型可靠

3.3 在DMS中的应用价值

发现 DMS启示
模型依赖前额叶α 疲劳时前额α增加 → 模型确实学到正确特征
模型依赖眼电伪迹 ⚠️ 模型可能在”看”眼动而非EEG
θ节律贡献高 认知负荷指标 → 正确用于分心检测
时序关注集中在闭眼段 PERCLOS相关 → 合理

4. EEG节律在DMS中的映射

节律 频率 DMS含义 典型应用
δ (Delta) 0.5-4Hz 深睡眠 睡眠检测
θ (Theta) 4-8Hz 认知负荷/困倦 分心/疲劳
α (Alpha) 8-13Hz 放松/闭眼 疲劳(闭眼α增)
β (Beta) 13-30Hz 活跃思考 正常驾驶基线
γ (Gamma) 30-100Hz 高级认知 信息处理

5. IMS开发启示

5.1 可解释DMS架构

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
EXPLAINABLE_DMS = {
"model": "EEG基础模型 (LaBraM/BIOT)",
"explainer": "EEG-Xplain 三维归因",
"output": {
"classification": "normal/fatigued/distracted/stressed",
"explanation": {
"spatial": "前额叶F3/F4通道主导",
"temporal": "第15-18秒信号段关键",
"frequency": "α节律贡献42%(疲劳标志)",
},
"confidence": 0.87,
"reliability": "AOPC=0.234, 一致性3/3",
},
"report": "LLM自然语言报告",
"compliance": "GDPR算法解释权",
}

5.2 伪相关检测

伪相关 影响 检测方法 消除策略
眼电(EOG)伪迹 模型”看”眼动非脑电 频域扰动 预处理去EOG
工频干扰(50/60Hz) 依赖电源噪声 频域扰动 陷波滤波
电极接触不良 依赖特定通道噪声 空间扰动 质量控制
被试习惯性伪迹 个体特异性 跨被试验证 个体校准

6. 局限性

局限 影响 缓解
计算开销 扰动需多次推理 采样近似
LLM报告质量 依赖模板质量 需领域专家验证
基准数据小 Mumtaz2016/TUAB有限 需扩展
仅EEG 不含fNIRS/ECG 框架可扩展

7. 结论

EEG-Xplain 的核心贡献:

  1. 统一归因框架:梯度+扰动+激活三类方法覆盖所有主流解释需求
  2. 三维分析:空间(通道)+时序(时间)+频域(节律)
  3. LLM报告:低层归因→高层自然语言,满足GDPR解释权
  4. 可靠性评估:AOPC+跨方法一致性量化归因可信度
  5. 伪相关检测:识别模型是否依赖噪声/伪迹

IMS启示: EEG基础模型在DMS中的应用需要可解释性——临床信任、法规合规、算法改进都依赖于此。EEG-Xplain提供了即插即用的解释框架,建议在部署LaBraM/BIOT时同步集成。LLM自然语言报告可直接用于向用户/法规解释DMS决策。


参考文献

  • EEG-Xplain: arXiv:2609.15687, 2026-09-14
  • BIOT: Yang et al., 2023
  • LaBraM: Jiang et al., NeurIPS 2023
  • EEGMamba: 2024
  • Mumtaz2016: Mumtaz et al., 2016
  • TUAB: Temple University Hospital EEG Corpus

EEG-Xplain 深度解读:EEG基础模型的可解释性框架——从黑盒到白盒的神经解码
https://dapalm.com/2026/09/16/2026-09-16-eeg-xplain-foundation-model-interpretability-dms-ims/
作者
Mars
发布于
2026年9月16日
许可协议