Send marker (insert codeline) when stimulus begins

Hi everyone! We need to insert the line

socket.annotation('130', 0.1)

into beginning of each stimulus presentation to send its marker to eyetracker.

In current routine there are 3 stimuli that start in different time.

I suppose the codeline could be inserted into

if instruction_text.status == STARTED:

Automatically created code:

while continueRoutine:
# get current time
t = instructionClock.getTime()
tThisFlip = win.getFutureFlipTime(clock=instructionClock)
tThisFlipGlobal = win.getFutureFlipTime(clock=None)
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame

# *instruction_text* updates
if instruction_text.status == NOT_STARTED and tThisFlip >= 1-frameTolerance:
# keep track of start time/frame for later
instruction_text.frameNStart = frameN # exact frame index
instruction_text.tStart = t # local t and not account for scr refresh
instruction_text.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(instruction_text, 'tStartRefresh') # time at next scr refresh
instruction_text.setAutoDraw(True)
if instruction_text.status == STARTED:
# is it time to stop? (based on global clock, using actual start)
if tThisFlipGlobal > instruction_text.tStartRefresh + 2-frameTolerance:
# keep track of stop time/frame for later
instruction_text.tStop = t # not accounting for scr refresh
instruction_text.frameNStop = frameN # exact frame index
win.timeOnFlip(instruction_text, 'tStopRefresh') # time at next scr refresh
instruction_text.setAutoDraw(False)
 

Probably you could suggest any other ideas? To check a time of stimuli presentation or anything else? Thank you in advance!

I think you’re on the right lines there. You would insert a code component and check every frame whether your stimulus has started.

#Every Frame

if *your_stimuli*.status == STARTED:
     annotation.socket(....)
1 Like