BCI IV-2a 运动想象论文代码复现

论文:EEG-TCNet: An Accurate Temporal Convolutional Network for Embedded Motor-Imagery Brain–Machine Interfaces

数据:The BCI Competition IV-2a dataset

数据描述请到官网

环境

win10,pycham2020.2

python版本:Python 3.7.9 

安装包:

C:\Users\Administrator>pip list
Package                Version
---------------------- ----------
absl-py                0.11.0
argon2-cffi            20.1.0
astor                  0.8.1
astunparse             1.6.3
async-generator        1.10
attrs                  20.3.0
backcall               0.2.0
bidict                 0.21.2
biosppy                0.6.1
bleach                 3.2.1
cachetools             4.2.0
certifi                2020.12.5
cffi                   1.14.4
chardet                4.0.0
chart-studio           1.1.0
colorama               0.4.4
cycler                 0.10.0
decorator              4.4.2
defusedxml             0.6.0
entrypoints            0.3
flatbuffers            1.12
gast                   0.2.2
google-auth            1.24.0
google-auth-oauthlib   0.4.2
google-pasta           0.2.0
grpcio                 1.32.0
h5py                   2.10.0
idna                   2.10
importlib-metadata     3.3.0
ipykernel              5.4.2
ipython                7.19.0
ipython-genutils       0.2.0
ipywidgets             7.6.2
jedi                   0.18.0
Jinja2                 2.11.2
joblib                 1.0.0
jsonschema             3.2.0
jupyter                1.0.0
jupyter-client         6.1.7
jupyter-console        6.2.0
jupyter-core           4.7.0
jupyterlab-pygments    0.1.2
jupyterlab-widgets     1.0.0
Keras                  2.3.1
Keras-Applications     1.0.8
Keras-Preprocessing    1.1.2
kiwisolver             1.3.1
Markdown               3.3.3
MarkupSafe             1.1.1
matplotlib             3.3.3
mistune                0.8.4
mne                    0.22.0
nbclient               0.5.1
nbconvert              6.0.7
nbformat               5.0.8
nest-asyncio           1.4.3
notebook               6.1.6
numpy                  1.19.4+mkl
oauthlib               3.1.0
opencv-python          4.4.0.46
opt-einsum             3.3.0
packaging              20.8
pandas                 1.2.0
pandocfilters          1.4.3
parso                  0.8.1
pickleshare            0.7.5
Pillow                 8.0.1
pip                    20.3.3
plotly                 4.14.1
prometheus-client      0.9.0
prompt-toolkit         3.0.8
protobuf               3.14.0
pyasn1                 0.4.8
pyasn1-modules         0.2.8
pycparser              2.20
Pygments               2.7.3
pyparsing              2.4.7
pyriemann              0.2.6
pyrsistent             0.17.3
python-dateutil        2.8.1
pytz                   2020.5
PyWavelets             1.1.1
pywin32                300
pywinpty               0.5.7
pywt                   1.0.6
PyYAML                 5.3.1
pyzmq                  20.0.0
qtconsole              5.0.1
QtPy                   1.9.0
requests               2.25.1
requests-oauthlib      1.3.0
retrying               1.3.3
rsa                    4.6
scikit-learn           0.21.3
scipy                  1.6.0
seaborn                0.11.1
Send2Trash             1.5.0
setuptools             51.1.1
shortuuid              1.0.1
six                    1.15.0
tensorboard            2.0.2
tensorboard-plugin-wit 1.7.0
tensorflow             2.0.0
tensorflow-estimator   2.0.1
termcolor              1.1.0
terminado              0.9.1
testpath               0.4.4
threadpoolctl          2.1.0
tornado                6.1
traitlets              5.0.5
typing-extensions      3.7.4.3
urllib3                1.26.2
wcwidth                0.2.5
webencodings           0.5.1
Werkzeug               1.0.1
wheel                  0.36.2
widgetsnbextension     3.5.1
wrapt                  1.12.1
zipp                   3.4.0

 

复现结果

For Subject: 1, Accuracy: 85.76512455516014, Kappa: 0.8101928467695633.
For Subject: 2, Accuracy: 65.01766784452296, Kappa: 0.5339432753888381.
For Subject: 3, Accuracy: 94.5054945054945, Kappa: 0.926729767932867.
For Subject: 4, Accuracy: 64.91228070175438, Kappa: 0.5318755774561132.
For Subject: 5, Accuracy: 75.36231884057972, Kappa: 0.671779087459121.
For Subject: 6, Accuracy: 61.395348837209305, Kappa: 0.4850076476869354.
For Subject: 7, Accuracy: 87.36462093862815, Kappa: 0.8317628889235948.
For Subject: 8, Accuracy: 83.76383763837639, Kappa: 0.7835188177411448.
For Subject: 9, Accuracy: 78.03030303030303, Kappa: 0.7066441872940455.
For Subject: 1, Accuracy: 89.32384341637011, Kappa: 0.8576302100925488.
For Subject: 2, Accuracy: 72.43816254416961, Kappa: 0.6325715331990611.
For Subject: 3, Accuracy: 97.43589743589743, Kappa: 0.9658072250353379.
For Subject: 4, Accuracy: 75.87719298245614, Kappa: 0.6782800554158757.
For Subject: 5, Accuracy: 83.69565217391305, Kappa: 0.7826885727783319.
For Subject: 6, Accuracy: 70.69767441860465, Kappa: 0.6094853683148335.
For Subject: 7, Accuracy: 93.14079422382672, Kappa: 0.9085903848825899.
 

  • 0
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 9
    评论
BCI Competition IV 2a数据集转换为Legacy TU Dataset的Python代码如下: ```python import numpy as np import mne # Load the BCI Competition IV 2a dataset data_train = np.load('A01T.npz') data_test = np.load('A01E.npz') # Extract features and labels from the dataset X_train = data_train['data'] y_train = data_train['labels'] X_test = data_test['data'] y_test = data_test['labels'] # Reshape the data arrays to match the Legacy TU Dataset format X_train = X_train.reshape(-1, 22, 1000).transpose(0, 2, 1) y_train = y_train.reshape(-1) X_test = X_test.reshape(-1, 22, 1000).transpose(0, 2, 1) y_test = y_test.reshape(-1) # Create MNE Raw objects for both the training and testing data ch_names = ['Fz', 'FC3', 'FC1', 'FCz', 'FC2', 'FC4', 'C5', 'C3', 'C1', 'Cz', 'C2', 'C4', 'C6', 'CP3', 'CP1', 'CPz', 'CP2', 'CP4', 'P1', 'Pz', 'P2', 'POz'] sfreq = 250 info = mne.create_info(ch_names=ch_names, sfreq=sfreq, ch_types='eeg') raw_train = mne.io.RawArray(X_train, info) raw_test = mne.io.RawArray(X_test, info) # Add event markers for the labels in both the training and testing data events_train = np.vstack((np.arange(len(y_train)), np.zeros(len(y_train)), y_train)).T events_test = np.vstack((np.arange(len(y_test)), np.zeros(len(y_test)), y_test)).T raw_train.add_events(events_train, stim_channel='STI 014') raw_test.add_events(events_test, stim_channel='STI 014') # Save the MNE Raw objects as .fif files mne.io.write_raw_fif(raw_train, 'A01T_raw.fif', overwrite=True) mne.io.write_raw_fif(raw_test, 'A01E_raw.fif', overwrite=True) ``` 这段代码假设您已经将BCI Competition IV 2a数据集下载到当前工作目录中,并已将其命名为"A01T.npz"和"A01E.npz"。代码使用NumPy和MNE库来加载、处理和保存数据。它首先从.npz文件中提取数据和标签,并将其转换为符合Legacy TU Dataset格式的形式。然后,代码使用MNE库创建了两个Raw对象,一个用于训练数据,另一个用于测试数据。最后,代码将标签添加为事件标记,并将MNE Raw对象保存为.fif文件。
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大大U

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值