Description of the problem: Hello, I saved the start and end of a stimulus and recorded the difference between them as the actual stimulus presentation duration. I got the results well in my local computer but when I ran the study online the data for that difference were NaN for all my stimuli.
I need this info as I’m feeding the participants’ previous responses as stimuli duration in the following trials. So I actually don’t have a pre-set stimulus duration, it’s critical for me to see what they were presented with.
(I only looked at one copy of your routine – for future reference it’s easier to make edits to an experiment if you use concentric loops for trial variations).
I don’t know if you can access rt in this way. I’ve taken to using t (time since start of the routine). Have you tried using console.log(varname); to see if the variables are behaving as expected?
@wakecarter OK, I see what you mean now. I realized that translation to js did not take the definition of polygon.tStop from python. And so the result was NaN. I added that as well as polygon.frameNStop, but then I realized the frameN in js is only the frame number, so it did not take into acount the interframe interval. Hence the data that I got was a frame number difference rather than milliseconds.
Below I share the relevant python and js code, could you help me how I can make the js calculate stim dur with frameN * interframe interval?
Python:
if polygon.status == NOT_STARTED and tThisFlip >= fix-frameTolerance:
# keep track of start time/frame for later
polygon.frameNStart = frameN # exact frame index
polygon.tStart = t # local t and not account for scr refresh
polygon.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(polygon, 'tStartRefresh') # time at next scr refresh
polygon.setAutoDraw(True)
if polygon.status == STARTED:
# is it time to stop? (based on global clock, using actual start)
if tThisFlipGlobal > polygon.tStartRefresh + seed1-frameTolerance:
# keep track of stop time/frame for later
polygon.tStop = t # not accounting for scr refresh
polygon.frameNStop = frameN # exact frame index
win.timeOnFlip(polygon, 'tStopRefresh') # time at next scr refresh
polygon.setAutoDraw(False)
JS:
if (t >= fix && polygon.status === PsychoJS.Status.NOT_STARTED) {
// keep track of start time/frame for later
polygon.tStart = t; // (not accounting for frame time here)
polygon.frameNStart = frameN; // exact frame index
polygon.setAutoDraw(true);
}
frameRemains = fix + seed1 - psychoJS.window.monitorFramePeriod * 0.75; // most of one frame period left
if (polygon.status === PsychoJS.Status.STARTED && t >= frameRemains) {
// keep track of start time/frame for later
polygon.tStop = t; // (not accounting for frame time here)
polygon.frameNStop = frameN; // exact frame index
polygon.setAutoDraw(false);
}
I had to delete the whole project cause I made corrections in gitlab in conjunction with psychopy and it stopped working.
I added the below code with a code component in each frame tab because tStop was not defined in js by default:
if (polygon.status === PsychoJS.Status.STARTED && t >= frameRemains) {
polygon.tStop = t; (// not accounting for frame time here)
polygon.frameNStop = frameN; // exact frame index
}
But I’m getting the error - "Unexpected token ‘;’ ", and if delete this then I get "Unexpected token “}” "