Guest User

Untitled

a guest
Mar 18th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. from psychopy import visual
  2. from psychopy import core
  3. from psychopy import event
  4.  
  5. win = visual.Window(color='#000000',
  6. fullscr=True,
  7. allowGUI=False,
  8. winType='pyglet',
  9. units='deg')
  10.  
  11. ####### BEGINNING OF THE EXPERIMENT ###########
  12. from pypixxlib.propixx import PROPixxCTRL
  13.  
  14. pxctrl = PROPixxCTRL()
  15. px_out = pxctrl.dout
  16.  
  17. def trigger(bit, t):
  18. """
  19. bit - number between 0 and 255
  20. t - duration of trigger
  21. triggers ProPixxControl
  22. returns trigger time, start and end of the function
  23. """
  24. start = core.getTime() # start of the function
  25. wait = core.StaticPeriod()
  26. px_out.setBitValue(value=bit, bit_mask=0xFF)
  27. pxctrl.updateRegisterCache()
  28. wait.start(t)
  29. trig = core.getTime()
  30. wait.complete()
  31. px_out.setBitValue(value=0, bit_mask=0xFF)
  32. pxctrl.updateRegisterCache()
  33. end = core.getTime() # end of the function
  34. return (trig, start, end) # if start and end time removed 'return trig'
  35. ###############################################
  36.  
  37. # bt = run['condition_nr'][row] + 1 # zero is reserved for zeroing the channels
  38. # stim1_tr, stim1_st, stim1_end = trigger(bt, 0.005)
  39.  
  40. ########### TRIGGER IN EXP ####################
  41. trigger(0, 0.005) # zero out all the channels
  42. while True:
  43. if event.getKeys(keyList=['space']):
  44. trigger_time, func_start, func_end = trigger(1, 0.005) # TRIGGER, save somewhere the data from those variables
  45.  
  46. if event.getKeys(keyList=['q']):
  47. break
  48. trigger(0, 0.005) # zero out all the channels
  49. ###############################################
  50.  
  51. win.close()
  52. core.quit()
Add Comment
Please, Sign In to add comment