Hello everyone!
I'm running an experiment where I have two computers connected by Ethernet:
- Computer A has the amplifier connected (EEGO) and runs the acquisition server (AS). It also runs an app with an acquisition client (AC) to visualize the signal and gets input from the keyboard to send stimulations to the AC.
- Computer B has an AC too, and then it does some online processing to the signal and saves the data. Besides, it has a threshold that when triggered, sends a stimulation (this is done with Matlab).
Now, I can see this last stimulation in computer B and also save it with the rest of the signal for later inspection. However, I would like to send this stimulation somehow to the AS (in the same way as the Keyboard Stimulation box), or at least to Computer A in real time, just for visualization purposes. Is there any way to do this with OpenVibe? I tried to make it work with TCP and LSL boxes, but they look like they only work in localhost...
Thank you in advance!
Esteban.
Sending stim to AS in another computer
Re: Sending stim to AS in another computer
Hi Esteban,
I have tried a few things today and you should be able to get stimulations from computer B to computer A.
I think this last option integrates the best as the LSLCommunication box seems to be showing issues.
I hope this this makes sense, let us know what works for you.
Cheers,
Thomas
I have tried a few things today and you should be able to get stimulations from computer B to computer A.
- I tried with LSL first, and it does work but not it's not perfect.
Basically, I used the LSLCommunication box on computer B to send stimulations, and the same box on computer A to receive them. The stimulations would only start poping on computer A after some time (between 20s and 60s) which is intriguing and obvioulsy not acceptable. However I'm on a corporate network, so it might give much better results if the computers are directly connected. - Then, I kept the LSLCommunication box on computer B, but I used a dedicated Acquisition Server on computer A to receive the stimulations using the LabStreamingLayer (LSL) driver. This works well but the driver needs to receive signal (stimulation stream is optional) to connect. You can always send some random signal to make it happy but it's a bit hacky. And it requires you to run two acquisition servers.
- The last option is the one that works best, but requires some python code.
I added a Python box on the computer B scenario, and used it with the script below.
The box has one stimulation input in order to receive stimulations and sends them via TCP to the TCP tagging server of the Acquisition Server on computer A.
Code: Select all
import socket
class MyOVBox(OVBox):
def __init__(self):
OVBox.__init__(self)
self.sAddr = ('127.0.0.1', 15361) # Localhost here, replace with IP of computer A
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.flag = 1 # option to let the AS timestamp the stimulation
def initialize(self):
self.sock.connect(self.sAddr)
return
def process(self):
for chunkIdx in range( len(self.input[0]) ):
chunk = self.input[0].pop()
if(type(chunk) == OVStimulationSet):
for stimIdx in range(len(chunk)):
timestamp = 0
stim=chunk.pop()
f = self.flag.to_bytes(8, 'little')
s = stim.identifier.to_bytes(8, 'little')
t = timestamp.to_bytes(8, 'little')
self.sock.send(f+s+t)
return
def uninitialize(self):
# nop
return
box = MyOVBox()
I hope this this makes sense, let us know what works for you.
Cheers,
Thomas
Re: Sending stim to AS in another computer
Hi Thomas,
The Python script worked super good and definitely does the job.
Thanks a lot for your help! That was awesome
Best,
Esteban.
The Python script worked super good and definitely does the job.
Thanks a lot for your help! That was awesome
Best,
Esteban.