Neurofeedback, OpenBCI Boards, and general getting started Questions & Thoughts

2»

Comments

  • wjcroftwjcroft Mount Shasta, CA
    Hi Hiroki,

    re: millivolt level samples


    re: notch filter

    You need to use a Python DSP Digital Signal Processing package to apply various filters to the data stream. For example you could do a bandpass filter from say .5 to 45 hz, that would solve your DC offset and mains noise at the same time.


    There is no notch built into the Cyton board, that is being done in the GUI. The 'f' command is unused according to the SDK,


    The tutorials that mention receiving an external trigger, find it in one of the Aux channels.

    Regards,

    William

  • Hi William,

    I applied a bandpass filter by myself, thank you.
    I have another problem.

    I used the sample code written at the top of cyton.py.
    Since the sampling rate is 250Hz, I expect the function 'handle_sample' is called every 4 ms.
    When I create the timestamp for every call, the intervals are about 0.3 - 0.4 ms and sometimes and periodically around 400ms.

    Is the handle_sample function really called for every 4 ms?
    Any suggestions?
  • edited August 2018
    Hi William,

    Thank you for indicating the description of FTDI driver fix for macos.
    I'm using MacBook running version 10.13.

    I fix the driver according to the documentation, but nothing changed.
    When I use the OpenBCI_GUI, the sampled EEG waveforms seems to be correctly captured.

    The program I created is:

    import openbci
    from datetime import datetime

    def handle_sample( sample ):
        t = datetime.now()
        print( '%s %d %f' % ( t, sample.id, sample.channel_data[ 0 ] ) )

    board = openbci.OpenBCICyton()
    board.print_register_settings()
    board.start_streaming( handle_sample, lapse = 10 )

    This program prints the timestamp and the EEG raw data of the first electrode for each sample as follows:

    2018-08-23 21:43:18.142490 113 -3684.886239

    2018-08-23 21:43:18.142929 114 -5777.881238

    2018-08-23 21:43:18.143378 115 -6608.516766

    2018-08-23 21:43:18.143746 116 -6344.296794

    2018-08-23 21:43:18.557327 117 -4401.527870 <- here

    2018-08-23 21:43:18.558110 118 -3686.070882

    2018-08-23 21:43:18.558728 119 -5775.310788

    2018-08-23 21:43:18.559363 120 -6606.818033

    2018-08-23 21:43:18.560120 121 -6343.693297


    The differences of each timestamp are about 0.3 - 0.4 ms, and sometimes ( for every 120 sample? ) jump for about 400ms as shown above.

    My program is almost as same as the sample code in cyton.py, may not be wrong.

    The captured EEG waveforms contain a large 50Hz noise, and it shows that this program captures EEG waveforms correctly as expected.

    So adding the config parameter InBufferSize=64 does not fix in my environment.


    I assume that the Cyton board captures the EEG correctly for every 4ms, but the data is buffered somewhere and my Mac read it intermittently.


    I use the OpenBCI for the real-time neurofeedback, and I should calculate ERP in real-time.

    I cannot allow this choppiness.

    The latest version of FTDI driver is 2.4.2, so will it fix this if I reinstall it and change the Info.plist file as described?

  • wjcroftwjcroft Mount Shasta, CA
    Try some searches using the Advanced Search box in right column, this turned up,



    What you are seeing is the macOS problem, you have to fix it with the edits shown. Cyton is sending the packets at the correct 4 ms rate, they are getting buffered inside macOS.
  • Hi William,

    I unloaded and loaded the kernel extension, then it was fixed.
    The latency was dramatically improved.
    But, the latency fluctuates between 1ms and 7ms ( and sometimes 50ms ) and is not stable.
    7ms latency is not good for my purpose, but I proceed with the current condition.

    thank you very much.
  • wjcroftwjcroft Mount Shasta, CA
    The sample rate at the Cyton is relatively constant. It is very close to 4ms, 250hz. However, the timing with which you receive the packets at the application varies, depending on operating system latencies. You can always assume each sample (one sample per bluetooth packet), was recorded at the 250hz rate. For all the neurofeedback applications I am aware of, such OS latencies are common and not an issue.
  • Hi William,

    Can I confirm the way to capture the EEG data from python?
    As I mentioned before, I am using the code at the top of cyton.py.
    When I saw the raw data of the first electrode, it contains the 50Hz noise, so I thought my program works as expected.
    I compared the waveforms captured by my program and OpenBCI_GUI:
    image

    When I apply FFT to the data captured using OpenBCI_GUI, the result is as expected:
    image

    But I got an unexpected result when I applied FFT to the data captured using my program:
    image
    The power spectrum density has a small peak at 50Hz, but anyway the shape of the PSD is curious.

    I put the data captured here, I'm happy if you find something wrong.
  • wjcroftwjcroft Mount Shasta, CA
    edited August 2018
    Your first graph shows two different DC offsets for GUI and your own capture. If you apply say a .5 Hz high pass filter, or .5 to 45 bandpass, that DC offset would go away.

    Your 3rd graph PSD is also showing a large low frequency "almost DC" component. Filter this out as suggested.

  • Hi,

    Yes, I'll apply a bandpass filter.
    I understood that the raw data contains a DC offset of ADS1299 as you mentioned.

    What I want to say is, the PSD of raw data from OpenBCI_GUI is as expected, even if it contains a large DC offset, while the PSD of raw data from my program is strange.
    The PSDs should be similar even if I don't filter the DC offset.
    So I thought I couldn't capture the raw EEG correctly.

    But my program is as same as the top of cyton.py, and the captured waveforms are very similar.
    I cannot find out what is wrong...
  • I also checked the packet_id(sample ID).
    It was incremented one by one and there was no warning message, so I think there was no packet(sample) loss.
  • wjcroftwjcroft Mount Shasta, CA
    Comparing the two raw data files, I see the OpenBCI raw data has widely varying DC offsets, whereas your DC offsets are all in the 50 millivolts range. Not sure if this might account for the differences. Best to pre-filter and remove DC offset before any further signal processing.
  • Hi William,

    The cause was very simple.
    The first sample is always 0 and the subsequent samples have large numbers, as a result, PSD was strange.
    When I omitted the first 0, the result was as expected.

    Thank you.
Sign In or Register to comment.