GithubHelp home page GithubHelp logo

brainflow-dev / brainflow Goto Github PK

View Code? Open in Web Editor NEW
1.2K 31.0 320.0 154.61 MB

BrainFlow is a library intended to obtain, parse and analyze EEG, EMG, ECG and other kinds of data from biosensors

Home Page: https://brainflow.org/

License: MIT License

CMake 3.03% C++ 46.34% C 13.44% Python 10.06% R 0.27% Java 5.69% C# 9.18% Dockerfile 0.11% MATLAB 2.41% Julia 2.00% Objective-C++ 0.14% Rust 3.83% TypeScript 3.49% JavaScript 0.01%
eeg eeg-analysis brain-computer-interface brain-machine-interface brain-control bci signal-processing biosensors biosignals biosensor

brainflow's People

Contributors

alexcastillo avatar andrey1994 avatar daniellasry avatar dependabot[bot] avatar dvaposto avatar evaesteban avatar fan1117 avatar fullflyt avatar furmanlukasz avatar isaacplotkin avatar john42506176linux avatar khoinguyen-hub avatar matthijscox avatar mesca avatar myd7349 avatar philippitts avatar purplesyringa avatar ramessesii2 avatar retiutut avatar salman2135 avatar sarthak031 avatar serense avatar shirleyzhang867 avatar signed-log avatar stellarpower avatar tedahmadi avatar trobanga avatar wameuh avatar xgdgsc avatar xloem 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

brainflow's Issues

Get rid of OpenMP and use C++ threads

I just realized that on linux openmp linked dynamically, it means that this library should be installed on user's PC... It's not good for portability. Need to link statically or dont link at all.

For MSVC we dont have such issue because openmp is a part of MSVC runtime which we link statically.

On MacOS OpenMP is not preinstalled in CI, so provided libraries dont have such dependency.

.jar files

Hi,
I just have a quick question about the difference between the two Java .jar files available. What is the difference between the one with and the one without dependencies?
Thanks

Kernel assembly for MATLAB

Good day.
I'm trying to build a kernel for MATLAB. The instructions for windows say: "Build it as a cmake project manually or use batch files from tools directory". Tell me, please, what should I collect: a release or the entire downloaded repository (containing the CMakeLists.txt file). It’s just that I just need to start the MATLAB scripts now. Also visual studio 2019: which commands for building a project should I run manually?

Best regards

Add C# support for Linux and MacOS using Mono

I think we need to add instructions how to compile it and fix DllImport statements to load correct library.
IMO its not required to provide precompiled libraries for it but we can consider this option too

MATLAB get data from CYTON&DAISY

Good afternoon!
An example was launched with getting raw data from a SYNTHETIC_BOARD. In accordance with the documentation indicated Board Id: CYTON_DAISY_BOARD and BrainFlowInputParams.serial_port: COM3. Got an error (screen below). Tell me, please, how to fix it (perhaps somewhere there are examples not with a SYNTHETIC_BOARD)?

BC3

Best regards,
Dmitriy

Not able to run band power example code.

When I run the code using synthetic board I get the following error :
Traceback (most recent call last):
File "band_power.py", line 7, in
from brainflow.data_filter import DataFilter, FilterTypes, AggOperations, WindowFunctions
ImportError: cannot import name 'WindowFunctions' from 'brainflow.data_filter' (C:\ProgramData\Anaconda3\lib\site-packages\brainflow\data_filter.py)

Cyton Daisy WiFi only streams 8 channels

When streaming from the OpenBCI Cyton Daisy WiFi setup, I only get 8 channels of data (1-8). Channels 9-16 are all 0s. There was a similar issue in the OpenBCI GUI I reported (OpenBCI/OpenBCI_GUI#837). Here is the code I used to collect data:

import pandas as pd
from brainflow.board_shim import BoardShim, BrainFlowInputParams

params = BrainFlowInputParams()
# default IP when connecting to board directly
params.ip_address = '192.168.4.1'
params.ip_port = 6227  # random port that was available
board = BoardShim(6, params)

board.prepare_session()
board.start_stream()

# other code is in here for collecting data
time.sleep(3)
data = board.get_board_data() # get all data and remove it from internal buffer
board.stop_stream()
board.release_session()

df = pd.DataFrame(data.T)
df.drop([0] + list(range(20, 30)), inplace=True, axis=1)
df.to_csv('test_data.csv', index=False)

If you examine the channels 1-8, they are fine, but channels 9-16 are all 0s.

I was using version 3.4.1 on Ubuntu. I don't have the headset for a week or two so can't test the latest versions that were released, but it didn't look like anything was committed to the code that would fix this problem.

Connection problem with the openbci dongle

Hi, i just took an openbci helmet and i'm trying to use brainflow to connect with the dongle.
The problem is that when i try to connect i get the error: unable_to_open_port_error .
I'm on macOs 10.13.6 and I've already tried several things.
I tried to fix ftdi, the dongle is visible using the "ls -l / dev / tty *" command and also the openbci GUI connects without problems.

I think I miss something about the API but I can't understand what.
Any help is welcome

integrating brainflow in Ue4

Hi, first of all i wanted to thanks for your work, for sharing and maintain all this amazing project, its been really helpful!, i´m trying to set up unreal engine 4.25 to work with brainflow, i'm decided to make a custom build including brainflow library via Nuget package, (since I'm quite noob , i don't know if this is the best way to approach this or maybe build them as a plugin modules?), so i build the editor, but i went i wanted to call some function, it cant find the module, i'm aware you already work with ue4 too, so i wanted to know a recommendation to go thru this, any light would be very helpful, im trying to use this using the emulator for testing a bci-cython board since right now i dont own one, (in there a way to integrate emulator in to unreal for testing?) thanks appreciated any help!

Neurofeedback calculations: Phase, Coherence, Synchrony, etc.

Will there be methods useful in Neurofeedback designs, such as Phase, Coherence, Synchrony, etc.? These terms don't always have the same algorithm across different platforms so it might be a challenge to determine what algorithm(s) to include in BrainFlow.

Build java libraries for jdk 8 and 11

In java9 modules were added, as of right now brainflow uses java 8 and has no modules. It makes it hard to use it in java 11 apps . At the same time we need to keep java 8 version for existing apps which do not support newer java versions.

We can add modules-info.java file for java > 8 and build 2 versions of java package in CI

Data not appearing at sampling rate

Hi,
I am using a cyton + daisy serial setup and a custom java program. I am running into an issue where data only appears in the ring buffer in large chunks every half a second. Is there a way to get data to appear at the board's sampling rate of 125 Hz or every 8 milliseconds?
Thanks

What is the first column of data?

I'm using a cyton+daisy+wifi board, and I have 31 rows of data when I collect data. The first column is 1.0 through 255.0, repeating. What is this supposed to be? It's not in any of the board info column numbers.

Add marker channel to all boards and design the API to get data between markers

Currently to get data between two events you need to add timestamps to these events and find data between these 2 timestamps. We can simplify this process:

We can add Marker channel to all boards and in user code during the streaming you will be able to write smth like:

board.add_marker(1)
# do smth
board.add_marker(1)

This method will set value for marker channel in next package.

Later in user API it will be possible to query epochs between two marker values.

Smth like

data = board.get_board_data()
marker_channel = BoardShim.get_marker_channel(board_id)
marker_value = 1
epochs = BoardShim.get_epochs(data, marker_channel, marker_value)

Travis CI MacOS builds are not free for open source projects anymore

Travis changed their subscription plans and now they gonna charge for MacOS builds. For now we have smth like free tier with limited amount of runs. It will expire soon and we will not be able to use it wo payments.

Need to move to github actions as soon as possible. Its a showstopper.

More info about this change https://blog.travis-ci.com/2020-11-02-travis-ci-new-billing

Email from travis support:

"Please note that we have now changed our subscription plans from Trials to Free Plan. This means your account has migrated to the new "Free Plan" usage on travis-ci.com. In addition, I confirm that this is only for the Free Plan, so no payment has been charged to your account.
If you received an email earlier stating you had 1000 credits, please disregard as you actually have 10,000 allotted."

Please help me,Solve this bug , Openbci : Cyton with WiFi Shield

(tensorflow-gpu) D:\PycharmProjects\openbci\python_tests>python brainflow_get_data.py --ip-address 192.168.4.1 --board-id 5
Traceback (most recent call last):
File "brainflow_get_data.py", line 54, in
main ()
File "brainflow_get_data.py", line 39, in main
board.prepare_session ()
File "C:\Users\Administrator.conda\envs\tensorflow-gpu\lib\site-packages\brainflow\board_shim.py", line 722,
in prepare_session
raise BrainFlowError ('unable to prepare streaming session', res)
brainflow.board_shim.BrainFlowError: INVALID_ARGUMENTS_ERROR:13 unable to prepare streaming session

Difficulty installing the MATLAB

Good afternoon.
The instructions say "Add folders lib and inc to Matlab path". Only these directories are missing in brainflow / matlab-package / brainflow. And without their indication, an error occurs. Tell me, please, where are folders lib and inc located?

Currently SmoothFilters from DSPFilters are used, add an option to use them without smoothing

Existing filters should be renamed and plain filters wo smoothing should be added.
Instead adding new methods I think in terms of API it should look like new entries in Filter Enum

DSPFilters docs https://github.com/vinniefalco/DSPFilters/blob/master/shared/DSPFilters/source/Documentation.cpp

Example:

// now
f = new Dsp::SmoothedFilterDesign<Dsp::Butterworth::Design::BandPass<MAX_FILTER_ORDER>,
                1, Dsp::DirectFormII> (1024);
// new
f = new Dsp::FilterDesign<Dsp::Butterworth::Design::BandPass<MAX_FILTER_ORDER>, 1> ();

Also need to check the difference between old and new filters(check fft plots visually, check how it affects concentration\relaxation calculation, etc)

Start straming and then Segmentation fault error

Dear Andrey,
I just found BrainFlow on GitHub and I think it is fantastic.
I run into problems: it crashes when it starts streaming.

I am a python user, Ubuntu 18.04, Python 3.8, Ganglion board with USB dongle BLED112.
brainflow==2.1.0
I am running the script from the code samples:
https://brainflow.readthedocs.io/en/stable/Examples.html#python-get-data-from-a-board

python main.py --board-id 1 --serial-port /dev/ttyACM0 --mac-address e0:06:15:36:28:44 --log
[2019-12-22 19:29:33.146] [brainflow_logger] [info] incomming json: {
"ip_address": "",
"ip_port": 0,
"ip_protocol": 0,
"mac_address": "e0:06:15:36:28:44",
"other_info": "",
"serial_port": "/dev/ttyACM0"
}
[2019-12-22 19:29:33.146] [brainflow_logger] [debug] ganglionlib initialized
[2019-12-22 19:29:33.146] [brainflow_logger] [info] search for e0:06:15:36:28:44
[2019-12-22 19:29:35.117] [brainflow_logger] [debug] use stub streamer
[2019-12-22 19:29:35.340] [brainflow_logger] [debug] start streaming
Segmentation fault (core dumped)

From: https://stackoverflow.com/questions/13654449/error-segmentation-fault-core-dumped

"Segmentation fault (core dumped)" is the string that Linux prints when a program exits with a SIGSEGV signal and you have core creation enabled. This means some program has crashed.
As you are getting this error from running Python, this means the Python interpreter has crashed. There are only a few reasons this can happen:

  • You're using a third-party extension module written in C, and that extension module has crashed.
  • You're (directly or indirectly) using the built-in module ctypes, and calling external code that crashes.
  • There's something wrong with your Python installation.
  • You've discovered a bug in Python that you should report.

I suppose we are in the first case.
Thanks in advice for your effort and time.

I wish you lovely holidays and a happy new year.
Kind Regards
Matteo Mazzanti

Buffer becomes empty after a while, and stays empty

Hi there!
I'm having a great experience trying out brainflow with OpenBCI boards. Great framework!
So far, There's only one issue that I have come across. After trying out brainflow on a windows PC, I moved to using a raspberry pi 3. I did compile everything from the source & double checked everything I did with the brainflow documentation. my program is meant to work on a real-time system, so basically the streaming continues forever unless the user wants to stop it. if I use the 'get_board_data' routine, everything goes well for about a few seconds up to a minute, and then then I only see empty data, and the 'data_count' is indeed zero. if the 'get_current_board_data' routine is used, after a while the same data is emitted over and over (probably due to no new data entering the buffer).
I have tested this with OpnBCI cyton & ganglion with the wifishield.
This seems to be the case with both the python version and the C++ version of brainflow.

Unable to build core.

Hello! I tried several options for building the kernel ...

  1. Using Visual Studio 2019: changed the build_win64.cmd ("cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX=..\installed64 .. ") and launched it. Then I tried to open CmakeLists.txt from Visual Studio and compile a project on it.
  2. Installed the Visual Studio 2017: launched an unchanged build_win64.cmd (from tools). Then I tried to open CmakeLists.txt from Visual Studio and compile a project on it.
    Of course, cmake is installed, in all cases it started GUI first to check the equipment. I tried to build a kernel with both connected and disconnected boards(Cyton&Daisy). Screenshots below. Tell me, please, in how to assemble the core after all?

BF_1
BF_2
BF_3

Error: unable to stop streaming session.

Dear Andrey,
I am having a problem:
brainflow.board_shim.BrainFlowError: GENERAL_ERROR:17 unable to stop streaming session.
Using the python script provided at:
https://brainflow.readthedocs.io/en/stable/Examples.html
Ubuntu v18.04
Python v3.8
Brainflow v2.1.3
OpenBCI Ganglion board

I am using:
board.start_stream ()
instead of:
board.start_stream (45000, args.streamer_params)

$ python main.py --board-id 1 --serial-port /dev/ttyACM0 --mac-address d2:e4:be:82:36:be --log
[2020-02-08 17:01:46.795] [brainflow_logger] [info] incomming json: {
"ip_address": "",
"ip_port": 0,
"ip_protocol": 0,
"mac_address": "d2:e4:be:82:36:be",
"other_info": "",
"serial_port": "/dev/ttyACM0"
}
[2020-02-08 17:01:46.795] [brainflow_logger] [debug] ganglionlib initialized
[2020-02-08 17:01:46.795] [brainflow_logger] [info] search for d2:e4:be:82:36:be
[2020-02-08 17:01:48.865] [brainflow_logger] [debug] use stub streamer
[2020-02-08 17:01:49.087] [brainflow_logger] [debug] start streaming
[2020-02-08 17:01:50.497] [brainflow_logger] [error] failed to stop streaming 13
Traceback (most recent call last):
File "main.py", line 56, in <module>
main ()
File "main.py", line 49, in main
board.stop_stream ()
File "/home/mrx/anaconda3/envs/OBCI_Brainflow_213/lib/python3.8/site-packages/brainflow/board_shim.py", line 741, in stop_stream
raise BrainFlowError ('unable to stop streaming session', res)
brainflow.board_shim.BrainFlowError: GENERAL_ERROR:17 unable to stop streaming session

Thanks in advice for your help.
/Matteo M.

Feature Request: Making ML models CUDA compatible

Hi there,

Great project. Was looking to do some stuff with Brainflow and Machine Learning. Specifically, I'd like to accelerate the inferencing of the ML models with CUDA on an NVIDIA Jetson.

Willing to work with you guys on this. Assuming the models are pre-trained and exist in a common format, it should be straight-forward.

Any thoughts or information on the models as they stand?

Thanks for being awesome!

Parallel signal processing algorithms

Currently signal processing algorithms work per channel and in user code need to write smth like

eeg_channels = BoardShim.get_eeg_channels (board_id)
for channel in eeg_channels:
    DataFilter.perform_bandpass (data[channel], BoardShim.get_sampling_rate (board_id), 15.0, 6.0, 4, FilterTypes.BESSEL.value, 0)

Its fine but in some languages its hard to parallel such computations(scripting languages with GIL), even in languages with real multithreading support it requires efforts to parallel it.

We can redesign the API to work like

eeg_channels = BoardShim.get_eeg_channels (board_id)
DataFilter.perform_bandpass (data, eeg_channels, BoardShim.get_sampling_rate (board_id), 15.0, 6.0, 4, FilterTypes.BESSEL.value, 0)

And parallel calculations like we do for get_avg_band_powers
Performance drawback - will need to convert 2d array to 1d array each time to pass it to low-level API. But it still should be much faster than single threaded code specially for large arrays.

Questions:

  • Should we implement it?
  • If yes, should it be instead current API(it will be a breaking change in this case) or in addition to existing API(new method or method overloading?)

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.