How to connect OpenBci with Matlab (LSL or BrainFlow)

PsinghPsingh Canada
edited April 2020 in Ganglion

1.How to connect OpenBci with Matlab using LSL. I tried with Matlab 2019a and OpenBCI V4.2.0 but it was not connected
2.someone tells me how I want to record Time series data in milliseconds but is shown to me in seconds.
3. I am trying Neuromore for real-time reading with using OpenBci but it is not connected with Dongle and software OpenBCI_GUI?

Comments

  • wjcroftwjcroft Mount Shasta, CA
    edited September 2021

    re: (3), Neuromore can connect to the Cyton serial port dongle (usb serial port). But does not yet have support for BrainFlow library access. Once they do that, it will give them Ganglion access.

    Direct access to OpenBCI devices from Matlab, has just been developed by Andrey Parfenov @Andrey1994. So it will be possible to skip the LSL pathway.

    https://brainflow.readthedocs.io/en/stable/

    I don't think the current docs cover the Matlab API. But I think the code is available,

    https://github.com/OpenBCI/brainflow

    Regards, William

  • Docs generated from master branch has matlab code samples https://brainflow.readthedocs.io/en/master/Examples.html#matlab but I just realized that there is one issue on unix which should be fixed. On Windows should work right now

  • Fixed all issues on unix and created new release

  • Mars2499Mars2499 Colombia
    edited September 2021

    hello I have followed the steps to use brainflow in matlab and when executing the BrainFlowGetData example I get the following error: Error loading library intermediate output follows.
    The actual error is at the end of this output.

    Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.30), passed through in regex; marked by <-- HERE in m/struct([^;,{(]*){ <-- HERE (.*?)\}([^;])*;/ at C:\Program Files\Polyspace\R2019a\toolbox\matlab\general\private\prototypes.pl line 912.
    
    Failed to parse type '( __cdecl__ )) set_log_level ( int log_level' original input '( __cdecl__ )) set_log_level ( int log_level '
    Found on line 81 of input from line 36 of file C:\\Users\\USUARIO\\Desktop\\brainflow\\inc\\board_controller.h
    Error parsing argument for function __attribute__ function may be invalid.
    
    Failed to parse type '( __cdecl__ )) set_log_file ( char * log_file' original input '( __cdecl__ )) set_log_file ( char * log_file '
    Found on line 82 of input from line 37 of file C:\\Users\\USUARIO\\Desktop\\brainflow\\inc\\board_controller.h
    Error parsing argument for function __attribute__ function may be invalid.
    
    Type 'JNINativeInterfacePtr' was not found.  Defaulting to type voidPtr.
    
    Found on line 86 of input from line 41 of file C:\\Users\\USUARIO\\Desktop\\brainflow\\inc\\board_controller.h
    
    Failed to parse type '( __cdecl__ )) java_set_jnienv ( JNIEnv * java_jnienv' original input '( __cdecl__ )) java_set_jnienv ( JNIEnv * java_jnienv '
    Found on line 87 of input from line 42 of file C:\\Users\\USUARIO\\Desktop\\brainflow\\inc\\board_controller.h
    Error parsing argument for function __attribute__ function may be invalid.
    *********
    Error using loadlibrary
    Building BoardController_thunk_pcwin64 failed.  Compiler output is:
    C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\gcc -I"C:\Program
    Files\Polyspace\R2019a\extern\include" -fexceptions -fno-omit-frame-pointer -I"C:\Users\USUARIO\Desktop\brainflow"
    -I"C:\Users\USUARIO\Desktop\brainflow\inc" "BoardController_thunk_pcwin64.c" -o "BoardController_thunk_pcwin64.dll"
    -shared
    BoardController_thunk_pcwin64.c: In function 'int32':
    BoardController_thunk_pcwin64.c:54:41: error: expected declaration specifiers before ')' token
     EXPORT_EXTERN_C int32_T int32(__cdecl__))set_log_level(intlog_levelThunk(void fcn(),const char *callstack,int
     stacksize)
                                             ^
    BoardController_thunk_pcwin64.c:5:26: error: expected declaration specifiers before '__attribute__'
       #define DLL_EXPORT_SYM __declspec(dllexport)
                              ^
    BoardController_thunk_pcwin64.c:19:25: note: in expansion of macro 'DLL_EXPORT_SYM'
     #define EXPORT_EXTERN_C DLL_EXPORT_SYM
                             ^~~~~~~~~~~~~~
    BoardController_thunk_pcwin64.c:63:1: note: in expansion of macro 'EXPORT_EXTERN_C'
     EXPORT_EXTERN_C int32_T int32(__cdecl__))set_log_file(char*log_fileThunk(void fcn(),const char *callstack,int
     stacksize)
     ^~~~~~~~~~~~~~~
    BoardController_thunk_pcwin64.c:5:26: error: expected declaration specifiers before '__attribute__'
       #define DLL_EXPORT_SYM __declspec(dllexport)
                              ^
    BoardController_thunk_pcwin64.c:19:25: note: in expansion of macro 'DLL_EXPORT_SYM'
     #define EXPORT_EXTERN_C DLL_EXPORT_SYM
                             ^~~~~~~~~~~~~~
    BoardController_thunk_pcwin64.c:72:1: note: in expansion of macro 'EXPORT_EXTERN_C'
     EXPORT_EXTERN_C int32_T int32(__cdecl__))java_set_jnienv(JNIEnv*java_jnienvThunk(void fcn(),const char *callstack,int
     stacksize)
     ^~~~~~~~~~~~~~~
    BoardController_thunk_pcwin64.c:54:25: warning: type of '__cdecl__' defaults to 'int' [-Wimplicit-int]
     EXPORT_EXTERN_C int32_T int32(__cdecl__))set_log_level(intlog_levelThunk(void fcn(),const char *callstack,int
     stacksize)
                             ^~~~~
    BoardController_thunk_pcwin64.c:78:1: error: expected '{' at end of input
     }
     ^
    Error in BoardShim.load_lib (line 14)
                        loadlibrary('BoardController.dll', 'board_controller.h', 'addheader', 'board_info_getter');
    Error in BoardShim.set_log_file (line 49)
                lib_name = BoardShim.load_lib();
    Error in BrainFlowGetData (line 1)
    BoardShim.set_log_file('brainflow.log');
    

    I would appreciate if you could explain to me how to solve it, thanks

  • wjcroftwjcroft Mount Shasta, CA

    @Mars2499, hi.

    Andrey should see your post on this thread and may answer here. An alternative is to post your question(s) regarding Brainflow, on the Brainflow Slack. SIgn up via this page,

    https://brainflow.org/

    William

  • Hi, just checked using the latest release and I cannot reproduce it. Downloaded from https://github.com/brainflow-dev/brainflow/releases/download/4.6.1/matlab_package.tar and used Matlab 2019b

  • It can be that in your matlab version there is another regexp parser for C\C++ headers which doesn't like

        // platform types and methods
        typedef const struct JNINativeInterface *JNIEnv; // A handle to use Java's JNI
        SHARED_EXPORT int CALLING_CONVENTION java_set_jnienv (JNIEnv *java_jnienv);
    

    In board_controller.h file, you can try to remove these lines to see if it helps.

  • In release notes for matlab 2019b there is smth about C\C++ code calling under "External Language Interfaces" https://www.mathworks.com/help/matlab/release-notes.html#mw_658d1546-34d0-4382-9b9a-78114a200148 . Maybe you will need to update from 2019a

Sign In or Register to comment.