#1
|
|||
|
|||
Flagging the Data
So I'm collecting position data through a flock of birds and writing the data to text files on the computer. I have:
Code:
flock1 = viz.add('flockofbirds.dls') flock2 = viz.add('flockofbirds.dls') flock3 = viz.add('flockofbirds.dls') flock4 = viz.add('flockofbirds.dls') flock1.command(6) flock2.command(6) flock3.command(6) flock4.command(6) tracking_data = open('prism_ve data/headdata_'+ str(Subnum) + " " + str(Trial) + '.txt', 'a') tracking_data2 = open('prism_ve data/hipdata_'+ str(Subnum) + " " + str(Trial) + '.txt', 'a') tracking_data3 = open('prism_ve data/kneedata_'+ str(Subnum) + " " + str(Trial) + '.txt', 'a') tracking_data4 = open('prism_ve data/ankledata_'+ str(Subnum) + " " + str(Trial) + '.txt', 'a') #""" flags = ['A', 'H', 'I', 'M', 'O', 'T', 'U', 'V', 'W', 'X', 'Y'] flagIndex = 0 def WriteFlag(): global flags, flagIndex letter = flags[flagIndex] flagIndex = flagIndex + 1 tracking_data.write('*** Reached point ' + letter + 'in', clock(), 'seconds' + '\n') tracking_data2.write('*** Reached point ' + letter + 'in', clock(), 'seconds' + '\n') tracking_data3.write('*** Reached point ' + letter + 'in', clock(), 'seconds' + '\n') tracking_data4.write('*** Reached point ' + letter + 'in', clock(), 'seconds' + '\n') vizact.onkeydown('f',WriteFlag) #('*** Reached point ' + letter + '\n'+ "Elapsed time =", clock(), " seconds") def WriteFlag2(): tracking_data.write('*** Time of Trial =', clock(), "seconds" + '\n') tracking_data2.write('*** Time of Trial =', clock(), "seconds"+ '\n') tracking_data3.write('*** Time of Trial =', clock(), "seconds"+ '\n') tracking_data4.write('*** Time of Trial =', clock(), "seconds"+ '\n') vizact.onkeydown('w',WriteFlag2) Code:
def onkeydown(key): if key == 'q': viz.quit() print "Time of Trial =", clock(), "seconds" # WriteFlag2() viz.callback(viz.KEYDOWN_EVENT,onkeydown) So when I run my script I get this error: raceback (most recent call last): File "C:\Program Files\Vizard25\vizact.py", line 1981, in __onkeydown item.call() File "C:\Program Files\Vizard25\vizact.py", line 1897, in call _paramargs_(self.func,0)(*(_paramargs_(self.args,0 ))) File "Prism_VE_Updated_Maze_7_BASELINE.py", line 152, in WriteFlag tracking_data.write('*** Reached point ' + letter + 'in', clock(), 'seconds' + '\n') TypeError: function takes exactly 1 argument (3 given) Traceback (most recent call last): File "C:\Program Files\Vizard25\vizact.py", line 1981, in __onkeydown item.call() File "C:\Program Files\Vizard25\vizact.py", line 1897, in call _paramargs_(self.func,0)(*(_paramargs_(self.args,0 ))) File "Prism_VE_Updated_Maze_7_BASELINE.py", line 162, in WriteFlag2 tracking_data.write('*** Time of Trial =', clock(), "seconds" + '\n') TypeError: function takes exactly 1 argument (3 given) And I have no idea why it thinks I'm trying to give it 3 arguments. If I change the WriteFlag function to: Code:
flags = ['A', 'H', 'I', 'M', 'O', 'T', 'U', 'V', 'W', 'X', 'Y'] flagIndex = 0 def WriteFlag(): global flags, flagIndex letter = flags[flagIndex] flagIndex = flagIndex + 1 tracking_data.write('*** Reached point ' + letter + '\n') tracking_data2.write('*** Reached point ' + letter + '\n') tracking_data3.write('*** Reached point ' + letter + '\n') tracking_data4.write('*** Reached point ' + letter + '\n') vizact.onkeydown('f',WriteFlag) I would love to be able to press "f" and get which letter was reached and at what time it was reached and I would like to know how to make it so that when I press "q" to quit the program that the time at that point could be written to the file as well. Last edited by Elittdogg; 04-10-2008 at 02:04 PM. |
Thread Tools | |
Display Modes | Rate This Thread |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Flock of Birds recognized, but no data sent | sjroorda | Vizard | 9 | 03-01-2016 09:48 PM |
data glove navigation | arielasso | Vizard | 6 | 10-24-2007 03:15 PM |
Data Files | betancourtb82 | Vizard | 6 | 05-04-2006 03:43 PM |
Get position data in an own little program | Researcher | Precision Position Tracker (PPT) | 2 | 02-01-2006 03:55 AM |
tracking using quaternarion data | jfreeman | Vizard | 2 | 06-01-2005 09:48 AM |