【脑机接口】MNE-python 安装与入门使用

一开始接触EEG脑电数据分析,师哥推荐用Matlab的EEGLAB,但感觉实在是不习惯Matlab的使用方式,于是开始找python里可以用于处理脑电数据的包。从百度上很快就找到了MNE这个包,果然这世界上跟我一样想用python处理脑电的人大有人在(


在这里插入图片描述
MNE是一个用于可视化和分析人类神经生理数据的开源 Python 包,可以分析并处理MEG、EEG、sEEG、ECoG、NIRS 等生理数据。

1. 安装

首先确保安装好了numpy、scipy、matlibplot等MNE的依赖库

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple MNE
import os
import mne
import matplotlib.pyplot as plt
import numpy as np

from scipy import signal

2.数据读取

MNE提供了多种读取函数,可以读取.set; .fdt; .edf; .gdf等不同的脑电数据格式
在这里插入图片描述
以.gdf格式为例
在这里插入图片描述
返回的是一个raw实例

参数说明

input_fname [str]
Path to the GDF file.
GDF文件的路径

eog [list or tuple]
Names of channels or list of indices that should be designated EOG channels. Values should correspond to the electrodes in the file. Default is None.
指定眼电通道

misc [list or tuple]
Names of channels or list of indices that should be designated MISC channels. Values should correspond to the electrodes in the file. Default is None.
指定MISC通道

stim_channel [‘auto’ | str | list of str | int | list of int]
Defaults to ‘auto’, which means that channels named ‘status’ or ‘trigger’ (case insensitive) are set to STIM. If str (or list of str), all channels matching the name(s) are set to STIM. If int (or list of ints), channels corresponding to the indices are set to STIM.
指定STIM通道(默认设置名为‘status’ or ‘trigger’的通道为STIM)

excludelist of str | str
Channel names to exclude. This can help when reading data with different sampling rates to avoid unnecessary resampling. A str is interpreted as a regular expression.
指定读取时排除的通道

preloadbool or str (default False)
Preload data into memory for data manipulation and faster indexing. If True, the data will be preloaded into memory (fast, requires large amount of memory). If preload is a string, preload is the file name of a memory-mapped file which is used to store the data on the hard drive (slower, requires less memory).
将数据预加载到内存中,以便进行数据操作和加快索引

verbosebool | str | int | None
Control verbosity of the logging output. If None, use the default verbosity level. See the logging documentation and mne.verbose() for details. Should only be passed as a keyword argument.
控制日志输出的详细程度

脑电数据来自BCI Competition IV dataset 2a

path = 
  • 7
    点赞
  • 40
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值