Advertisement
smathot

PyGaze benchmark

Jun 18th, 2013
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.11 KB | None | 0 0
  1. # example script for using PyGaze
  2.  
  3. # # # # #
  4. # importing the relevant libraries
  5. import random
  6. from pygaze import libscreen, libtime, liblog, defaults
  7.  
  8. # # # # #
  9. # setup the experiment
  10.  
  11. # start timing
  12. libtime.expstart()
  13.  
  14. # create display object
  15. disp = libscreen.Display()
  16.  
  17. # create logfile object
  18. log = liblog.Logfile()
  19. log.write(["count", "rt"])
  20.  
  21. # create screens
  22. x = 0
  23. y = 0
  24. w = defaults.DISPSIZE[0]
  25. h = defaults.DISPSIZE[1]
  26. black = libscreen.Screen()
  27. black.draw_rect(colour=(0,0,0), x=x, y=y, w=w, h=h, fill=True)
  28. white = libscreen.Screen()
  29. white.draw_rect(colour=(255,255,255), x=x, y=y, w=w, h=h, fill=True)
  30.  
  31. # # # # #
  32. # run the experiment
  33.  
  34. # run 20 trials
  35. for count in range(1,5):
  36.     # prepare trial
  37.     trialtype = random.choice(['left','right'])
  38.    
  39.     # present fixation
  40.     disp.fill(black)
  41.     disp.show()
  42.     libtime.pause(500)
  43.        
  44.     disp.fill(white)
  45.     t1 = disp.show()
  46.     libtime.pause(500)
  47.     t2 = libtime.get_time()
  48.    
  49.     rt = t2 - t1
  50.    
  51.     # log stuff
  52.     log.write([count, rt])
  53.  
  54. # end the experiment
  55. log.close()
  56. disp.close()
  57. libtime.expend()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement