Giter VIP home page Giter VIP logo

metabci's Introduction

MetaBCI

Welcome!

MetaBCI is an open-source platform for non-invasive brain computer interface. The project of MetaBCI is led by Prof. Minpeng Xu from Tianjin University, China. MetaBCI has 3 main parts:

  • brainda: for importing dataset, pre-processing EEG data and implementing EEG decoding algorithms.
  • brainflow: a high speed EEG online data processing framework.
  • brainstim: a simple and efficient BCI experiment paradigms design module.

This is the first release of MetaBCI, our team will continue to maintain the repository. If you need the handbook of this repository, please contact us by sending email to [email protected] with the following information:

  • Name of your teamleader
  • Name of your university(or organization)

We will send you a copy of the handbook as soon as we receive your information.

What are we doing?

The problem

  • BCI datasets come in different formats and standards
  • It's tedious to figure out the details of the data
  • Lack of python implementations of modern decoding algorithms
  • It's not an easy thing to perform BCI experiments especially for the online ones.

If someone new to the BCI wants to do some interesting research, most of their time would be spent on preprocessing the data, reproducing the algorithm in the paper, and also find it difficult to bring the algorithms into BCI experiments.

The solution

The Meta-BCI will:

  • Allow users to load the data easily without knowing the details
  • Provide flexible hook functions to control the preprocessing flow
  • Provide the latest decoding algorithms
  • Provide the experiment UI for different paradigms (e.g. MI, P300 and SSVEP)
  • Provide the online data acquiring pipeline.
  • Allow users to bring their pre-trained models to the online decoding pipeline.

The goal of the Meta-BCI is to make researchers focus on improving their own BCI algorithms and performing their experiments without wasting too much time on preliminary preparations.

Features

  • Improvements to MOABB APIs

    • add hook functions to control the preprocessing flow more easily
    • use joblib to accelerate the data loading
    • add proxy options for network connection issues
    • add more information in the meta of data
    • other small changes
  • Supported Datasets

    • MI Datasets
      • AlexMI
      • BNCI2014001, BNCI2014004
      • PhysionetMI, PhysionetME
      • Cho2017
      • MunichMI
      • Schirrmeister2017
      • Weibo2014
      • Zhou2016
    • SSVEP Datasets
      • Nakanishi2015
      • Wang2016
      • BETA
  • Implemented BCI algorithms

    • Decomposition Methods
      • SPoC, CSP, MultiCSP and FBCSP
      • CCA, itCCA, MsCCA, ExtendCCA, ttCCA, MsetCCA, MsetCCA-R, TRCA, TRCA-R, SSCOR and TDCA
      • DSP
    • Manifold Learning
      • Basic Riemannian Geometry operations
      • Alignment methods
      • Riemann Procustes Analysis
    • Deep Learning
      • ShallowConvNet
      • EEGNet
      • ConvCA
      • GuneyNet
    • Transfer Learning
      • MEKT
      • LST

Installation

  1. Clone the repo
    git clone https://github.com/TBC-TJU/MetaBCI.git
  2. Change to the project directory
    cd MetaBCI
  3. Install all requirements
    pip install -r requirements.txt 
  4. Install brainda package with the editable mode
    pip install -e .

Who are we?

The MetaBCI project is carried out by researchers from

  • Academy of Medical Engineering and Translational Medicine, Tianjin University, China
  • Tianjin Brain Center, China

What do we need?

You! In whatever way you can help.

We need expertise in programming, user experience, software sustainability, documentation and technical writing and project management.

We'd love your feedback along the way.

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated. Especially welcome to submit BCI algorithms.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the GNU General Public License v2.0 License. See LICENSE for more information.

Contact

Email: [email protected]

Paper

If you applied MetaBCI in your research, please cite: Mei, J., Luo, R., Xu, L., Zhao, W., Wen, S., Wang, K., ... & Ming, D. (2023). MetaBCI: An open-source platform for brain-computer interfaces. Computers in Biology and Medicine, 107806.

And this open access paper can be found here: MetaBCI

Acknowledgements

metabci's People

Contributors

bbencor3 avatar bettyjiang22 avatar ch-meijie avatar erjanmx avatar hbonnie avatar heoohuan avatar hori7on7 avatar hzs0922 avatar jielu-wu avatar jieyu1999 avatar jly0107 avatar junyang-wang avatar lisimsim avatar liuyuwei905 avatar miyanyan avatar mrswolf avatar mute-xd avatar promiseyou1 avatar ruixinluo avatar tbc-tju avatar xiwangsun666 avatar zhouziyu2050 avatar zvivian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

metabci's Issues

请问 实现类Marker 是否可以实现不同的event 对应不同的时间窗

比如 我现在的的events 为[1,2] 对应的时间窗为[ [0 , 4] , [-1 , 3] ]
虽然我的请求有点怪 但是贵校在 BaseParadigm类的_map_events_intervals方法中有这样的处理

def _map_events_intervals(self, dataset: BaseDataset):
        event_list = self.event_list
        intervals = self.intervals

        if event_list is None:
            # use all events in dataset
            event_list = list(dataset.events.keys())

        used_events = {ev: dataset.events[ev][0] for ev in event_list}

        if intervals is None:
            used_intervals = {ev: dataset.events[ev][1] for ev in event_list}
        elif len(intervals) == 1:
            used_intervals = {ev: intervals[0] for ev in event_list}
        else:
            if len(event_list) != len(intervals):
                raise ValueError(
                    "intervals should be the same number of events")
            used_intervals = {
                ev: interval for ev, interval in zip(event_list, intervals)
            }

        return used_events, used_intervals

Offline_mi.py运行报错

joblib.externals.loky.process_executor._RemoteTraceback:
"""
Traceback (most recent call last):
File "D:\ProgramData\Miniconda3\envs\psychopy\lib\site-packages\joblib\externals\loky\process_executor.py", line 428, in _process_worker
r = call_item()
File "D:\ProgramData\Miniconda3\envs\psychopy\lib\site-packages\joblib\externals\loky\process_executor.py", line 275, in call
return self.fn(*self.args, **self.kwargs)
File "D:\ProgramData\Miniconda3\envs\psychopy\lib\site-packages\joblib_parallel_backends.py", line 620, in call
return self.func(*args, **kwargs)
File "D:\ProgramData\Miniconda3\envs\psychopy\lib\site-packages\joblib\parallel.py", line 288, in call
return [func(*args, **kwargs)
File "D:\ProgramData\Miniconda3\envs\psychopy\lib\site-packages\joblib\parallel.py", line 288, in
return [func(*args, **kwargs)
File "", line 10, in _get_single_subject_data
File "C:\Users\WTP\Desktop\MetaBCI-master\metabci\brainda\paradigms\base.py", line 195, in _get_single_subject_data
data = dataset.get_data([subject_id])
File "", line 12, in get_data
File "C:\Users\WTP\Desktop\MetaBCI-master\metabci\brainda\datasets\base.py", line 169, in get_data
data[subject] = self._get_single_subject_data(subject)
File "C:\Users\WTP\Desktop\MetaBCI-master\demos\brainflow_demos\datasets.py", line 108, in _get_single_subject_data
raw = read_raw_cnt(run_file,
File "D:\ProgramData\Miniconda3\envs\psychopy\lib\site-packages\mne\io\cnt\cnt.py", line 164, in read_raw_cnt
return RawCNT(input_fname, eog=eog, misc=misc, ecg=ecg,
File "D:\ProgramData\Miniconda3\envs\psychopy\lib\site-packages\mne\io\cnt\cnt.py", line 393, in init
info, cnt_info = _get_cnt_info(input_fname, eog, ecg, emg, misc,
File "D:\ProgramData\Miniconda3\envs\psychopy\lib\site-packages\mne\io\cnt\cnt.py", line 175, in _get_cnt_info
with open(input_fname, 'rb', buffering=0) as fid:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\WTP\Desktop\MetaBCI-master\demos\brainflow_demos\data\ssvep\sub1\1.cnt'
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:/Users/WTP/Desktop/MetaBCI-master/demos/brainflow_demos/Offline_ssvep.py", line 299, in
X, y, meta = paradigm.get_data(
File "", line 10, in get_data
File "C:\Users\WTP\Desktop\MetaBCI-master\metabci\brainda\paradigms\base.py", line 377, in get_data
*Parallel(n_jobs=n_jobs)(
File "D:\ProgramData\Miniconda3\envs\psychopy\lib\site-packages\joblib\parallel.py", line 1098, in call
self.retrieve()
File "D:\ProgramData\Miniconda3\envs\psychopy\lib\site-packages\joblib\parallel.py", line 975, in retrieve
self._output.extend(job.get(timeout=self.timeout))
File "D:\ProgramData\Miniconda3\envs\psychopy\lib\site-packages\joblib_parallel_backends.py", line 567, in wrap_future_result
return future.result(timeout=timeout)
File "D:\ProgramData\Miniconda3\envs\psychopy\lib\concurrent\futures_base.py", line 444, in result
return self.__get_result()
File "D:\ProgramData\Miniconda3\envs\psychopy\lib\concurrent\futures_base.py", line 389, in __get_result
raise self._exception
FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\WTP\Desktop\MetaBCI-master\demos\brainflow_demos\data\ssvep\sub1\1.cnt'

版本与解码问题

经使用刺激界面stim_demo.py发现,使用python3.10的环境会出现如下错误:
ImportError: cannot import name 'MutableMapping' from 'collections'
在3.10环境下lib下的collections的__init__.py文件里添加如下语句即可解决:
from collections.abc import Mapping
from collections.abc import MutableMapping
此时若出现以下json解码错误:
TypeError: JSONDecoder.init() got an unexpected keyword argument 'encoding'
可同样在3.10环境下lib下的json的__init__.py文件里的load函数处将如下语句更改:
def loads(s, *, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None,**kw):
更改为:
def loads(s, *, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, encoding='utf-8',**kw):
此时,再运行stim_demo.py 即可成功
希望可以帮助装好了环境又不想切换的小伙伴

恳请分享中文使用手册

老师您好,已将研究机构信息发送指定邮箱[email protected],请问多久可以收到中文使用手册。十分期待您的宝贵分享,如果效果良好本团队会在论文中鸣谢。

How to collect data?

Hello ,thank you for a great job!!! I'm a newbie in this area, is there any cheap equipment to collect data set for BCI ?

metabci/brainda/paradigms/base.py中229行

epochs = mne.Epochs(
raw,
selected_events,
event_id={event_name: used_events[event_name]},
event_repeated="drop",
tmin=used_intervals[event_name][0],
tmax=used_intervals[event_name][1]
- 1.0 / raw.info["sfreq"],
picks=picks,
proj=False,
baseline=None,
preload=True,
)

为什么这里要对tmax - 1.0 / sfreq

Integrate pre-commit

On the previous PR (now merged), I noted that there were several flake8 related issue. For open-source library, I think it would be nice to integrate pre-commit hook to ensure the code-styles of the library are consistent (https://pre-commit.com/), especially if you are expecting external contributors.

pip install issue

install issue
您好,很感谢你们做出MetaBCI这么好用的开源平台,可是我在安装的过程中一直遇到下面问题,希望您可以帮忙解决一下,谢谢!!!
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [7 lines of output]
Traceback (most recent call last):
File "", line 2, in
File "", line 34, in
File "C:\Users\29221\AppData\Local\Temp\pip-install-48_f4m0s\gevent_5ba2c49fd3b04bd79bd7e2f234710595\setup.py", line 95
print 'Linking %s to %s' % (path_to_build_core_so, path_to_core_so)
^
SyntaxError: invalid syntax
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

在线实验的具体操作流程是什么?

  很高兴可以使用贵校和贵团队开发的MetaBCI平台进行实验,但是我在进行运动想象的在线实验时产生了一些困惑,向您请教一下,主要问题是:在线实验的具体操作流程是什么?

  我使用了您项目中提供的范式demo-stim_demo.py,online=True作为在线实验范式,在线demo-Online_mi.py作为在线采集后台,我的操作流程是先运行范式界面,但是不进行任何操作(不点击enter),之后运行Online_mi.py,但是这样的操作流程会导致一些问题:
  第一个问题关于在线程序和刺激程序的连接,在运行Online_mi.py之后,切回在线范式时,在初始界面选中MI点击enter后,范式界面没有反应,不进入出现左右手的页面,而且FeedbackWorker在run()函数中,会产生except queue.Empty 异常,导致陷入循环等待。而在进行离线采集,online=false时,范式不用和在线程序进行连接时,可以正常运行,请问这是否代表我的在线程序和刺激程序并没有进行正确的连接,如何将在线程序和刺激程序进行正确的连接呢,仅仅保证lsl_source_id相同即可?
  第二个问题关于在线程序和NeuroScan的连接,我使用的是curry8的协议,NeuroScan36导联(不是64导联,此处有影响吗?),在ns.start_acq()里,会进行两次self.recv(​),其中第一次self.recv(​)可以正常运行,b_header ={bytes} b'DATA\x00 x01 x00 x01 x00 x00 x00 x00’,self._unpack_header(b_header)解析出来header = tuple <class 'tuple'>: ('DATA', 1, 1, 0),由于pkf_size=0,不从socket读取数据;但是第二次self.recv(​)运行异常,会陷入socket循环等待,主要原因是b_header ={bytes} b'x00 x00 x00 x04 x00 x00 x00 x00"x03 x00 x00',(此处有些异常,在第九位出现了双引号),self._unpack_header(b_header)解析出来为header = tuple <class 'tuple'>:( x00 x00 x00 x04', 0, 0, 570621952),其pkf_size=570621952,因此会从socket读取570621952数据,但是此时socket中并没有这么多数据,而且因为之前self.set_timeout(None),没有设置过期时间,因此陷入长时间的等待,请问这个问题是因为36导联或者是数据协议不同而产生的吗?
   非常感谢您的耐心阅读,我将会非常感谢您的回答!

Add openbci equipment

Say hi to author team.

this metabci project is a great job.

while i checked 'brainflow/amplifiers.py' , there is only Neuroscan, Neuracle, and Curry8. These equipment is fantasy good, while i am using openbci now. Is there any opportunity to get openbci-cython-daisy module to be added in. Or i will try develop on this.

openbci doc
openbci github-python-code

关于FBTDCA算法

作者你好,在给出的demos/FBTDCA.py中,intervals=[(0.14, 0.64+0.1)], 是不是意味着测试的时候,时间窗也变成0.6s了,得到的是信号长度为0.6s时的结果?
image

发现一处小的错误。

在domes/brainstim_demos/stim_demo.py的行3处
from matabci.brainstim.paradigm import SSVEP,P300,MI,paradigm
应该改为
from metabci.brainstim.paradigm import SSVEP,P300,MI,paradigm

Brainflow demos

Hi

wanna try running the demos, but unable to do it, does everyone has the same problem? Using python 3.7 at windows 11.

python3.8, an error occurs when running stim_demo.py

Hello, there is a dependency package error when running the change file.
Traceback (most recent call last):
File "D:/PycharmProjects/MetaBCI/demos/brainstim_demos/stim_demo.py", line 3, in
from metabci.brainstim.paradigm import SSVEP,P300,MI,AVEP,paradigm
File "D:\PycharmProjects\MetaBCI\metabci\brainstim\paradigm.py", line 8, in
from psychopy import data, visual, event
File "C:\Users\13645\AppData\Roaming\Python\Python38\site-packages\psychopy\visual_init_.py", line 28, in
from .button import ButtonStim
File "C:\Users\13645\AppData\Roaming\Python\Python38\site-packages\psychopy\visual\button.py", line 13, in
from psychopy.visual.shape import BaseShapeStim
File "C:\Users\13645\AppData\Roaming\Python\Python38\site-packages\psychopy\visual\shape.py", line 36, in
from psychopy.contrib import tesselate
File "C:\Users\13645\AppData\Roaming\Python\Python38\site-packages\psychopy\contrib\tesselate.py", line 52, in
from pyglet.gl import (
ImportError: cannot import name 'gluErrorString' from 'pyglet.gl' (C:\Users\13645\AppData\Roaming\Python\Python38\site-packages\pyglet\gl_init_.py)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.