Advertisement
Guest User

Catyre's Code

a guest
Jun 28th, 2022
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.26 KB | None | 0 0
  1.         _timeToFirstFrame = win.getFutureFlipTime(clock="now")
  2.         trialClock.reset(-_timeToFirstFrame) # t0 is time of first possible fli
  3.  
  4.         streams = reposition(streams, level)  # Reposition each stimuli to the correct place
  5.  
  6.         # Iterate over the letters in each stream and display them appropriately
  7.         for letters, T_nearby in trial.stream:
  8.             # get current time
  9.             tThisFlip = win.getFutureFlipTime(clock=trialClock)
  10.             tThisFlipGlobal = win.getFutureFlipTime(clock=None)
  11.  
  12.             # Check if there is a target in the stream
  13.             T_in_stream = "T" in letters
  14.  
  15.             if heads_up.status == NOT_STARTED and tThisFlip >= 0.0 - frame_tolerance:
  16.                 heads_up.status = STARTED
  17.                 heads_up.tStartRefresh = tThisFlipGlobal
  18.                 heads_up.tStopRefresh = FOREVER # Arbitrary large number, will be adjusted when the conditions are met
  19.                 win.timeOnFlip(heads_up, "tStartRefresh")
  20.                 heads_up.setAutoDraw(True)
  21.             if heads_up.status == STARTED:
  22.                 if tThisFlipGlobal > heads_up.tStartRefresh + 1 - frame_tolerance:
  23.                     heads_up.status = FINISHED
  24.                     heads_up.tStopRefresh = tThisFlipGlobal
  25.                     win.timeOnFlip(heads_up, "tStopRefresh")
  26.                     heads_up.setAutoDraw(False)
  27.  
  28.             # Display fixation
  29.             if fixation.status == NOT_STARTED and trial.rsvp_stream_count > 1 and tThisFlipGlobal >= heads_up.tStopRefresh - frame_tolerance:
  30.                 fixation.status = STARTED
  31.                 fixation.tStartRefresh = tThisFlipGlobal
  32.                 fixation.setAutoDraw(True)
  33.                 win.timeOnFlip(fixation, "tStartRefresh")
  34.             if fixation.status == STARTED:
  35.                 if tThisFlipGlobal > fixation.tStartRefresh + 100 - frame_tolerance:
  36.                     fixation.status = FINISHED
  37.                     win.timeOnFlip(fixation, "tStopRefresh")
  38.                     fixation.setAutoDraw(False)    
  39.  
  40.             # Take every letter and assign it to a stimuli in streams.  Then display the stimulus
  41.             for j in range(len(letters)):
  42.                 # Take the jth stream and assign the jth letter to it
  43.                 stream = streams[j]
  44.                 stream.text = letters[j]
  45.                
  46.                 if stream.status == NOT_STARTED and tThisFlip >= heads_up.tStopRefresh - frame_tolerance:
  47.                     stream.status = STARTED
  48.                     stream.tStartRefresh = tThisFlipGlobal
  49.                     win.timeOnFlip(stream, "tStartRefresh")
  50.                     stream.setAutoDraw(True)
  51.                 if stream.status == STARTED:
  52.                     if tThisFlipGlobal > stream.tStartRefresh + 0.4 - frame_tolerance: # 24 frames = 400 ms
  53.                         stream.status = FINISHED
  54.                         win.timeOnFlip(stream, "tStopRefresh")
  55.                         stream.setAutoDraw(False)
  56.  
  57.             if continueRoutine:
  58.                 #core.wait(0.4)
  59.                 win.flip()
  60.  
  61.         # Reset stream statuses to NOT_STARTED so they will still display on the next run-through
  62.         for stream in streams:
  63.             if hasattr(stream, 'status'):
  64.                 stream.status = NOT_STARTED
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement