sccn / lsl_archived

Multi-modal time-synched data transmission over local network
242 stars 134 forks source link

can't get values, actichamp #286

Open pdeman opened 6 years ago

pdeman commented 6 years ago

Hi,

we are using a actichamp (brainproduct) system on a windows computer. we started the apps/actichamp.exe on this computer.

we made a small script to listen the data streaming on linux computers:

import sys, os, socket, time
sys.path.append("binaries-python2.7")
import pylsl

resolvedStreams = list(pylsl.resolve_streams(1.0))

for k in range(len(resolvedStreams)):
    print(resolvedStreams[k].name() + ' (' + resolvedStreams[k].hostname() +')')

print("looking for an EEG stream...")
streams = pylsl.resolve_stream('type','EEG')

inlet = pylsl.stream_inlet(streams[0])

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

(this code works on the windows computer, it can "listen itself". but on the linux computers we have this:

ActiChamp-0 (L-1010035417) ActiChamp-0-Sampled-Markers (L-1010035417) looking for an EEG stream... <pylsl.pylsl.StreamInlet instance at 0x7f58bfb717e8> 0 ((None, None), [])

so it detects that its an actichamp but we don't get the data, what am I doing wrong ?

pdeman commented 6 years ago

If I run the SendData.py, other linux computers receive:

BioSemi looking for an EEG stream... <pylsl.pylsl.StreamInlet instance at 0x7f58bfb717e8> 0 ((None, None), [])

cboulay commented 6 years ago

Some pulls will have 0 samples. This is especially true for the first pull. Try the following:

import pylsl

print("looking for an EEG stream...")
streams = pylsl.resolve_stream('type', 'EEG')

if len(streams) > 0:
    inlet = pylsl.stream_inlet(streams[0])

    while True:
        samples, timestamps = inlet.pull_chunk(timeout=0.0)
        if len(timestamps) > 0:
            print(samples.shape)

By the way, you shouldn't have to append pylsl binaries to your path. I use Linux but I don't use Python 2.7 so I can't reproduce your error. Try the following: After uninstalling all versions of pylsl and after building the LSL libraries, go into the liblsl-Python directory where setup.py is and do a pip install .. Let me know if that doesn't work for you.

Also, can you tell me where you got the template for your original example? (I've since edited your example, sorry). The use of pylsl.vectorf() is legacy and is not recommended anymore.

Edit: Markdown damaged my original code. It should be fixed now.

dmedine commented 6 years ago

I believe that if you set the timeout to some value greater than 0.0, pull_chunk will block until samples are available. In that case, you shouldn't have to check to see if anything has come through, and you will use much less CPU.

On 4/10/2018 4:12 PM, Chadwick Boulay wrote:

Some pulls will have 0 samples. This is especially true. Try the following:

import pylsl

print("looking for an EEG stream...") streams= pylsl.resolve_stream('type','EEG')

if len(streams)> 0: inlet= pylsl.stream_inlet(streams[0])

 while  True:
     samples, timestamps=  inlet. pull_chunk(timeout=0.0)
     if  len(timestamps)>  0:
         print(samples.shape)

By the way, you shouldn't have to append pylsl binaries to your path. I use Linux but I don't use Python 2.7 so I can't reproduce your error. Anyway, something you should try is, after uninstalling all versions of pylsl and after building the LSL libraries, go into the liblsl-Python directory where setup.py is and do a |pip install .|. Let me know if that doesn't work for you.

Also, can you tell me where you got the template for your original example? (I've since edited your example, sorry). The use of pylsl.vectorf() is legacy and is not recommended anymore.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sccn/labstreaminglayer/issues/286#issuecomment-380113608, or mute the thread https://github.com/notifications/unsubscribe-auth/ADch7jbtlFEO2J10eh_DcZz9gzFnwnT0ks5tnL29gaJpZM4TOTnf.

pdeman commented 6 years ago

Try the following: After uninstalling all versions of pylsl and after building the LSL libraries, go into the liblsl-Python directory where setup.py is and do a pip install .. Let me know if that doesn't work for you.

I tried that, I just did: import pylsl print("looking for an EEG stream...") streams = pylsl.resolve_stream('type', 'EEG')

and now streams = pylsl.resolve_stream('type', 'EEG') never end. it doen't crash but never stop.

cboulay commented 6 years ago

Sorry, I copy-pasted that part of your code but it appears that too was maybe too old. See here for the correct function.

streams = pylsl.resolve_byprop('type', 'EEG', timeout=5.0) Edit: Or... streams = pylsl.resolve_byprop('name', 'ActiChamp-0', timeout=5.0)