Save onset offset time 2020.2.10 online

Hi There,

You are correct that start and stop times are stored locally but not online. To save a stims start time online you would add a code component, set code type to JS and use:

// save the onset times of stimuli
thisExp.addData('stimName.tStart', stimName.tStart)

// save the onset times of stimuli (taking into account frames
thisExp.addData('stimName.frameNStart', stimName.frameNStart)

Saving offsets is a little tricker. What is stopping your stimulus from being presented? is it a keyboard response that ends the routine? in which case the response time from that key response would serve as your end time) is it a time when the stimulus is moved offscreen by something else? What you would need is a component something like this (code type set to auto → JS):

if myStim.pos[0] == -300:# checking when a stims x coordinate is -300 for example
    stopTime = myRoutineNameClock.getTime()

thisExp.addData('stopTime', stopTime)

** note only if using a pre 2021.2 version of psychopy** Remember, as per the crib sheet, PsychoPy Python to Javascript crib sheet - Google Docs to add a code component to the very start of your experiment, code type JS, and add thisExp=psychoJS.experiment; (so that the javascript version of your experiment knows what you are referring to when you save data to thisExp).

Hope this is helpful,
Becca

2 Likes