PDA

View Full Version : data lose


psykoko
12-16-2010, 04:13 AM
I have an EEG system I'd like to use to send data to vizard over our network.
EEG System --> BCI Software ---> Network (UDP) ---> Vizard

so, when i send to data from BCI software to vizard, the data lose is induced. my BCI software data sampling rate is 256hz,

how can i get all data from BCI software to Vizard ?

Jeff
12-16-2010, 05:18 PM
You could try using the Python socket module to receive the data.

If you can send data via the parallel port you could try getting that in Vizard using the vizparallel.read command.

psykoko
12-16-2010, 07:21 PM
HI.
i don't know how can use vizparallel.read .
where can i search this example ??

if possible, i want to example code.

psykoko
12-16-2010, 08:08 PM
attach my code
import viz
import vizmat
import vizinfo
import socket
import struct
viz.go()
viz.mouse.setVisible(viz.OFF)



#The maximum amount of data to receive at a time
MAX_DATA_SIZE = 1024

#The port to send/receive data on
PORT = 8000

#Get the name of this computer
COMPUTER_NAME = socket.gethostname()

#Get the IP address of this computer
COMPUTER_IP_ADDRESS = socket.gethostbyname('localhost')

#Create a socket to send data over
OutSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
OutSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

#Create a socket to receive data from
InSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
InSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
InSocket.bind(('', PORT))
InSocket.setblocking(0)
viz.directormode(viz.DIRECTOR_FAST)

def SendData(data):
OutSocket.sendto(data,(COMPUTER_IP_ADDRESS,PORT))

def ReceiveData():
try:
return InSocket.recvfrom(MAX_DATA_SIZE)
except:
pass

def onkeydown(key):
if key == ' ':
#Send data over the socket
SendData('hello there')

viz.callback(viz.KEYDOWN_EVENT,onkeydown)


def ontimer(num):
#Try to receive data from socket
data = ReceiveData()
if data:
udp = struct.unpack(">d", data[0][:8])[0]
right = open('c:\\new\\new.txt', 'a+')
right.write(str(udp)+'\n')
print 'Received Message:',udp

viz.callback(viz.TIMER_EVENT,ontimer)
viz.starttimer(0,0,viz.FOREVER)