questions on Cyton sampling frequency, GUI, signal processing

edited January 2018 in Cyton
Hi everyone!

I recently had the department of biomedical engineering at my school purchase a cyton 8-channel board for my group's senior design project. I have a few questions - if they've been answered somewhere else already, it'd be great if someone could point me in the right direction.

1. What is the sampling frequency? 250 Hz?
2. Reference electrode is the bias pin and ground electrode is the srb2 pin on the board, correct?
3. Is there any signal processing that the OpenBCI application does? Are there any filters on by default in the program? Or are we visualizing the raw signal?

Those are my questions for now. Thanks in advance!
«1

Comments

  • wjcroftwjcroft Mount Shasta, CA
    1. yes, but can be higher if using the wifi shield.
    2. it's the other way, Bias is ground, SRB2 is the common reference.
    3. the GUI does do some signal processing for the screen display, but records the raw signal to the output file.
  • Thanks wjcroft!

    Do you happen to know what processing the application does? For example, are there high pass, low pass, or band pass filters and what are their cutoff/center frequencies?
  • wjcroftwjcroft Mount Shasta, CA
    Filtering is controlled by settings in the GUI. Again, this is just for display. The raw signal is recorded. One of the filters is a high pass to eliminate the slowly drifting DC offset. An optional notch can be set at the mains freq.
  • Thank you! A few more questions:

    1. Is there a document on the OpenBCI application detailing exactly what it's functions are and the details of the signal processing?
    2. How much of a delay is there in data transmission from the board to the program? And does this delay vary if we were to use another program like MATLAB?
    3. Is there a way to turn off certain channels from the OpenBCI app? I know I could just remove the electrode from the cap or just disconnect from the board, but I figured there might be a way to do this in the program.
  • wjcroftwjcroft Mount Shasta, CA
    1. yes


    You'll have to look at the source in Github if you want further details on the signal processing. As I mentioned (twice) the output file is raw, with no processing. You also have other ways to route the output stream, for example LabStreamingLayer or Python, Matlab.

    2. this will vary. The serial port stream is real time with packets arriving every 4 milliseconds (250 hz). Output to the file is buffered, so I assume you are not referring to this. LSL will add other delay factors. I believe there is a Matlab library that can receive directly from the serial port.

    3. yes, GUI can do this, also the control characters transmitted to the serial port.

  • Thanks again! Is there a way to check which firmware is installed on our board? 
  • wjcroftwjcroft Mount Shasta, CA
    It is shown on the SDK link previously given. You connect a terminal emulator to the COM port, then power up the Cyton. It will identify.
  • You've been really helpful, I really appreciate it! 

    So far, to test that our system is working, we've connected the channel, reference, and ground electrodes together and saw that the output was zero. We're trying to get a P300 test going and we've found the external trigger document from OpenBCI. I'm looking at the following link: http://docs.openbci.com/Tutorials/06-External_Trigger_Cyton_Example#external-trigger-on-openbci-32bit-board-external-triggering-the-easy-way-firmware-3xx

    Should we be following the instructions for the Firmware 1.x.x? And then work our way up to 3.x.x?

    In the meantime, I've also been trying to stream data into MATLAB, but with bcilab running on 2017a, I can't seem to get the GUI to be visible though it shows up in the tool bar. Do you know what I could do to solve this issue?
  • Please disregard my last question. I found the solution through by following the last post at this link: https://github.com/sccn/BCILAB/issues/29
  • wjcroftwjcroft Mount Shasta, CA
    If you don't have 3.x.x firmware, then please upgrade. That is the easiest way to get the external trigger.

    Check all the related Matlab posts on the site,

  • Thanks! Do you know how long the battery lasts and how long it takes for the battery to charge? 

    Also, for some reason, I'm not getting any data to show on the GUI anymore. I fully charged the battery and have the dongle connected. The computer is able to find the device, the channels just all show zero. Any suggestions on how to fix this? It seems to be happening on one of my group mate's computers as well.
  • So I've tried resetting the board and dongle, but neither seems to be working. I can't visualize any data through the GUI, though it still connects to both the board and dongle. 
  • Just an update - I got it to work again, although I have no idea whether or not what I did had any actual affect. Started a discussion on github for this as well. 

    I still am not clear on the instructions for the external trigger. Do I absolutely need an optoisolater for this to work? The instructions aren't very clear.
  • wjcroftwjcroft Mount Shasta, CA
    What is the source of your external trigger? If it is connected to other mains powered equipment, then the optoisolation is recommended for safety purposes. If you have some kind of battery powered trigger without mains connection, then you might avoid this. You still need to be careful what voltages you apply to the chipKIT (PIC) analog or digital input pins.

  • The source is another computer applying a voltage of around 0.3 V - this is from a P300 paradigm test. The computer is laptop and the output comes from a parallel port. We may have to plug in the AC adapter to the laptop - will this be an issue? We plan to attach wires into the pin holes on the port and use the digital input and ground on the cyton, but from my understanding, I have to build the circuit shown at the end of that document.

    Also, I'm still trying to setup LSL with OpenBCI using Matlab. I've tried following the OpenBCI LSL python tutorial from github: https://github.com/OpenBCI/OpenBCI_LSL. However, Spyder hangs after I enter this into the command window: 
    !python openbci_lsl.py COM13 --stream

    I can't seem to get past this point. I've tried looking at how to stream data into BCILAB as well, but have been unsuccessful so far. I've also tried following the LSL wiki and have turned off my firewall. I downloaded the lsl library for Matlab too, but I don't know what to do with it. Any other suggestions? 
  • wjcroftwjcroft Mount Shasta, CA
    If you use an AC adapter with the laptop, then you have a potential connection pathway from the mains current (during malfunction) to your brain. That's why the opto isolation is recommended.
  • Right, I figured that could happen after I posted. So in regards to LSL, what are my options? Is there an OpenBCI LSL Matlab tutorial I can take a look at?
  • I found the OpenBCI Matlab repository on Github but I see that it's deprecated and it directs me to follow the OpenBCI LSL procedure using python. I'm still stuck on python hanging at
    !python openbci_lsl.py COM13 --stream

    After I get this to work, I want to stream data into Matlab. You also mentioned being able to stream data directly from the serial port into Matlab. Could you offer some suggestions on this? Does this require LSL also? 

    I'm assuming the OpenBCI standalone app has the best data transmission capability. I understand that the sampling rate is 250Hz, so can I achieve that speed of data transmission with the method I'm using currently (stream via pyhton, then matlab) or is there a better way to go about this. I ask because I'm not experienced with this, but am willing to step out of my comfort zone to get this to work.
  • wjcroftwjcroft Mount Shasta, CA
    re: direct serial port Matlab example

    This is old, but he did say it works. You can also Message atom2626 by clicking on his username.


    re: GUI output to LSL

    I havent used this myself, but I thought it was available as a GUI widget.


    Run the GUI (then LSL widget) from the Processing IDE as suggested.

    A new Python is in alpha testing,


  • Thanks for referring me to atom2626's post. I contacted him via a direct message. His links aren't working however. I want to try creating the script and functions in Matlab based on his code, but do I still have to setup the LSL in python first?

    In regards to the GUI output to LSL, after I setup the widget in the GUI, all I have to do in Matlab is run the vis_stream function, correct?

    For the new python, is that an updated LSL library for OpenBCI and python?
  • wjcroftwjcroft Mount Shasta, CA
    re: atom2626

    This is Frederic Simard,


    re: his script, no his script reads directly from the serial port, no Python or LSL.

    re: widget, the Matlab receiving should follow LSL guidelines,


    re: new python. it's a new alpha release, I don't know if the LSL code has been updated. I think it was primarily an update to include support for wifi shield.

  • I've found his email via Github. I hope he responds! I've been trying to combine the code from his script, replacing the parts that he updated later on in his posts. I've gotten various errors for undefined variables, which I assume I'm getting because he didn't paste the entirety of the script. I commented those lines out as they didn't seem to directly impact what the function was doing overall, they were only to check the status of the packets.

    I've commented on what the files are in this Github repository that I've made: https://github.com/faheemersh/Senior_Design_EEG_fNIRS_BCI/commit/ff611fa4b51b420ad289245d6f36069545e2873e

    Here are the steps I've taken to try this.

    1. I'm running OpenBCI Hub only. I had the GUI running too but after getting the matlab error that the port was in use by another program, I closed it. Plugged in dongle and turned on cyton 32 bit board.
    2. Pretty much copied everything exactly from the large post of code he had, and inserted the constants at the end of that post into the beginnings of both atom2626.m and unpack_openbci_eeg.m
    3. Comment out lines that were throwing errors, such as lines 21 and 54 in atom2626.m and line 6 of unpack_openbci_eeg.m. I also put the constants after line 6 in that file too (like I said in the last step, at the beginning).
    4. I run the script atom2626.m in Matlab. Kept the defaults atom2626 had, so 1000 samples and 8 channels.
    5. See the output in the eeg_data variable, which I think is the correct data output variable. 

    Only weird thing is, the numbers seem a bit off. I would think these are all still in microvolts but I'm not sure. Could you verify by looking at the data output I've saved as an excel file on the Github called atom2626_eegdata_output? I've also uploaded one of the text files from the recordings I've done with the GUI for comparison.

    Also - another issue. Every time I run this in Matlab, I can't run it again to get more data as it says COM13 is closed. I have to close and open Matlab to run it again. Any ideas on how to get around this?

    And one last question - I may have just missed this, but what is the sampling frequency with this method?
  • wjcroftwjcroft Mount Shasta, CA
    As I said before, his code opens the serial port directly

    ("s_bci = serial(OPENBCI_PORT,'BaudRate',OPENBCI_BAUDRATE);").

    So you DO NOT want the GUI or Hub running at the same time. They are also trying to open the port.

    The default sample rate is always 250 hz.

    Hopefully Fred will answer your email.

    ----

    And... Please also investigate using the GUI widget LSL streaming approach. As a separate attempt. No connection to Fred's code.


  • I think his running his script one time seems to occupy the port. I can't run it again, even with both the OpenBCI GUI and Hub closed. I have to restart Matlab to run the script everytime. Is there a way to somehow not occupy the port after running the script one time?

    And yes, I will be looking at how to get the Networking widget on the GUI. From some of the instructions, it seems that the widget should be pre-installed and when I go to see the program files folder of the GUI, the .pde file of the widget is there. Should the widget come with the GUI? 

    If not, that is okay, I will try to figure out how to use Processing to get the widget running on the IDE version of the GUI.
  • Also, it took 40 seconds to get 2000 samples from each channel, or 16000 samples overall. I've uploaded the time it took to run the script to the repository as well: https://github.com/faheemersh/Senior_Design_EEG_fNIRS_BCI/tree/Streaming-to-Matlab-directly-from-Serial-Port/atom2626data_and_openbci_data/atom2626data

    The sampling frequency seems to be 400 Hz, no?
  • I've gotten the networking widget on my GUI. However, I'm not sure what the parameters should be in terms of IP, port, and address. Do you know what these should be or can you refer me to the right place? I think this is the reason why I'm having the problems below. I've also taken at the links you've provided me but still don't know what to enter in those fields on the widget. 

    Also, I'm not sure how to use the examples of the Matlab LSL files off of github. What does this mean: 
    To run these examples, you must have added the folder include/lsl_matlab to your MATLAB path (recursively).
    You can do this either via the File/Path... menu or via the command addpath(genpath('your_path_to/liblsl-1.xx/include/lsl_matlab'))
    Also, if you have rebuilt the library, make sure that liblsl-1.xx/include/lsl_matlab/bin contains a copy of the library files in the liblsl-1.xx/bin.

    From my understanding, I have to use the networking widget to create the LSL stream and I have to just add the path to Matlab (change my directory to that path) and run the example file ReceiveData.m. How is file being run going to pick up the LSL stream?

    I know to try a few other ways to get the LSL stream in Matlab.
    1. Setup the stream with networking widget. Run the Matlab viewer from the latest LSL repository (have downloaded it already). I'm getting the error that there is not stream found on the network, Again, probably because I need to enter the correct IP, port, and address.
    2. Using BCILAB, I can go to the online analysis tab-->read input from-->lab streaming layer. This is the way I want to be able to use LSL. 
  • Also, I forgot to add on. Atom2626's script seems to work correctly only if the I have the Hub running and run the script once in Matlab. Still having the issue with having to close and open Matlab to run the script. No response from Frederic either...
  • After a few days of trying, I was able to get LSL working through python and then stream data into MATLAB using the lsl examples (the link you sent me that I wasn't sure how to use), using MATLAB viewer, and BCILAB. I created a document of the exact steps I took to get each method working.

    Please take a look. I wanted to contribute something useful and I think this will be helpful to others: https://docs.google.com/document/d/1rdp4mJKKu5mBQRHH0cVUDW4-uLGTncGEp0tp2nXT6yE/edit?usp=sharing
    Please make sure to turn on the outline when viewing the document, if you can't see it already. Go to View-->Document Outline.

    I have opened the document to comment, so please feel free to do so, if you think it will be helpful. I started out as a novice with this and was able to get it to work finally. Still having some issues that you might be able to address, and I've also mentioned these in the document.

    1. The error in Matlab: Undefined function or variable 'lsl_loadlib. I did a search and found a forum post here, but it was never solved. To avoid this error, I've had to run BCILAB first, and then I can run vis_stream or ReceiveData. Can't get around the error otherwise.
    2. Streaming from the serial port (using atom2626's code) works inconsistently. I must have the OpenBCI Hub running for it to work at all. I cannot interpret what the numbers mean, as they seem to have different units in comparison to streaming using other methods. Also, I have to quit Matlab if I want to run this script more than once.
    3. I could not figure out which IP, port, and address I should be using for the Networking widget. Still am unsuccessful with this one. Would be great to have the visualization in the GUI while data streams to Matlab at the same time.


  • I have been able to get around all of the issues apart from the streaming directly from the serial port with some help from the LSL repo contributors/collaborators. Unfortunately, Frederic never replied. It also seems that I have exhausted wjcroft with my questions - I apologize for my naïveté. I sincerely appreciate the help you've provided. The link I posted in my previous post shows the exact steps I've taken to solve the issues I had in the above post. I am also organizing my Github so these setup processes are simplified and anyone can get their system setup quickly.

    It's time to focus on the next part of the project, which is feature extraction, classification/regression, and then integrating fNIRS.
Sign In or Register to comment.