LSL streaming with MATLAB yeild negative time gaps

I'm using Cyton board to do surface EMG study. I stream my data via LSL to MATLAB with the sample code provided here. The streaming works well for the channels, but the recorded time gave me negative time gaps. Please find the image below showing what I mean. I tried to put the board and the dongle as close as possible, and changed new batteries, but the problem persist. Is there an explaination or solution to this issue? Thanks! @retiutut


  • wjcroftwjcroft Mount Shasta, CA

    Hi Huayran,

    I'm not sure the term "negative time gaps" is the most understandable. Is not what you are seeing, just the loss of some samples, then the sample time stays the same until the next valid sample arrives?

    This lossage could be occurring anywhere in the data stream path: your Matlab code, the app sending samples, the Cyton radio link, etc.

    Are you using the GUI and the Networking widget, or are you using the Brainflow Matlab binding?

    Do you see any packet lossage when the GUI is recording from the Cyton directly (no Matlab involved)? If not, then that means this is not a hardware / radio link issue. But instead some lossage is happening via LSL or Matlab. Suggest you stream directly using Brainflow+Matlab calls and avoid using LSL and GUI entirely.


  • wjcroftwjcroft Mount Shasta, CA

    Actually looking at your expanded sample graph on the right, it does appear that the line returns to baseline. After sticking at the same time value for some period of time. So this implies that the sample times are moving 'faster' than normal during the catch-up period.

    In any event, this is completely weird, and again, a symptom of something odd going on with the LSL stream. Your best bet is to use the Matlab binding for Brainflow, to directly read the samples from Matlab. No need for GUI, LSL, etc.

  • Hi William,
    Thanks for your response! I'm using the the GUI and the Networking wideget instead of the Brainflow. I think most likely the lossage of samples happened via LSL. I checked the automatic saved data by the GUI and compared it to the LSL streamed data. The voltage signals can overlap, which means that only the time information streamed by LSL is incorrect. What do you think?
    In this case, I would actually rely on the automatically saved data, which I assume would much less likely to malfunciton.

  • wjcroftwjcroft Mount Shasta, CA

    If you want a real-time system that receives the data stream in Matlab, then use the Brainflow Matlab binding and forget about using the GUI and LSL.

    Richard @retiutut may have insights on why the Networking Widget (LSL output) is losing time values. But again your best bet is just to go direct as you can.


Sign In or Register to comment.