OpenViBE forum

The OpenViBE community
It is currently Sun Sep 23, 2018 4:49 pm

All times are UTC

Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Dec 10, 2015 9:19 am 

Joined: Wed Dec 09, 2015 6:47 pm
Posts: 1
I am master student of Cognitive Neuroscience, i want to conduct experiment on Motor imaginary task.
I want to write the "motor-imagery-bci-graz-stimulator" data (stim marker) on serial port which can read by "NeuroScan amp" device.
I modify the "python-print-stimulations" example to do my task , its work but not reach real time.(code inserted below )

I want it work in real time and please suggest me if there is any better way to do it or better python script to do it.

Thanks a lot.


import time
import serial

# configure the serial connections (the parameters differs on the device you are connecting to)
ser = serial.Serial(


class MyOVBox(OVBox):
   def __init__(self):
   def initialize(self):
      # nop
   def process(self):
      for chunkIndex in range( len(self.input[0]) ):
         chunk = self.input[0].pop()
         if(type(chunk) == OVStimulationSet):
            for stimIdx in range(len(chunk)):
               print 'Received stim', stim.identifier, 'stamped at',, 's'
      ser.write('Received stim')
         #   print 'Received chunk of type ', type(chunk), " looking for StimulationSet"
   def uninitialize(self):
      # nop

box = MyOVBox()

Reply with quote  
PostPosted: Fri Dec 11, 2015 8:30 am 

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

at a glance the code looks reasonable. First of all, does it run in real time if you don't send anything to the serial port, but just run the script with printing only? At least that should be possible. This helps you to narrow down if the issue is in the thing in general, or in the serial write routine. Note also that probably not all process() calls should write to the serial port, but only when it has some stimulations pending. Based on the tabbing I see, you write each time.

Afaik the process() function is likely to be called repeatedly even if there were no stimulations to process, so you'll need to check (those ifs there might do).


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

All times are UTC

Who is online

Users browsing this forum: No registered users and 1 guest

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.