Advertisement
Guest User

diff libeyelink.py

a guest
Feb 7th, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.48 KB | None | 0 0
  1. 26a27
  2. > import openexp.exceptions
  3. 76c77
  4. <
  5. ---
  6. >       experiment.eyelink_esc_pressed = False
  7. 311a313
  8. >       self.experiment.eyelink_esc_pressed = False
  9. 321c323,324
  10. <       while True:
  11. ---
  12. >       # 'silly loop, it should be left out:'
  13. >       # while True:
  14. 326c329,330
  15. <               error = pylink.getEYELINK().doDriftCorrect(pos[0], pos[1], 0, 1)
  16. ---
  17. >           print 'attempting drift correct...'
  18. >           error = pylink.getEYELINK().doDriftCorrect(pos[0], pos[1], 0, 0)
  19. 330a335
  20. >               # TODO "...escape or q pressed" ?
  21. 333c338
  22. <           except:
  23. ---
  24. >       except Exception, e:
  25. 399c404,412
  26. <           if my_keyboard.get_key()[0] != None:
  27. ---
  28. >           try:
  29. >               key,time = my_keyboard.get_key()
  30. >           except:
  31. >               # if escape key pressed:
  32. >               self.experiment.eyelink_esc_pressed = True
  33. >               self.recording = False
  34. >               return False
  35. >           else:
  36. >               if key != None: # i.e. 'q' was pressed
  37. 403a417
  38. >
  39. 486d499
  40. <
  41. 661d673
  42. <
  43. 692d703
  44. <
  45. 737a749,780
  46. >   def confirm_abort_experiment(self):
  47. >       """
  48. >       Asks for confirmation before aborting the experiment.
  49. >       Displays a confirmation screen, collects the response, and acts accordingly
  50. >
  51. >       Raises a response_error upon confirmation
  52. >
  53. >       """
  54. >       # Display the confirmation screen
  55. >       conf_canvas = canvas(self.experiment)
  56. >       conf_kb = keyboard(self.experiment, timeout = None)
  57. >       yc = conf_canvas.ycenter()
  58. >       ld = 40
  59. >       conf_canvas.clear()
  60. >       conf_canvas.text("Really abort experiment?", y = yc - 3 * ld)
  61. >       conf_canvas.text("Hit 'Y' to abort, ", y = yc - 0.5 * ld)
  62. >       conf_canvas.text("Hit any other key or wait 5s to go to setup, ", y = yc + 0.5 * ld)
  63. >       conf_canvas.show()
  64. >
  65. >       # process the response:
  66. >       try:
  67. >           key, time = conf_kb.get_key(timeout = 5000)
  68. >       except:
  69. >           return False
  70. >
  71. >       # if confirmation, close experiment
  72. >       if key == 'y':
  73. >           raise openexp.exceptions.response_error( \
  74. >                           "The experiment was aborted")
  75. >       else:
  76. >           return False
  77. >
  78. 758d800
  79. <
  80. 957a1000
  81. >       self.experiment.eyelink_esc_pressed = False
  82. 1105c1148,1150
  83. <           _key, time = self.my_keyboard.get_key()
  84. ---
  85. >           key, time = self.my_keyboard.get_key()
  86. >       except openexp.exceptions.response_error:
  87. >           key = 'escape'
  88. 1109,1114d1153
  89. <       if _key == None:
  90. <           return None
  91. <
  92. <       ky = []
  93. <       key = self.my_keyboard.to_chr(_key)
  94. <
  95. 1138a1178,1181
  96. >       elif key == "escape": # escape does the same as 'q', but also marks esc_pressed
  97. >           self.experiment.eyelink_esc_pressed = True
  98. >           keycode = pylink.ESC_KEY
  99. >           self.state = None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement