Sending External Stimulation

Obtaining data from various hardware devices
Post Reply
pwierzgala
Posts: 22
Joined: Tue Nov 26, 2013 3:43 pm

Sending External Stimulation

Post by pwierzgala »

Hi,

I'm trying to send stimulations from external application to acquisition server but it doesn't work as expected: stimulations don't appear in "signal display" box. I've followed:

http://openvibe.inria.fr/send-stimulati ... on-server/

and read:

viewtopic.php?f=5&t=4961
  • I'm using OpenViBE in version 0.17.0 on Ubuntu 12.04.
  • I've compiled it by executing: ./linux-install_dependencies and ./linux-build.
  • I've set "AcquisitionServer_ExternalStimulations = True" in personal configuration file.
Do you have any idea what may be wrong?

jtlindgren
Posts: 778
Joined: Tue Dec 04, 2012 3:53 pm
Location: INRIA Rennes, FRANCE

Re: Sending External Stimulation

Post by jtlindgren »

Take 'network-acquisition.xml' scenario and get it to run. You should see a signal when acquisition server is sending data. Now launch 'openvibe-external-stimulation-connection-example.sh'. You should now see a stimulus in the display. If so, just follow the code of that example app. If there is no stimulus that way, there's a problem.


Happy hacking,
Jussi

pwierzgala
Posts: 22
Joined: Tue Nov 26, 2013 3:43 pm

Re: Sending External Stimulation

Post by pwierzgala »

It works, thanks! I'm not really sure what I did that it started to work but i tried:
  • installing openvibe 0.16.2,
  • reinstalling openvibe 0.17.0,
  • enbling and disabling "EnableExternalStimulations" in Acquisition Server Properties,
  • restarting openvibe,
  • trying your test.
After reinstallation of version 0.17.0 I had disabled "EnableExternalStimulations" by default. I enabled it but stimulations still didn't work. I closed all OpenViBE windows and after that I got stimulations on "signal display".
I'd like to note that in "Edit->Preferences" I have now "AcquisitionServer_ExternalStimulations" set to false and external stimulations work.
Besides that in version 0.16.2 acqusition server is periodically sending (it's own?) stimulations with value 0 (screen in attachemnt).
Last edited by pwierzgala on Tue Jan 21, 2014 10:41 am, edited 1 time in total.

pwierzgala
Posts: 22
Joined: Tue Nov 26, 2013 3:43 pm

Re: Sending External Stimulation

Post by pwierzgala »

Forgot about screenshot :]
Attachments
Screenshot.png
Screenshot.png (37.27 KiB) Viewed 11527 times

jtlindgren
Posts: 778
Joined: Tue Dec 04, 2012 3:53 pm
Location: INRIA Rennes, FRANCE

Re: Sending External Stimulation

Post by jtlindgren »

Periodical stimulations happen because you have selected such an option in the driver.

Use CSV Writer box to produce a CSV file, and you'll see what the reader expects. Note the weird practice with the mandatory last column.

Code: Select all

Time (s);Channel 1;Channel 2;Channel 3;Channel 4;Sampling Rate
0.000000;1.698815;1.305434;-1.408991;-0.466583;512
0.001953;1.735544;1.177482;-1.865364;-0.517466;
0.003906;1.756200;0.998269;-2.263588;-0.300512;
0.005859;1.760030;0.782073;-2.551195;0.152289;
0.007813;1.746574;0.545681;-2.692383;0.742552;
Cheers,
Jussi

pwierzgala
Posts: 22
Joined: Tue Nov 26, 2013 3:43 pm

Re: Sending External Stimulation

Post by pwierzgala »

You are right. I didn't open driver properties before so I didn't see that option. Everything is clear now. Thanks for help very much!

klaro
Posts: 4
Joined: Mon Jun 27, 2016 8:34 pm

Re: Sending External Stimulation

Post by klaro »

Hi,

I have exactly the same problem. I want to send stimulations from a self programmed game to OV via TCP tagging. The suggestion of jtlindgren works. But If I use the provided tcp-tagging python script example, the stimuli don't appear in the display or anywhere else. I hope someone here can help me with this.

My system:
Win 7 64 Bit
openvibe 1.2.0
The game is written with the pygame library

Best,
David

jtlindgren
Posts: 778
Joined: Tue Dec 04, 2012 3:53 pm
Location: INRIA Rennes, FRANCE

Re: Sending External Stimulation

Post by jtlindgren »

Hi Klaro, there might be a bit of confusion there. The external stimulation connection example uses the previous technique of 'External Stimulations' whereas 'TCP Tagging' is our new recommended approach. I'll ping our expert about the tcp tagging python example.

TCP Tagging doc in general,

http://openvibe.inria.fr/tcp-tagging/

Cheers,
Jussi

klaro
Posts: 4
Joined: Mon Jun 27, 2016 8:34 pm

Re: Sending External Stimulation

Post by klaro »

Oh okay. I thought this was completely replaced with TCP tagging. However, if I would use external stimulations, I need to do this in C++, right? Thanks for asking your expert. I would prefer the TCP tagging solution with python since all my code is based on python. So please let me know :). Thanks.

This is what I do right now:
I acquire the signals from the generic oscillator.
In the designer I use the network-acquisition.xml example.
After I started the acquisition server and designer, I execute the example script tcp-tagging-client.py

Code: Select all

import sys
import socket
from time import time, sleep

# host and port of tcp tagging server
HOST = '127.0.0.1'
PORT = 15361

# Event identifier (See stimulation codes in OpenVibe documentation)
EVENT_ID = 0x00008205

# Artificial delay (ms). It may need to be increased if the time to send the tag is too long and causes tag loss.
DELAY=0

# transform a value into an array of byte values in little-endian order.
def to_byte(value, length):
    for x in range(length):
        yield value%256
        value//=256

# connect 
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))

for i in range(100):
    # create the three pieces of the tag, padding, event_id and timestamp
    padding=[0]*8
    event_id=list(to_byte(EVENT_ID, 8))

    # timestamp can be either the posix time in ms, or 0 to let the acquisition server timestamp the tag itself.
    timestamp= list(to_byte(int(time()*1000)+DELAY, 8))

    # send tag and sleep
    s.sendall(bytes(padding+event_id+timestamp))
    sleep(1)

s.close()
Now I would expect, that the stimuli are displayed but they aren't.

Best,
klaro

nfoy
Posts: 40
Joined: Fri Nov 14, 2014 1:06 pm

Re: Sending External Stimulation

Post by nfoy »

Hi klaro,

I think the problem you have is related to the fact that 'bytes' is different in python2 and python3.
The example script was written for python 3. All you have to do is to replace bytes by bytearray. This should work for both python 2 and python 3.
The example script will be changed accordingly so that other people don't face the same problem.

Thanks !

klaro
Posts: 4
Joined: Mon Jun 27, 2016 8:34 pm

Re: Sending External Stimulation

Post by klaro »

Hi nfoy,

thank you so much. It works now :).

Best,
klaro

Post Reply