Data column appears NaN in pavlovia results

URL of experiment: https://gitlab.pavlovia.org/pinartoptas/timingpriors

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.

Any help will be appreciated.
Thanks!

So the critical line appears to be (in Python)

reproduction5 = _key_resp_5_allKeys[-1].rt - _key_resp_5_allKeys[-2].rt

(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?

I could, well at least in the Builder. I ran it a few times and it did save the time in between two keypresses correctly with this code.

But I’m not really interested in that, how can I use t to get the time of stimulus presentation?

No, I have not. Could you please direct me to a link maybe? Cause I really don’t know how to do this.

Thanks a lot!

I’m on my phone but you could search for console in my crib sheet.

You want the time between two events which can be calculated from the time of those two events from the start of the routine.

@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);
    }

Hi again,

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 “}” "

Why this might be happening?

You have (// stuff ) when I think you want //( stuff )

Oops. Didn’t notice it. Thanks!