Skip to content

Commit

Permalink
2021-09-01
Browse files Browse the repository at this point in the history
  • Loading branch information
bkxcyu committed Sep 1, 2021
1 parent 231557b commit 908dae6
Show file tree
Hide file tree
Showing 32 changed files with 951 additions and 45 deletions.
58 changes: 58 additions & 0 deletions &make html
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# 事件相关电位

## 引言

ERPs可以通过脑电图(EEG)可靠地测量,脑电图是一种通过放置在头皮上的电极来测量随时间变化的大脑电活动的方法.脑电图反映了数千个同时进行的大脑过程.这意味着大脑对单一刺激或感兴趣的事件的反应通常在单个试验的脑电图记录中不可见.为了观察大脑对刺激的反应,实验者必须进行多次试验并将结果平均,使随机的大脑活动平均,相关的波形保持不变,这就是所谓的ERP.

用一句话来讲:事件相关电位是与特定的物理事件或心理事件在时间上相关的电压波动.

> An event-related potential (ERP) is the measured brain response that is the direct result of a specific sensory, cognitive, or motor event. More formally, it is any stereotyped electrophysiological response to a stimulus.

![ERP](img/Screenshot_20210831_105501.png)

## 大脑为什么会产生与事件相关的电压波动,这些电压波动意味着什么?

ERP是神经信息处理的毫秒级记录,反应了大脑的感觉编码,抑制反应和更新工作记忆等特定的操作的神经活动.

下面是笔者整理的几个例子,或许能够帮助读者理解事件相关电位的意义.

### 听觉注意

1973年,希利亚德设计了一个巧妙的实验,在一定程度上解释了听觉的注意机制.他们通过耳机在被试的两耳同时呈现不同音高的声音刺激流,在一种条件下要求被试注意呈现在左耳的刺激而忽略右耳,在另一种条件下则注意右耳的刺激而忽略左耳.这样,研究者就可以在被试只注意一侧耳刺激的条件下记录两个声音诱发的事件相关电位反应.结果发现,刺激注意与刺激忽略条件相比,听觉事件相关电位的振幅明显放大了.由于这个波是在刺激呈现后事件相关电位的第一个显著负波(N1波),而N1波成分是一种由感觉刺激诱发的脑波.所以,实验结果可能是感觉加工早期选择的证据.

![听觉注意](img/Screenshot_20210831_105501.png)

### 视觉注意

采用事件相关电位技术,也可以直接测量脑内负责加工视觉刺激神经元的电活动,揭示选择注意是如何影响脑对视觉刺激加工的.心理学家伊森等人在1969年做了一个实验:要求被试有意将注意力暗中指向左侧(或者右侧)的某个位置,可以使事件相关电位在刺激出现后70-80毫秒的正波明显增高,这一成分称为P1波.

![P1](img/Screenshot_20210831_105258.png)

空间位置注意的P1波效应仅仅在空间注意时出现.在注意选择其它视觉特征,如颜色,空间频率,方向或这些特征的结合时都不会出现.进一步的研究显示,视觉空间选择性注意是通过调节视觉皮层的加工实现的.这些效应最初发生在纹外皮层,也可能包含纹状皮层.证据来自如下几方面:1,P1波效应在头皮上方的分布类似网膜图,在对侧枕区最大,这与视觉通路对侧投射是一致的;2,选择注意引起的事件相关电位潜伏期(70毫秒)和纹外皮层神经元放电的潜伏期一致;3,功能成像研究也表明,注意力对感觉加工调节发生在纹外皮层.

## 事件相关电位如何提取和分析?

由于其它噪声的干扰,事件相关电位很难直接从原始数据中观察到.为了提取到事件相关电位,需要做一些基本的假设:

1. 感兴趣的信号由一系列具有不变延迟和形状的事件锁定的电压序列组成
2. 过程中的干扰可以近似为高斯噪声

具体的处理过程见下面的动画演示

### 动画

<iframe src="/home/bkxcyu/workspace/manim/media/videos/scene/1080p60/LineGraphExample.mp4">

### 数学定义

\begin{equation}
x(t,k) = s(t) + n(t,k)
\end{equation}


### 代码

1. mne

2. eeglab

Binary file added build/doctrees/ERP.doctree
Binary file not shown.
Binary file modified build/doctrees/FT_Interactive_animation.doctree
Binary file not shown.
Binary file modified build/doctrees/environment.pickle
Binary file not shown.
Binary file modified build/doctrees/index.doctree
Binary file not shown.
2 changes: 1 addition & 1 deletion build/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: c14f61d1e82ab4a58cbb0bbf18d3a4b8
config: 78f792ad7dab612b571a16472480de99
tags: 645f666f9bcd5a90fca523b33c5a78b7
374 changes: 374 additions & 0 deletions build/html/ERP.html

Large diffs are not rendered by default.

28 changes: 24 additions & 4 deletions build/html/FT_Interactive_animation.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>傅利叶变换: 以\(f(t) = sin(2\pi t)\)​为例 &#8212; demo 文档</title>
<title>傅利叶变换: 以\(f(t) = sin(2\pi t)\)​为例 &#8212; BCI Intuition 文档</title>

<link href="_static/css/theme.css" rel="stylesheet" />
<link href="_static/css/index.c5995385ac14fb8791e8eb36b4908be2.css" rel="stylesheet" />
Expand Down Expand Up @@ -38,6 +38,7 @@
<script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"processClass": "tex2jax_process|mathjax_process|math|output_area"}})</script>
<link rel="index" title="索引" href="genindex.html" />
<link rel="search" title="搜索" href="search.html" />
<link rel="next" title="事件相关电位" href="ERP.html" />
<link rel="prev" title="Welcome to bkxcyu’s documentation!" href="index.html" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="docsearch:language" content="en" />
Expand All @@ -58,15 +59,20 @@
<a class="navbar-brand text-wrap" href="index.html">


<h1 class="site-logo" id="site-title">demo 文档</h1>
<h1 class="site-logo" id="site-title">BCI Intuition 文档</h1>

</a>
</div><form class="bd-search d-flex align-items-center" action="search.html" method="get">
<i class="icon fas fa-search"></i>
<input type="search" class="form-control" name="q" id="search-input" placeholder="Search the docs ..." aria-label="Search the docs ..." autocomplete="off" >
</form><nav class="bd-links" id="bd-docs-nav" aria-label="Main">
<div class="bd-toc-item active">
<ul class="current nav bd-sidenav">
<p class="caption">
<span class="caption-text">
First steps
</span>
</p>
<ul class="current nav bd-sidenav">
<li class="toctree-l1 current active">
<a class="current reference internal" href="#">
傅利叶变换: 以
Expand All @@ -76,6 +82,11 @@ <h1 class="site-logo" id="site-title">demo 文档</h1>
​为例
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="ERP.html">
事件相关电位
</a>
</li>
</ul>

</div>
Expand Down Expand Up @@ -190,7 +201,7 @@ <h1 class="site-logo" id="site-title">demo 文档</h1>

<p>任何一个工科生都不会对傅利叶变换感到陌生:傅利叶变换可以将一个信号从时域转换到复频域,这样就能愉快地在复频域分析信号啦.虽然在用的时候司空见惯,但在某一些时刻我还是会忍不住感叹–傅利叶变换真是太妙了!</p>
<p>其实,从在课堂上学到傅利叶变换后的很长一段时间里我都还没有领会到其妙处,直到我看到了这个视频:</p>
<iframe src="//player.bilibili.com/player.html?aid=19141078&bvid=BV1pW411J7s8&cid=31220967&page=1" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"style="width: 640px; height: 430px; max-width: 100%" > </iframe>
<iframe src="//player.bilibili.com/player.html?aid=19141078&bvid=BV1pW411J7s8&cid=31220967&page=1" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true" style="width: 640px; height: 430px; max-width: 100%" > </iframe>
<p>这个视频通过数学动画将傅利叶变换形象地展示了出来.受这个视频的启发,我也写了一个交互式的小程序来体会傅利叶变换的精妙之处.</p>
<a class="reference internal image-reference" href="_images/F.gif"><img alt="ft1" class="align-center" src="_images/F.gif" style="width: 400px;" /></a>
<div class="note admonition">
Expand Down Expand Up @@ -301,6 +312,15 @@ <h2>3. <span class="math notranslate nohighlight">\(sin(2\pi t)e^{-2\pi i \omega
</div>
</a>
</div>
<div id="next">
<a class="right-next" href="ERP.html" title="下一页 页">
<div class="prevnext-info">
<p class="prevnext-label">下一页</p>
<p class="prevnext-title">事件相关电位</p>
</div>
<i class="prevnext-label fas fa-angle-right"></i>
</a>
</div>

</div>

Expand Down
Binary file added build/html/_images/400px-Eeglab_small.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/html/_images/sphx_glr_30_eeg_erp_010.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
128 changes: 128 additions & 0 deletions build/html/_sources/ERP.md.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# 事件相关电位

## 引言

ERPs可以通过脑电图(EEG)可靠地测量,脑电图是一种通过放置在头皮上的电极来测量随时间变化的大脑电活动的方法.脑电图反映了数千个同时进行的大脑过程.这意味着大脑对单一刺激或感兴趣的事件的反应通常在单个试验的脑电图记录中不可见.为了观察大脑对刺激的反应,实验者必须进行多次试验并将结果平均,使随机的大脑活动平均,相关的波形保持不变,这就是所谓的ERP.

用一句话来讲:事件相关电位是与特定的物理事件或心理事件在时间上相关的电压波动.

```{admonition} 来自维基百科的定义
An event-related potential (ERP) is the measured brain response that is the direct result of a specific sensory, cognitive, or motor event. More formally, it is any stereotyped electrophysiological response to a stimulus.
```


## 大脑产生的与事件相关的电压波动意味着什么?

ERP是神经信息处理的毫秒级记录,反应了大脑的感觉编码,抑制反应和更新工作记忆等特定的操作的神经活动.下面是笔者整理的几个例子,或许能够帮助读者理解事件相关电位的意义.

### 听觉注意

1973年,希利亚德设计了一个巧妙的实验,在一定程度上解释了听觉的注意机制.他们通过耳机在被试的两耳同时呈现不同音高的声音刺激流,在一种条件下要求被试注意呈现在左耳的刺激而忽略右耳,在另一种条件下则注意右耳的刺激而忽略左耳.这样,研究者就可以在被试只注意一侧耳刺激的条件下记录两个声音诱发的事件相关电位反应.结果发现,刺激注意与刺激忽略条件相比,听觉事件相关电位的振幅明显放大了.由于这个波是在刺激呈现后事件相关电位的第一个显著负波(N1波),而N1波成分是一种由感觉刺激诱发的脑波.所以,实验结果可能是感觉加工早期选择的证据.


```{image} img/Screenshot_20210831_105501.png
:alt: 听觉注意
:width: 400px
:align: center
```


### 视觉注意

采用事件相关电位技术,也可以直接测量脑内负责加工视觉刺激神经元的电活动,揭示选择注意是如何影响脑对视觉刺激加工的.心理学家伊森等人在1969年做了一个实验:要求被试有意将注意力暗中指向左侧(或者右侧)的某个位置,可以使事件相关电位在刺激出现后70-80毫秒的正波明显增高,这一成分称为P1波.

```{image} img/Screenshot_20210831_105258.png
:alt: P1
:width: 400px
:align: center
```

空间位置注意的P1波效应仅仅在空间注意时出现.在注意选择其它视觉特征,如颜色,空间频率,方向或这些特征的结合时都不会出现.进一步的研究显示,视觉空间选择性注意是通过调节视觉皮层的加工实现的.这些效应最初发生在纹外皮层,也可能包含纹状皮层.证据来自如下几方面:1,P1波效应在头皮上方的分布类似网膜图,在对侧枕区最大,这与视觉通路对侧投射是一致的;2,选择注意引起的事件相关电位潜伏期(70毫秒)和纹外皮层神经元放电的潜伏期一致;3,功能成像研究也表明,注意力对感觉加工调节发生在纹外皮层.

## 事件相关电位如何提取和分析?

由于其它噪声的干扰,事件相关电位很难直接从原始数据中观察到.为了提取到事件相关电位,需要做一些基本的假设:

1. 在每次实验中,事件发生后段时间内,感兴趣的信号延迟和形状都不会变.
2. 根据中心极限定理,在实验的次数足够多时,过程中的干扰的均值服从均值为0,方差为$\sigma ^2$的正态分布

```{admonition} 中心极限定理
简单地讲,这个定理说明了足够多的独立随机变量的均值近似正态分布.
```

具体的处理过程见下面的动画演示

### 动画

<iframe src="//player.bilibili.com/player.html?aid=462746265&bvid=BV1rL41147Xn&cid=400866786&page=1" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true" style="width: 640px; height: 430px; max-width: 100%"> </iframe>

### 数学定义
计算事件相关电位具体的数学过程如下.

设在第$k$次实验中,$t$时刻在电极上采集到的通道平均信号$x(t,k)$由原信号$s(t)$和噪声$n(t,k)$组成:

$$
x(t,k) = s(t) + n(t,k).
$$

总共做了$N$次实验,$N$次实验均值$\bar{x}(t)$即为该实验的事件相关电位:

$$
\bar{x}(t) = \frac{1}{N}\sum^{N}_{k=1} x(t,k) = s(t) +\frac{1}{N}\sum^{N}_{k=1} n(t,k)
$$

```{note}
在大多数研究中,只关心事件发生附近一个时间窗口内(通常小于1秒)的ERP,因为ERP在事件发生700ms后会逐渐减弱到零.若令事件发生的时刻$t=0$,$t$取1秒,则时间窗口可以取$-0.1<t<0.9$.
```

那么,$\bar{x}(t)$的期望$\mathrm{E}[\bar{x}(t)] = s(t)$,$\bar{x}(t)$的方差为:

$$
\operatorname{Var}[\bar{x}(t)]=\mathrm{E}\left[(\bar{x}(t)-\mathrm{E}[\bar{x}(t)])^{2}\right]=\frac{1}{N^{2}} \mathrm{E}\left[\left(\sum_{k=1}^{N} n(t, k)\right)^{2}\right]=\frac{1}{N^{2}} \sum_{k=1}^{N} \mathrm{E}\left[n(t, k)^{2}\right]=\frac{\sigma^{2}}{N}
$$

### 如何判断ERP的显著性?
在求得ERP后,怎样证明这个ERP与事件相关?换句话讲,即如何证明该ERP与别的采样信号(同样时间窗口)有显著性差异?

简单地说,快速判断ERP显著性方法如下:

在画ERP曲线时,同时画出其95%置信区间.在$t$时刻,其置信区间不包含0,则能判断该时刻的ERP是显著的,在此情况下,置信区间越窄,越远离0,则显著性越强.

如果要严格地证明,可以使用假设检验的方法,如t检验.

```{note}
许多涉及实验的BCI研究都会用到假设检验,我讲另写一篇文章来列举并分析BCI研究中用到的假设检验方法.
```

## 如何使用程序来分析ERP
### eeglab

[eeglab](https://sccn.ucsd.edu/eeglab/index.php)是研究者们最常用的脑电分析工具

```{image} img/400px-Eeglab_small.jpg
:alt: eeglab
:width: 400px
:align: center
```

由于eeglab提供了图形化界面,在eeglab中分析ERP非常容易,详细的内容可以参考[eeglab官方文档](https://eeglab.org/tutorials/08_Plot_data/Data_Averaging.html)

### mne

mne是一个用于分析EEG,MEG,ECoG和NIRS等神经生理学数据的python库,相对于eeglab来说更加灵活.

就ERP而言,mne能够提供更加多样的分析.下面给出一个例子:

```{code-block} python
epochs.plot_joint()
```
```{image} img/sphx_glr_30_eeg_erp_010.png
:alt: erp1
:width: 600px
:align: center
```

更详细的内容可以参考[这个链接](https://mne.tools/stable/auto_tutorials/evoked/30_eeg_erp.html).



3 changes: 2 additions & 1 deletion build/html/_sources/FT_Interactive_animation.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

其实,从在课堂上学到傅利叶变换后的很长一段时间里我都还没有领会到其妙处,直到我看到了这个视频:

<iframe src="//player.bilibili.com/player.html?aid=19141078&bvid=BV1pW411J7s8&cid=31220967&page=1" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"style="width: 640px; height: 430px; max-width: 100%" > </iframe>
<iframe src="//player.bilibili.com/player.html?aid=19141078&bvid=BV1pW411J7s8&cid=31220967&page=1" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true" style="width: 640px; height: 430px; max-width: 100%" > </iframe>



Expand All @@ -17,6 +17,7 @@
```



```{admonition} 注意
:class: note
要体验交互功能,您需要{download}`下载.ipynb文件<src/FT_code.ipynb>`后在本地运行.如果您不熟悉jupyter notebook,请看[这里](https://jupyter.org/)
Expand Down
8 changes: 8 additions & 0 deletions build/html/_sources/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,13 @@
Welcome to bkxcyu's documentation!
====================================

我将在这里分享一些有关BCI的数学直觉.


.. toctree::
:maxdepth: 2
:hidden:
:caption: Getting Started

FT_Interactive_animation.md
ERP.md
16 changes: 13 additions & 3 deletions build/html/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>索引 &#8212; demo 文档</title>
<title>索引 &#8212; BCI Intuition 文档</title>

<link href="_static/css/theme.css" rel="stylesheet" />
<link href="_static/css/index.c5995385ac14fb8791e8eb36b4908be2.css" rel="stylesheet" />
Expand Down Expand Up @@ -57,15 +57,20 @@
<a class="navbar-brand text-wrap" href="index.html">


<h1 class="site-logo" id="site-title">demo 文档</h1>
<h1 class="site-logo" id="site-title">BCI Intuition 文档</h1>

</a>
</div><form class="bd-search d-flex align-items-center" action="search.html" method="get">
<i class="icon fas fa-search"></i>
<input type="search" class="form-control" name="q" id="search-input" placeholder="Search the docs ..." aria-label="Search the docs ..." autocomplete="off" >
</form><nav class="bd-links" id="bd-docs-nav" aria-label="Main">
<div class="bd-toc-item active">
<ul class="nav bd-sidenav">
<p class="caption">
<span class="caption-text">
Getting Started
</span>
</p>
<ul class="nav bd-sidenav">
<li class="toctree-l1">
<a class="reference internal" href="FT_Interactive_animation.html">
傅利叶变换: 以
Expand All @@ -75,6 +80,11 @@ <h1 class="site-logo" id="site-title">demo 文档</h1>
​为例
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="ERP.html">
事件相关电位
</a>
</li>
</ul>

</div>
Expand Down

0 comments on commit 908dae6

Please sign in to comment.