labstreaminglayer / pylsl

Python bindings (pylsl) for liblsl
MIT License
136 stars 57 forks source link

Update ReceiveData.py #51

Closed novikov-p-a closed 2 years ago

novikov-p-a commented 2 years ago

Arguments were removed from the call of resolve_stream(). With previous arguments, resolve_stream() hangs the thread.

dmedine commented 2 years ago

Thank you very much for submitting a pull request!

I have two apprehensions about changing this. One is that all the other API's have basically exactly the same example programs. Changing one implies that they should all be changed. The other is that I believe it is important to demonstrate the use of arguments in resolve_stream. One option would be adding a few comments in the code explaining this. Another option would be adding an example program that demonstrates just this. For the record, the arguments do not hang the call if there is in fact a stream on the network with 'type' 'EEG'.

novikov-p-a commented 2 years ago

Thank you very much for the explanation! I will have access to the recording equipment again in a couple of days and I can return to this.

dmedine commented 2 years ago

If you are running tests without hardware, you can always generate a 'fake' eeg stream by running SendData.py.

cboulay commented 2 years ago

Closing because we won't be merging this.

Along @dmedine 's comments, there are a couple changes that we would merge:

  1. Add code comments that this call will block until a stream of type EEG is found. For example, running SendData.py in another process can create such a stream.
  2. Add the wait_time=2.0 argument to resolve, and if the length of the returned streams list is 0, print a message and return.
    • The printed message would basically be the same as what you might type in the comments in option 1.

In either case, the added code should be minimal. These examples are really meant to be as simple as possible.

If we wanted to provide a more comprehensive example then we would add argparse, logging, continuous_resolver in a thread, preallocate a numpy array and use pull_chunk's dest_obj argument, etc.