Giter Club home page Giter Club logo

openbci_lsl's People

Contributors

gabrielibagon avatar hack-r avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openbci_lsl's Issues

Buffer below 1 second returns error/empty data

When changing the lsl.outlet buffer size to be below 1 second, LSL fails to send any samples.
Leaving the outlet buffer maximum at 1 second or above, and changing the lsl.inlet buffer size to be below 1 second, keeps pull_sample in what I assume is an indefinite wait loop, and causes pull_chunk to return only empty data. Is 1 second the smallest supported buffer size, or am I missing something?

data stream not recognized

i am doing an experiment with BCIs and mobile EEG. these two are connected via LSL stream - mobile eeg is streamed on one computer via openBCI and the interface is on another computer. when i turn on the labrecorder on both computers i see that the computer with interface (receiver) recognizes the openbci_data LSL stream but when I write the code to receive data it says no stream is found. Any ideas on what the issues might be? some example code is pasted below

ex1

[def main():
# first resolve an EEG stream on the lab network
print("looking for an EEG stream...")
streams = resolve_stream('type', 'eeg')

# create a new inlet to read from the stream
inlet = StreamInlet(streams[0])

while True:
    # get a new sample (you can also omit the timestamp part if you're not
    # interested in it)
    sample, timestamp = inlet.pull_sample()
    print(timestamp, sample)

if name == 'main':
main()

ex 2

import pylsl

def receive_eeg_stream(stream_name="openbci_data"):
    try:
        # Resolve the stream by name
        print("Resolving LSL stream...")
        streams = pylsl.resolve_byprop("name", f"*{stream_name}*", timeout=5.0)

        if not streams:
            print(f"LSL stream '{stream_name}' not found. Make sure the stream is running.")
            return

        # Open an inlet to receive data
        print("Opening an LSL inlet...")
        inlet = pylsl.StreamInlet(streams[0])

        print(f"Receiving data from LSL stream '{stream_name}'...")

        while True:
            # Receive data sample
            sample, timestamp = inlet.pull_sample()

            # Access EEG data channels 
            eeg_data = sample[:16]

            # Print or process the EEG data 
            print(f"Timestamp: {timestamp}, EEG Data: {eeg_data}")

    except pylsl.LSLTimeoutError:
        print("LSL TimeoutError: Unable to find the stream. Make sure the stream is running.")
    except KeyboardInterrupt:
        print("Experiment interrupted. Closing LSL inlet.")
    except Exception as e:
        print(f"An error occurred: {e}")

if __name__ == "__main__":
    receive_eeg_stream()

Establishing a serial connection in Windows

When I run:

python openbci_lsl.py --stream

it outputs the following:

-------INSTANTIATING BOARD-------
Traceback (most recent call last):
File "openbci_lsl.py", line 56, in
main(sys.argv[1:])
File "openbci_lsl.py", line 40, in main
lsl = streamerlsl.StreamerLSL(GUI=False)
File "C:\Program Files\MATLAB\OpenBCI_LSL\lib\streamerlsl.py", line 46, in init
self.initialize_board(autodetect=True)
File "C:\Program Files\MATLAB\OpenBCI_LSL\lib\streamerlsl.py", line 59, in initialize_board
self.board = bci.OpenBCIBoard()
File "C:\Program Files\MATLAB\OpenBCI_LSL\lib\open_bci_v3.py", line 77, in init
port = self.find_port()
File "C:\Program Files\MATLAB\OpenBCI_LSL\lib\open_bci_v3.py", line 599, in find_port
raise OSError('Cannot find OpenBCI port')
OSError: Cannot find OpenBCI port

Where can I find the [port] for my device? I have a Ganglion.

Also, how do I change the init function in open_bci_v3.py to establish a serial connection in Windows?

effective sample rate vs open_bci LSL sample rate

Hi! I am using LSL for recording my data from the OpenBCI. I am running using cmd command (--stream). It is supposed, based on open bci's documentation, that the sampling rate is 250hz by default. Running as in the example, I obtain this picture where the rate showed is 125hz:

125_lsl

I went into the code for trying to identify where this set up comes and I found this division:
https://github.com/OpenBCI/OpenBCI_LSL/blob/3134a1513c204834d66084491f104e6f236e440b/lib/open_bci_v3.py#L117

Why is the sample rate divided by 2? When I remove this, my new setup in the cmd is:

250_lsl
Despite this change and set up the sample rate using the SDK into LSL (employing the command ~), the sample rate remains the same. For demonstrating it, I recorded the data (using labstreamlayer recorder) and opened the XDF file in Matlab I just realized that the effective sample rate remains 125hz, as Matlab highlights:
srate_matlab

I also calculated the diff between time stamps and effectively I obtained 125hz (0.0080).

matlab_lsl

Can someone explain how I really can set up the sample rate for an effective sample rate (>250Hz) for recording through LSL.

Thanks!

Unexpected END_BYTE 'errors' if user has turned on digital or analog board mode

This is because the end byte checking code in this app, was not updated when the firmware changed to send various end byte values, depending on board mode.

https://docs.openbci.com/Cyton/CytonDataFormat/#binary-format

The following table is sorted by Stop Byte. Drivers should use the Stop Byte to determine how to parse the 6 AUX bytes.

This would be an easy fix. User Professor James Taylor comments here:

https://openbci.com/forum/index.php?p=/discussion/comment/17802/#Comment_17802

LSL fails to execute in Windows 10 platform

Hello,
I was trying to use python LSL but miserably failed.
I installed all the module individually and as given, after running python openbci_lsl.py --stream,
I get the following error:

D:\Github\OpenBCI_LSL>python openbci_lsl.py --stream
Traceback (most recent call last):
  File "openbci_lsl.py", line 25, in <module>
    import lib.streamerlsl as streamerlsl
  File "D:\Github\OpenBCI_LSL\lib\streamerlsl.py", line 21, in <module>
    from pylsl import StreamInfo, StreamOutlet
  File "C:\Program Files\Python37\lib\site-packages\pylsl\__init__.py", line 2, in <module>
    from .pylsl import IRREGULAR_RATE, DEDUCED_TIMESTAMP, FOREVER, cf_float32,\
  File "C:\Program Files\Python37\lib\site-packages\pylsl\pylsl.py", line 1200, in <module>
    lib = CDLL(libpath)
  File "C:\Program Files\Python37\lib\ctypes\__init__.py", line 356, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

Am I missing something?
Any related help would be appreciated.

Unexpected END_BYTE found <2> instead of <192>

Hi, everyone.

I am new on openbci and try to make it lsl stream for my research.

when I try to start lsl, this error message printed.

Do you have any idea what's going on and how can I fix this?
Streaming data... WARNING:root:ID:<1> <Unexpected END_BYTE found <2> instead of <192> Warning: ID:<1> <Unexpected END_BYTE found <2> instead of <192> Exception in thread Thread-1 (start_streaming): Traceback (most recent call last): File "C:\Users\Bong Suhyeon\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1016, in _bootstrap_inner self.run() File "C:\Users\Bong Suhyeon\AppData\Local\Programs\Python\Python310\lib\threading.py", line 953, in run self._target(*self._args, **self._kwargs) File "C:\Users\Bong Suhyeon\Downloads\OpenBCI_LSL-master\OpenBCI_LSL-master\lib\open_bci_v3.py", line 158, in start_streaming sample = self._read_serial_binary() File "C:\Users\Bong Suhyeon\Downloads\OpenBCI_LSL-master\OpenBCI_LSL-master\lib\open_bci_v3.py", line 225, in _read_serial_binary unpacked = struct.unpack('3B', literal_read) struct.error: unpack requires a buffer of 3 bytes

Save files with lab streaming layer

I would like to add the option of saving eeg dataset from OpenBCI_LSL using python but I don't know where to start or
how should I handle the data like structure or format, any ideas?

python openbci_lsl.py --stream is not finding board

When I run

python  openbci_lsl.py --stream 

It hangs indefinitely on -------INSTANTIATING BOARD-------. The Python library's user.py script finds the board automatically with no problem. These 2 programs seem related, so I'm not sure why it's not working for LSL for me.

The CSR 4.0 BT Dongle is plugged in and active, but is it perhaps using the builtin BT adapter by mistake?

In case it matters I'm on Ubuntu and I am using a Ganglion board.

ModuleNotFoundError: No module named 'serial'

When I run:

python openbci_lsl.py --stream

in CMD it displays the following error:

Traceback (most recent call last):
File "openbci_lsl.py", line 25, in
import lib.streamerlsl as streamerlsl
File "C:\Program Files\MATLAB\OpenBCI_LSL\lib\streamerlsl.py", line 20, in
import lib.open_bci_v3 as bci
File "C:\Program Files\MATLAB\OpenBCI_LSL\lib\open_bci_v3.py", line 19, in
import serial
ModuleNotFoundError: No module named 'serial'

Does anyone know how to solve this?

Connect fail to the board in the GUI

Hi everyone!

I can't connect the software to the board on GUI mode. When I click on the "Connect Board" buttom, the follow message show on the terminal:

$ python openbci_lsl.py
Detecting board settings...
/dev/ttyUSB0 False

-------INSTANTIATING BOARD-------
Connecting to V3 at port /dev/ttyUSB0
Traceback (most recent call last):
File "/home/rhubner/BCI/OpenBCI_LSL/lib/gui.py", line 298, in connect_board
self.lsl.board.disconnect() #close the serial
AttributeError: 'StreamerLSL' object has no attribute 'board'

The configuration in the GUI seems correct. My port is /usb/ttyUSB0 and daisy is set to 'false'.

The error showed doesn't related to the 'self.lsl.initialize_board(port=port,daisy=daisy)', but the line 298 (self.lsl.board.disconnect() #close the serial). So, I couldn't understand why the 'initialize_board' fail and why the object 'self.lsl' lost the reference.

294 try:
295   self.lsl.initialize_board(port=port,daisy=daisy)
296 except:
297   self.lsl.board.disconnect()  #close the serial
298   self.console.setText("  Error connecting to the board")
299   print("Error connecting to the board") 
300   return

ussue during data stream <Unexpected END_BYTE found <0> instead of <192>

Hello,

I'm able to connect to and stream data from our Cyton board. However, I have received this warning several times now. Does this actually affect the data stream in any way? As of right now I am unsure of wether it causes missing data or not.

--> /start
Streaming data...

--> WARNING:root:ID:<160> <Unexpected END_BYTE found <0> instead of <192>
Warning: ID:<160> <Unexpected END_BYTE found <0> instead of <192>
WARNING:root:ID:<246> <Unexpected END_BYTE found <0> instead of <192>
Warning: ID:<246> <Unexpected END_BYTE found <0> instead of <192>
/stop
--> q

I have gotten this several times, and also with numbers different from <0> and <192>.

Any answers and comments appreciated!
Thanks!
BR, Henrikke

Unable to stream data to Python

I'm actually trying to stream data into MATLAB without a change of delay in data transmission. I've tried following this link but every time I run this line of code in python:
!python openbci_lsl.py COM13 --stream
The command line just hangs and nothing happens for a while. Any ideas on how to fix this and is there a better way to stream data directly from the serial port to matlab?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.