OpenViBE forum

The OpenViBE community
It is currently Wed Dec 13, 2017 9:01 am

All times are UTC




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

Joined: Wed Dec 09, 2015 6:47 pm
Posts: 1
Hi,
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.

Best
Satya

Code:
import time
import serial

# configure the serial connections (the parameters differs on the device you are connecting to)
ser = serial.Serial(
    port='COM5',
    baudrate=9600,
    parity=serial.PARITY_ODD,
    stopbits=serial.STOPBITS_TWO,
    bytesize=serial.SEVENBITS
)

ser.isOpen()


class MyOVBox(OVBox):
   def __init__(self):
      OVBox.__init__(self)
      
   def initialize(self):
      # nop
      return
      
   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)):
               stim=chunk.pop();
               print 'Received stim', stim.identifier, 'stamped at', stim.date, 's'
      ser.write('Received stim')
         
                             
         #else:
         #   print 'Received chunk of type ', type(chunk), " looking for StimulationSet"
      return
      
   def uninitialize(self):
      # nop
      return

box = MyOVBox()


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

Joined: Tue Dec 04, 2012 3:53 pm
Posts: 599
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).


Cheers,
Jussi


Top
 Profile  
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.