# BCI @ AIT
This simple project was created to demonstrate how BCI can be done from data acquisition, running the experiment, and analyzing the data perspective, mainly for my students at Asian Institute of Technology, ICT Department. It is intended to quickly boostrap my lab students for starting their research. This is an ongoing project and I intend to populate this with at least six topics (see below), all of which are ongoing research topics in my lab.
## About
Hardware:
- OpenBCI + Cyton, Sampling rate of 250Hz
Software:
- Python
Some basic terminology defined for new students:
1. **Online vs. Offline analysis**: Online refers to real-time I/O of EEG signals while offline analysis refers to recording and aftermath analysis. Both kind of analysese are required - offline analysis allows us to figure optimal parameters and setup, while online analysis is about really putting the system in real usage
2. **P300, SSVEP, Motor Imagery, Power Spectrum**: These terms describe the paradigm of how brain signals are evoked. There are different ways in which brain generates some patterns of signals (in volts). For example, when we encounter some rare but interested stimuli, there will be a spike occuring around 300ms-500ms after the onset of that stimuli, this is called **P300**. For another example, when we look at two stimuli flickering with different frequency, let's say 10 and 15hz respectively, we can detect which one users are looking at because similar, harmonic frequencies (e.g., 15hz, 30hz, 45hz, etc.) will be shown in users' EEG signals, this is called **SSVEP**. When users are having high cognitive load, we can infer from power of each frequency band by performing Fourier Transform (or Wavelet Transform). As a easy way to think about this, when you are stressed, your brain generates very high frequency signal, vice versa, when you are calm, most of your brain signals tend to fall in low frequency range. This is called **Power spectral Density**. Not surprisingly, P300, SSVEP, and PSD can all be triggered by audio/visual/haptic stimuli. As for more user-generated signal rather than relying on external stimuli, brain signals can be evoked by asking the users to perform certain thought (e.g., thinking of moving left), which then developers can map these brain signals to commands. This is called **Motor Imagery**
3. **Nyquist theorem**: describes a fundamental law in which the highest frequency component should be 1/2 * sampling rate. For example, if our device is 250hz, then the highest frequency component we can investigate is 125hz. This is because we need at least two samples per time point to make a judgement of that frequency rate. In simple words, even our device sampling rate is 250hz, we can only investigate users' frequency band until 125hz. Fortunately, in BCI, the interested frequency band is typically around 4 - 50 hz.
4. **Lab Streaming Layer**: a network protocol for streaming time-series data (e.g., eeg data, markers). We are using pylsl python library.
5. **Markers**: markers refer to temporal events, such as image displaying. We need to map markers to eeg signals, so we can infer what is happening when the stimuli (i.e., markers/events) are shown. LSL can be used to push markers as well as eeg signals.
6. **Epochs**: refers to windowed eeg signals that are event-bound. For example, we may be interested to chop the eeg signal from 0.2 to 0.5s after the onset of the stimuli and check what is happening during that period. MNE-python are commonly used to get epochs but coding from scratch can also be done (see P300 code).
7. **Signal filters (bandpass/notch filters)**: refers to process of removing unwanted frequency band from the signals. For example, in many countries, our electrical devices emit 50hz which can be artifact thus we may want to apply a **notch filter** of 50hz. For another example, for P300, the frequency band in interest is typically around 1 to 30hz, thus we may want to perform a **bandpass filter** with low cut of 1 and high cut of 30hz. Signal filtering can be done using the scipy.signal python library.
8. **Artifacts**: refers to noise of EEG signals. Sources include eye blinks, muscle/head movements, random thoughts. Can be partially fix by ICA (Independent Component Analysis) or simply restrict your participants (tell him/her do not move!) or use baseline corrections. For ICA, using MNE-python can be easily be achieved.
All code will be centered around 3 typical steps
1. Data acquisition (Credit: https://github.com/NeuroTechX)
2. Experiment (stimuli) (Online/Offline experiment)
3. Analysis (Offline analysis)
Topics include:
1. **Psychological Experiment** - follows typical paradigm of showing stimuli and inferring user's state based on EEG signal, typically power spectrum (e.g., alpha). Offline analysis based. Useful for students to understand the basic setup of the EEG system.
2. **SSVEP Control** - aims to create an unsupervised online classification of three targets using Filter-bank Canonical Correlation Analysis. Since this is unsupervised, offline analysis is done mainly to identify optimal parameters (e.g., epoch width). Useful for students to understand the SSVEP paradigms.
3. **P300 Speller** - aims to create a 6 x 6 matrix speller using different stimuli variations; unsupervised method (e.g., discriminant analysis) will be demonstrated for online classification. Useful for students to understand how ERP works.
4. **Motor Imagery Control** - aims to allow users to train left/right movement thoughts to control left/right movements
Things need to take precaution:
- To get a clean signal, it is important to **stay at a location free of electric artifacts**. When you look at your brain signals using lsl-viewer, it should be around low frequency, around -10 or less. If it is more, try make sure your feet/hand is touching the ground and see whether the volts changes. Also, if your bluetooth receiver is near the power outlet, it can also increase the frequency significantly. Try move to different locations that are free of power influences. Last, even your feet/hand is grounded, make sure no electricity is on the ground!, e.g., leaving some plugs on the ground
## How to run
1. **Psychological Experiment**
1. Run <code>python lsl-stream</code> on the background
2. Run <code>python lsl-viewer</code> on another tab; brain microvolts should be around -10; make sure you are properly grounded (you can close after checking)
3. Run <code>python offline_experiment.py</code> (do not click space yet)
4. Run <code>python lsl-record</code> on another tab; it should detect the marker stream from (iii)
5. Press space bar from (iii)
6. Data can be found in 3-analysis/data; Open Offline.ipynb for offline analysis
2. **SSVEP**
1. Run <code>python lsl-stream</code> on the background
2. Run <code>python lsl-viewer</code> on another tab to check and then close
3. Run <code>python offline_experiment.py</code> (do not click space yet)
4. Run <code>python lsl-record</code> on another tab; it should detect the marker stream from (iii)
5. Press space bar from (iii)
6. Data can be found in 3-analysis/data; Open Offline.ipynb for offline analysis. Since we are using unsupervised CCA, this file is mainly to find the optimal parameters when used with online
7. run <code> python online_classifier.py </code> (make sure to do this before step (viii), or else, no markers stream will be found)
8. Now, <code> python online_experiment.py </code>
3. **P300**
1. Run <code>python lsl-stream</code> on the background
2. Run <code>python lsl-viewer</code> on another tab to check and then close
3. Run <code>python offline_experiment.py</code> (do not click space yet)
4. Run <code>python lsl-record</code> on another tab; it should detect the marker stream from (iii)
5. Press Start from (iii)
6. Data can be found in 3-analysis/data
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
这个简单的项目是为了演示如何从数据采集、运行实验和分析数据的角度来完成BCI,主要是为我在亚洲理工学院ICT系的学生创建的。它的目的是快速引导我的实验室学生开始他们的研究。这是一个正在进行的项目,我打算用至少六个主题填充这个项目(见下文),所有这些都是我实验室正在进行的研究主题。 Psychological Experiment Run python lsl-stream on the background Run python lsl-viewer on another tab; brain microvolts should be around -10; make sure you are properly grounded (you can close after checking) Run python offline_experiment.py (do not click space yet) Run python lsl-record on another tab; it should detect the marker stream from (iii)
资源推荐
资源详情
资源评论
收起资源包目录
P300,SSVEP脑电信号采集到分析处理教学 (1190个子文件)
anger-amuse-61trials-6s.csv 11.33MB
anger-amuse-100trials-3s.csv 9.08MB
anger-amuse-32trials-6s.csv 7.15MB
ssvep-20trials-3s-chaky-bigsquare.csv 6.01MB
ssvep-20trials-3s-chaky-bigsquare-2nd.csv 5.7MB
p300-6trials-12rep-chaky.csv 4.68MB
anger-amuse-10trials-10sec.csv 4MB
ssvep-10trials-3s-chaky-bigsquare.csv 3.17MB
sit_cb1.csv 2.82MB
sit_cb0.csv 2.34MB
sit_cb2.csv 2.3MB
sit_cb3.csv 2.24MB
sit_cb4.csv 2.23MB
sit_cb5.csv 2.14MB
p300-6trials-3rep-chaky.csv 1.97MB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.gitignore 1KB
Offline.ipynb 2.82MB
offline_analysis.ipynb 1.18MB
Offline.ipynb 1.07MB
combine_par_data.ipynb 492KB
EM-Offline.ipynb 486KB
Offline.ipynb 266KB
train_model.ipynb 17KB
einstein.jpg 587KB
einstein.jpg 587KB
sad_0647.jpg 73KB
chaky-ConvertImage.jpg 71KB
sad_0312.jpg 65KB
sad_0357.jpg 64KB
fear_0964.jpg 60KB
sad_0414.jpg 59KB
contentment_0129.jpg 59KB
disgust_0809.jpg 55KB
excitement_0268.jpg 55KB
sad_0288.jpg 54KB
disgust_0760.jpg 54KB
excitement_0237.jpg 53KB
excitement_0240.jpg 53KB
sad_0371.jpg 53KB
excitement_0182.jpg 52KB
excitement_0187.jpg 52KB
disgust_0787.jpg 50KB
amusement_0539.jpg 50KB
sad_0331.jpg 50KB
contentment_0101.jpg 50KB
amusement_0722.jpg 47KB
amusement_0519.jpg 47KB
excitement_0255.jpg 47KB
excitement_0236.jpg 46KB
disgust_0758.jpg 45KB
disgust_0776.jpg 45KB
disgust_0783.jpg 45KB
sad_0454.jpg 45KB
fear_0970.jpg 44KB
excitement_0202.jpg 44KB
excitement_0233.jpg 44KB
sad_0464.jpg 43KB
sad_0624.jpg 43KB
fear_0946.jpg 43KB
excitement_0223.jpg 42KB
fear_0926.jpg 42KB
sad_0385.jpg 42KB
excitement_0204.jpg 42KB
amusement_0491.jpg 42KB
anger_0253.jpg 42KB
anger_0028.jpg 42KB
disgust_0802.jpg 42KB
disgust_0807.jpg 42KB
disgust_0885.jpg 42KB
excitement_0165.jpg 42KB
sad_0617.jpg 42KB
anger_0262.jpg 42KB
disgust_0765.jpg 42KB
excitement_0213.jpg 41KB
disgust_0757.jpg 41KB
excitement_0176.jpg 41KB
amusement_0537.jpg 41KB
sad_0390.jpg 41KB
sad_0637.jpg 41KB
fear_0681.jpg 41KB
disgust_0767.jpg 41KB
amusement_0743.jpg 41KB
excitement_0226.jpg 41KB
amusement_0731.jpg 41KB
excitement_0261.jpg 40KB
amusement_0508.jpg 40KB
excitement_0246.jpg 40KB
sad_0446.jpg 40KB
disgust_0805.jpg 40KB
excitement_0239.jpg 40KB
awe_0600.jpg 40KB
fear_0673.jpg 39KB
amusement_0511.jpg 39KB
awe_0852.jpg 39KB
excitement_0267.jpg 39KB
excitement_0188.jpg 39KB
共 1190 条
- 1
- 2
- 3
- 4
- 5
- 6
- 12
资源评论
- 2301_798720282024-03-19资源不错,内容挺好的,有一定的使用价值,值得借鉴,感谢分享。
大大U
- 粉丝: 721
- 资源: 135
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Pytorch-pytorch深度学习教程之逻辑回归.zip
- Pytorch-pytorch深度学习教程之双向循环网络.zip
- Pytorch-pytorch深度学习教程之卷积神经网络.zip
- Pytorch-pytorch深度学习教程之前馈神经网络.zip
- Pytorch-pytorch深度学习教程之线性回归.zip
- Pytorch-pytorch深度学习教程之基本操作.zip
- 基于QT的地图可视化桌面系统后台数据库为MySQL5.7源码.zip
- 基于simulink的PLL锁相环系统仿真【包括模型,文档,参考文献,操作步骤】
- 基于EM-GMM模型的目标跟踪和异常行为检测matlab仿真【包括程序,注释,参考文献,操作步骤,说明文档】
- 2109010044_胡晨燕_选课管理数据库设计与实现.prj
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功