Advertisement
smathot

OpenSesame non-slip timing

Jan 27th, 2013
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.69 KB | None | 0 0
  1. # Specify how long you want the trial the last. Make sure that trials do not last
  2. # longer!
  3. trial_duration = 3000
  4.  
  5. # Get a trial id
  6. trial_id = self.get_check('trial_id', default=0)
  7.  
  8. # For the first trial, just note the time
  9. if trial_id == 0:
  10.     exp.set('first_trial_timestamp', self.time())
  11.     time_to_pad = 0
  12.    
  13. # For the other trials, wait until the the trial should start, based on the time
  14. # of the first trial and the trial duration
  15. else:
  16.     time_to_pad = self.get('first_trial_timestamp') + trial_id * trial_duration - self.time()
  17.     if time_to_pad > 0:
  18.         self.sleep(time_to_pad)
  19.        
  20. # Remember the trial id and padding time
  21. exp.set('trial_id', trial_id+1)
  22. exp.set('time_to_pad', time_to_pad)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement