Hello, I am running a pupillometry paradigm and want to mark timestamps for when I have images on (the trial images, fixation, mask etc). I especially want to have a idea of when the fixation image is on, so I am trying to write out the message the same way I do for the mask images which is like:
if Mask.status == STARTED: el_tracker.sendMessage('Mask.running %s' % maskClock.getTime())
. However, for some reason the fixation timestamps don’t end up on my sample message column when I export the data (my code is below). When I print them, they print just fine, so I don’t think it’s a clock issue. I think I might be missing something small and would really appreciate another set of eyes on this!
Best,
Bahar
`
------Prepare to start Routine “fixation”-------
continueRoutine = True
routineTimer.add(2.000000)
# update component parameters for each repeat
# keep track of which components have finished
fixationComponents = [fixation]
for thisComponent in fixationComponents:
thisComponent.tStart = None
thisComponent.tStop = None
thisComponent.tStartRefresh = None
thisComponent.tStopRefresh = None
if hasattr(thisComponent, 'status'):
thisComponent.status = NOT_STARTED
# reset timers
t = 0
_timeToFirstFrame = win.getFutureFlipTime(clock="now")
fixationClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip
frameN = -1
# -------Run Routine "fixation"-------
while continueRoutine and routineTimer.getTime() > 0:
# get current time
t = fixationClock.getTime()
tThisFlip = win.getFutureFlipTime(clock=fixationClock)
tThisFlipGlobal = win.getFutureFlipTime(clock=None)
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame
# *"fixation"* updates
if fixation.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
# keep track of start time/frame for later
fixation.frameNStart = frameN # exact frame index
fixation.tStart = t # local t and not account for scr refresh
fixation.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(fixation, 'tStartRefresh') # time at next scr refresh
fixation.setAutoDraw(True)
if fixation.status == STARTED:
el_tracker.sendMessage('fixation.running %s' % fixationClock.getTime())
print(fixationClock.getTime())
# is it time to stop? (based on global clock, using actual start)
if tThisFlipGlobal > fixation.tStartRefresh + 1.5-frameTolerance:
# keep track of stop time/frame for later
fixation.tStop = t # not accounting for scr refresh
fixation.frameNStop = frameN # exact frame index
win.timeOnFlip(fixation, 'tStopRefresh') # time at next scr refresh
fixation.setAutoDraw(False)
# check for quit (typically the Esc key)
if endExpNow or defaultKeyboard.getKeys(keyList=["escape"]):
thisExp.saveAsWideText(filename+'.csv', delim=',')
thisExp.saveAsPickle(filename)
logging.flush()
terminate_task()
core.quit()
# check if all components have finished
if not continueRoutine: # a component has requested a forced-end of Routine
break
continueRoutine = False # will revert to True if at least one component still running
for thisComponent in fixationComponents:
if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
continueRoutine = True
break # at least one component has not yet finished
# refresh the screen
if continueRoutine: # don't flip if this routine is over or we'll get a blank screen
win.flip()
# -------Ending Routine "fixation"-------
for thisComponent in fixationComponents:
if hasattr(thisComponent, "setAutoDraw"):
thisComponent.setAutoDraw(False)
EncodingTrials.addData('fixation.started', fixation.tStartRefresh)
EncodingTrials.addData('fixation.stopped', fixation.tStopRefresh)
el_tracker.sendMessage('fixationEnd %s' % fixationClock.getTime())`