gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] gzz/gfx/util disp.py


From: Janne V. Kujala
Subject: [Gzz-commits] gzz/gfx/util disp.py
Date: Tue, 04 Mar 2003 06:38:34 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Janne V. Kujala <address@hidden>        03/03/04 06:38:34

Modified files:
        gfx/util       : disp.py 

Log message:
        log trial results in a file

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/util/disp.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text

Patches:
Index: gzz/gfx/util/disp.py
diff -u gzz/gfx/util/disp.py:1.5 gzz/gfx/util/disp.py:1.6
--- gzz/gfx/util/disp.py:1.5    Tue Mar  4 06:10:25 2003
+++ gzz/gfx/util/disp.py        Tue Mar  4 06:38:33 2003
@@ -18,7 +18,20 @@
 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 # MA  02111-1307  USA
 # 
-# 
+#
+
+# A program for displaying images. Reads pairs of lines from the
+# file named in argv[1] and parses them to trials as follows:
+#   <filename> <min-time> <max-time> <list-of-keys>
+#   <trial description>
+# For each trial
+#   - shows the named picture centered on screen
+#   - waits for min-time 
+#   - waits until any key in the list is pressed
+#     or until max-time is reached
+#  - logs the elapsed time and the pressed key (if any)
+#    in the file named in argv[2] (default "disp.log")
+
 from __future__ import nested_scopes
 
 import sys
@@ -89,6 +102,15 @@
 starttime = 0
 mintime = 0
 toid = 0
+logfile = "disp.log"
+trialdesc = ""
+
+def log(data, time = None):
+    if time == None:
+        time = System.currentTimeMillis()
+    f = open(logfile, "a")
+    f.write(str(time) + " " + data)
+    f.close()
 
 class Bindings(AbstractBinder):
     def keystroke(self, key):
@@ -118,6 +140,9 @@
 
     trial = trials.pop(0)
     print "Starting trial:", trial
+
+    global trialdesc
+    trialdesc = trial["desc"]
     
     global keys, mintime
     keys = trial["keys"]
@@ -129,6 +154,8 @@
     global starttime
     starttime = System.currentTimeMillis()
 
+    log("Trial start %s" % trialdesc, time = starttime)
+
     print "Start time", starttime
     global toid
     if trial["max"] > 0:
@@ -144,8 +171,11 @@
 
     print "Trial ended:", time, key
 
+    log("Trial end %5d %s %s" % (time, key, trialdesc))
+
     if not nextTrial():
         print "End of exper"
+        System.exit(0)
 
 class Main(Runnable):
 
@@ -155,6 +185,10 @@
         w.setLocation(0,0,xs,ys)
         w.registerBinder(Bindings())
 
+        if len(sys.argv) >= 3 and sys.argv[2] != "":
+            global logfile
+            logfile = sys.argv[2]
+
         print "Reading trials"
         global trials
         trials = []
@@ -174,7 +208,7 @@
         f.close()
         print "Read", len(trials), "trials"
 
-        # Start
+        log("Exper start\n")
         nextTrial()
         
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]