OS (e.g. Win10): Windows 10 PsychoPy version (e.g. 1.84.x): 2020.2.10
Hi!
I want to know the duration for which a stimulus was presented in my experiment. I set the time on 4 seconds, but participants are allowed to be faster than that by continuing the experiment before the 4 seconds are ofer.
In order to know the time they could have looked at the stimuli, I want to know the onset/offset times (which I asked for in the builder view > image properties > data).
In my offline (i.e. psychopy on desktop) csv file, I get two colomns:
prpaint.started ā with values like 2512985889997790 and 27450827699969500
prpaint.stopped ā None (So I assume something already goes wrong here?)
When I try my experiment online, I get neither.
My question is therefore: How do I get the image presentation duration in my csv file in my online study?
I tried adding this to the Py and JS End Routine Code components in the same routine as I presented the image.
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).
It needs to be in the āend routineā tab, as at the beginning of the routine, those values havenāt yet been measured (i.e. the stimulus hasnāt appeared at the time that code section runs).