delay in stream data from OpenBCI_GUI to Matlab 2019

Hi, 
I am using the Cyton board and the dongle to receive data from 8 channels in a Windows PC. I am able to visualize all the 8 signals in real time on the OpenBCI_GUI. However, when I set up the LSL from this GUI to stream data into Matlab, I have noticed that the stream data in Matlab has a long delay of approximately 20 to 23 seconds. In Matlab, from the command window I use: vis_stream. This allows me to visualize the 8 signals with the long delay of 20 s. I tried changing different parameters (from the vis_stream pop up window) such as maximum time range to buffer, sampling rate for display and refresh rate for display but the long delay of over 20 s in the stream data persisted. 
I also tried creating different Matlab scripts where I use pull_sample() or pull_sample(0) or pull_chunk() functions and plot the stream data but obtain the same long delays in the stream data. 
Any advice will be greatly appreciate it.

Thanks,
Fredy

Comments

  • retiututretiutut Louisiana, USA
    edited August 2019

    @FredyMunoz

    I am the developer who fixed LSL output from the GUI. Before, it was completely broken. The output from the GUI using LSL is very strait forward, with little room for error. I have successfully tested LSL networking using OpenVibe ONLY with no delays or issues of any kind!

    Please provide an example Matlab sketch/program so that myself and others can test this and replicate/resolve any issues with GUI->MATLAB integration.

  • retiututretiutut Louisiana, USA

    ALL MATLAB USERS: Are there any obvious errors in the OpenBCI MATLAB Doc???

    If so, please make an issue here on the new Docs repo.

  • edited February 2020

    Hi,
    Please see below the script that I use with the pull.sample() function. I put side by side the real-time signals displayed on the OpenBCI_GUI and the figure plotted in the Matlab script. I notice a delay greater than 20 s in the signals displayed by the Matlab script.
    Thanks for your help.

    disp('Loading the library...');
    lib = lsl_loadlib();
    disp('Resolving an EEG stream...');
    result = {};
    while isempty(result)
        result = lsl_resolve_byprop(lib,'type','EEG'); end
    
    disp('Opening an inlet...');
    inlet = lsl_inlet(result{1});
    disp('Now receiving data...');
    fs=250;%Hz
    duration=1;%seconds
    totalSamples=duration*fs;
    displayTime=10;%in seconds
    EMGdata=zeros(totalSamples,8);
    timeStamp=zeros(totalSamples,1);
    displayRawSignals=zeros(displayTime*fs,8);
    
    stop=0;
    counter=0;
    while 1
       [vec,ts] = inlet.pull_sample();
       if isempty(vec)~=1
         counter=counter+1;
         if counter<=totalSamples
            EMGdata(counter,1:8)=vec;
            timeStamp(counter,1)=ts;
         else
            counter=0;
            stop=1;
         end
       end     
        if stop==1%
            displayRawSignals=circshift(displayRawSignals,-totalSamples);
            displayRawSignals(displayTime*fs-totalSamples+1:displayTime*fs,:)=EMGdata;
            figure (1)
            plot(displayRawSignals(:,1),'r')
            stop=0; 
         end    
    end
    
  • retiututretiutut Louisiana, USA

    Moving this to an OpenBCI GUI Issue: https://github.com/OpenBCI/OpenBCI_GUI/issues/595

    Looks like LSL streaming needs a handful of work, and there is a need to prioritize LSL streaming for the next GUI releases.

  • Hey there,
    I replicated the 23seconds delay issue from GUI -> MATLAB using my own MATLAB scripts.
    Is there currently any known configuration where live streaming from Cyton to MATLAB works? Maybe Python --> MATLAB?

    Thanks for your help.

  • retiututretiutut Louisiana, USA
    edited October 2019

    Everyone please try 4.1.6. There was a bug that didn't allow multiple LSL streams to work properly, and it has been fixed.

    I've written some simple LSL python scripts: https://github.com/OpenBCI/OpenBCI_GUI/tree/master/Networking-Test-Kit/LSL. This allowed me to debug the issue.

    Also, I am running Matlab2019b with liblsl-Matlab-1.10 added to my Matlab Path, and I do not see a delay!

  • retiututretiutut Louisiana, USA
    edited October 2019

    All of these people experiencing a delay have to have something in common... Not quite sure what it is.

    Please refer to the above screenshot. I was not able to replicate any type of delay using: Matlab, OpenVibe, or Python.

  • retiututretiutut Louisiana, USA

    @FredyMunoz Are you using 32bit or 64bit apps? GUI and Matlab?

  • Hey,
    Testing the OpenBCI GUI to stream over LSL from the Cython board, and I was able to replicated the 23 s delay.
    My system is W10 64-bits, and the OpenBCI GUI is 4.1.7, and the LSL stream was read from Python3 using pylsl.
    Later, I used OpenBCI_LSL to stream data from the Cython board over LSL. And using the same Python3 codes to received data, and there was not noticeable delay.

Sign In or Register to comment.