OpenViBE forum

The OpenViBE community
It is currently Sat Dec 16, 2017 8:29 pm

All times are UTC

Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Tue Mar 17, 2015 3:01 am 

Joined: Sun Mar 15, 2015 7:55 pm
Posts: 3
Bonjour à tous! I'm using a python script to automate an experiment using OpenViBE and the OpenBCI amplifier. The script generates stimulations demarcating control time periods and trial time periods.

I'm trying to use the stream switch box to break the incoming stream up and record the control segments separately from the trial segments. I'm getting very strange behaviour out of the stream switch box using these python-generated stimulations.

Viewing the output of the stream switch with a signal display box, the display remains blank until the target stimulation arrives, and then the scrolling area is instantly filled, the cursor moves a short distance, and then stops, and no additional signal is viewable. Behaviour is similar when viewing the recorded output of the stream switch. (I would like to be able to examine the stream in some more direct fashion than by watching the signal display, but I'm not sure the best way to do this).

The stream switch behaves normally when I tested with the keyboard stimulator box.

Curiously, the python-generated stimulations also seem to do odd things to the stimulation multiplexer box. If I connect a clock stimulator, keyboard stimulator, and the stimulations from my stream matrix all to a stim multiplexer box (which is then connected to a stim listener box), none of the keyboard or clock stimulations are sent to the log, except when there is also a stimulation from the stream. It is as though the clock and keyboard stims are buffered by the multiplexer, and then sent all at once when the recorded stim arrives (I thought this might be the default behaviour of the multiplexer box, but after testing with clock and keyboard stims it seems this is not the case.)

Any idea why this might be occuring? The stimulations do appear in the signal display, and they do show up in the log manager. The python code is modified from the clock stimulator example script. Is it possible that the stimulations are malformed in some way that would cause this behavior (ie, stimulation headers being set erroneously)? My hacking of the python clock stimulator may have left behind something problematic, since I don't really understand the OpenViBE python API clearly at all. Any other clues as to the cause?

Here is the python code that generates the stimulations:

class MyOVBox(OVBox):
  def __init__(self):
    self.stimLabel = None
    self.stimCode = None

    self.sequence = {
      '10': 'OVTK_StimulationId_ExperimentStart',
      '30': 'OVTK_StimulationId_SegmentStop',
      '330': 'OVTK_StimulationId_SegmentStart',
      '630': 'OVTK_StimulationId_SegmentStop',
      '930': 'OVTK_StimulationId_SegmentStart',
      '1230': 'OVTK_StimulationId_ExperimentStop',
    self.sequence = {
      '1': 'OVTK_StimulationId_ExperimentStart',
      '10': 'OVTK_StimulationId_SegmentStart',
      '20': 'OVTK_StimulationId_SegmentStop',
      '30': 'OVTK_StimulationId_SegmentStart',
      '40': 'OVTK_StimulationId_SegmentStop',
  def initialize(self):

    self.output[0].append(OVStimulationHeader(0., 0.))

    print "Sequence controller initialized"

  def process(self):
    currentTimeString = str(int(self.getCurrentTime()))

    if currentTimeString in self.sequence:
      currentStimLabel = self.sequence[currentTimeString]
      currentStimCode = OpenViBE_stimulation[currentStimLabel]

      stimSet = OVStimulationSet(self.getCurrentTime(), self.getCurrentTime()+1./self.getClock())
      stimSet.append(OVStimulation(currentStimCode, self.getCurrentTime(), 0.))
      print "Sending stimulation"
  def uninitialize(self):
    end = self.getCurrentTime()
    self.output[0].append(OVStimulationEnd(end, end))

box = MyOVBox()

Thanks very much for your help!


Reply with quote  
PostPosted: Thu Mar 19, 2015 8:52 am 

Joined: Tue Dec 04, 2012 3:53 pm
Posts: 601
Location: INRIA Rennes, FRANCE
Hello Adam,

Some speculation follows.

In OpenViBE, data is transmitted in chunks. Each chunk has a beginning time stamp and an end time stamp. These stamps should be 'appropriate'. Examples: Components like signal display are mostly tested and used with continuous data, and if it gets - for example - time-overlapping chunks, results might be curious. Also, stimulation streams should have a particular chunk structure, usually a narrow chunk time range which includes the stimulation's time stamp. So one thing to look is if the chunk structure of your streams resemble that of streams generated otherwise. You can do this by using the EBML spy box.

What I would do is to see if the python clock stimulator produces a well behaving stream, and then find out how yours differs from it.

One thing I see in your code is that you try to send the stimulations along the way. This should not be necessary and might not be happening robustly the way you do it. You can just construct all the stimulation sets with the intended time stamps and push them out right at the beginning. OpenViBE kernel should take care of passing them out properly. If I remember right, several of the lua stimulators (for example in the SSVEP mind shooter demo, training-acquisition-controller.lua) are doing it in this manner,.

Happy hacking,

Reply with quote  
PostPosted: Thu Mar 19, 2015 8:58 pm 

Joined: Sun Mar 15, 2015 7:55 pm
Posts: 3
Thanks Jussi. It hadn't occurred to me that I could output all the stims from the box at the outset, and the OV kernel would space them appropriately.

I will have another go at inspecting the stim stream with the EBML stream spy and comparing this with properly-behaving stims and see if anything comes to light.

Thanks for your help,

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Americanized by Maël Soucaze.