Skip to content

data stream not recognized #22

@ggril

Description

@ggril

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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions