Open FenjaB opened 7 years ago
I don't use LSL with Matlab, but receiving two streams in Matlab should be possible. To avoid the problem you're encountering, you'll have to call pull_* with a timeout. How to handle cases when Stream-1 has no data but Stream-2 does, or vice versa, will depend on your specific use case. For example, you might need to buffer up Stream-1 data until you get something from Stream-2.
You can use callbacks. It's not so easy to do in Matlab, but it is possible. Here is a introduction:
http://undocumentedmatlab.com/blog/explicit-multi-threading-in-matlab-part4
On 9/5/2017 3:31 PM, FenjaB wrote:
Hello, is it possible to receive two streams in Matlab at the same time in the same script? It works with LabRecorder but I need it in Matlab. I think my problem is that Matlab waits at pull_sample at one stream and doesn't look at the other one.
— 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/217, or mute the thread https://github.com/notifications/unsubscribe-auth/ADch7h8EhaSe1f3NVc6iaWq8d5kpZbcNks5sfU09gaJpZM4PM89D.
@dmedine , is there anything specific to the Matlab wrapper that prevents two outlets from being used in the same thread?
No, not at all. I think that spinning two threads is much more reliable than trying to coherently and reliably time two outlets that receive on the same one. That would require, among other things, buffering, and (as you point out) being careful with timeouts. The callback syntax in Matlab is a little scary at first, but in the end, I think this approach is much easier to deal with. Also, it's the way LabRecorder does it.
On 9/5/2017 5:04 PM, Chadwick Boulay wrote:
@dmedine https://github.com/dmedine , is there anything specific to the Matlab wrapper that prevents two outlets from being used in the same thread?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sccn/labstreaminglayer/issues/217#issuecomment-327204434, or mute the thread https://github.com/notifications/unsubscribe-auth/ADch7gwzM0OERjc9aB8HH6TJbappmS4Xks5sfWLxgaJpZM4PM89D.
Thanks. I ill try that later
I haven't worked much with the matlab wrapper, so there may be some complications that I am not familiar with. However, generally when dealing with multiple channels I rely on the LSL library to take care of the buffering and threading issues (which it does a good job of).
Generally I run one thread in the calling application, which sets up all the inlets required. The application runs a main loop, where it attempts to pull samples from all inlets at some high frequency. The pull command timeout is zero. If the returned time stamp is not zero, data is ready and the sample is valid. If the timestamp is zero, no data is ready.
On 9/6/2017 12:37 AM, David Medine wrote:
No, not at all. I think that spinning two threads is much more reliable than trying to coherently and reliably time two outlets that receive on the same one. That would require, among other things, buffering, and (as you point out) being careful with timeouts. The callback syntax in Matlab is a little scary at first, but in the end, I think this approach is much easier to deal with. Also, it's the way LabRecorder does it.
On 9/5/2017 5:04 PM, Chadwick Boulay wrote:
@dmedine https://github.com/dmedine , is there anything specific to the Matlab wrapper that prevents two outlets from being used in the same thread?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub
https://github.com/sccn/labstreaminglayer/issues/217#issuecomment-327204434,
or mute the thread
— 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/217#issuecomment-327401313, or mute the thread https://github.com/notifications/unsubscribe-auth/AFC33WLXzBYlaxMWAroFyaVASvckKnOUks5sfkuggaJpZM4PM89D.
Hello, is it possible to receive two streams in Matlab at the same time in the same script? It works with LabRecorder but I need it in Matlab. I think my problem is that Matlab waits at pull_sample at one stream and doesn't look at the other one.