I'm French student and I use OpenVibe for a project using SSVEP and a space invader video games.
I search to release my orders with correlation between one sinus(simulation of flash) and signals after a spatial filter.
The scenario contains an acquisition server(or GDF reader for test), three python scripting Box (one for each sinus) and Button Vrpn server to dialog with the application.
But, my problem is that I don't succeed to recover value (type float) for numpy.correlate().
my code:
Code: Select all
import numpy
def process(self):
#sinus frequency
freq=2*numpy.pi*20
#value input, type OVSignalBuffer
chunk = self.input[0]
#dimension
siz=numpy.size(chunk)
if(siz >=2):
#recove in array
numpyBuffer = numpy.array(chunk)
#condition of traitement
if(type(numpyBuffer) == numpy.ndarray):
#time array simulation for sinus
t=numpy.array(range(numpy.size(numpyBuffer)-1))
t.astype(float).tolist()
#release sinus
sinus=numpy.sin(freq*t*2/180.).tolist()
#I need to release correlate
correl=numpy.correlate(sinus[:(siz-1)],numpyBuffer[:(siz-1)])/numpy.sqrt(numpy.sum(numpy.power(sinus,2))+numpy.sum(numpy.power(numpyBuffer,2)))
if(correl > 0.8):
#send Stimulation for Button vrpn server
stimSet = OVStimulationSet(self.getCurrentTime(), self.getCurrentTime()+1./self.getClock())
stimSet.append(OVStimulation(self.stimCode, self.getCurrentTime(), 0.))
self.output[0].append(stimSet)
if(siz >= 20):
chunk=chunk.pop();