Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. from psychopy import iohub, event, visual, core
  2. import logging
  3. import datetime
  4.  
  5. io = iohub.launchHubServer()
  6. keyboard = io.devices.keyboard
  7.  
  8. logging.basicConfig(filename="experiment.txt", level=logging.INFO)
  9.  
  10. logging.info("NEW EXPERIMETNT. Start time: {dt}".format(dt=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
  11. logging.info("")
  12.  
  13.  
  14. win = visual.Window([100,100],color=(1,1,1), colorSpace='rgb',)
  15. myMouse = event.Mouse(win=win)
  16.  
  17.  
  18. while not myMouse.getPressed()[0]:
  19.     pass
  20. while myMouse.getPressed()[0]:
  21.     pass
  22.  
  23. start_time = core.getTime()
  24.  
  25. while True:
  26.     presses = [press for press in keyboard.waitForKeys() if press.type == 'KEYBOARD_PRESS' and press.key == ' ']
  27.     if presses:
  28.         diff = presses[-1].time - start_time
  29.         if diff > 0:
  30.             logging.info(str(diff))
  31.             break
  32.  
  33. logging.info("")
  34. logging.info("")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement