# refresh the screen
    if continueRoutine:  # don't flip if this routine is over or we'll get a blank screen
        win.flip()

# -------Ending Routine "practice"-------
for thisComponent in practiceComponents:
    if hasattr(thisComponent, "setAutoDraw"):
        thisComponent.setAutoDraw(False)

# >>> iohub Custom Code
tablet.reporting = False
io.clearEvents()
io.sendMessageEvent("End Pen Practice Period")

pen_pos_stim.clear()
pen_traces_stim.clear()
pen_traces_stim.setAutoDraw(False)
pen_pos_stim.setAutoDraw(False)

# <<< iohub Custom Code


# the Routine "practice" was not non-slip safe, so reset the non-slip timer
routineTimer.reset()

# set up handler to look after randomisation of conditions etc
trials = data.TrialHandler(
    nReps=1.0,
    method="random",
    extraInfo=expInfo,
    originPath=-1,