calculating the exact duration for which a stimulus was displayed

399 views
Skip to first unread message

arnold....@gmail.com

unread,
Jun 30, 2018, 5:11:15 AM6/30/18
to jsPsych
Hi Josh and community,

I have 2 questions regarding the exact timing of the stimuli display and RTs.

1. I noticed that there is a difference between the RT that jsPsych recorded and the number that I get if I subtract the time_elapsed value of the previous trial from the time_elapsed value of the current trial. What I get from calculating based on time_elapsed is always a bit longer than the RT given by jsPsych. During the first trials it is only 1-3 ms difference, but by trial 200 it becomes 7-10 ms difference.
I was wondering, what causes this difference and why does it increase over time?
Looking into the jsPsych code, I see that rt is actually calculated by subtacting start_time from key_time. Does it mean there is some lag before display of the next trial? So then the RT given by jsPsych is to be trusted more?

2. I actually ran a priming study with jsPsych. I set the text that served as a prime to be displayed for 83 ms. Now I would like to calculate the actual duration of the prime stimulus for each participant so that I know how long an average delay was. Can I do that by simply subtracting the time_elapsed from previous trial like I described for RTs?
Again, here too I see that the lag increases by some 8-10 ms by trial 200 or so.


Thank you very much for your answers beforehand!


Arnold

Josh de Leeuw

unread,
Jul 11, 2018, 11:56:34 PM7/11/18
to arnold....@gmail.com, jsPsych
Hi Arnold,

I would trust the RT more than the time elapsed. Even though the overhead of starting and stopping a trial is small, it's nonzero. A few ms difference doesn't surprise me.

Actual display durations is tougher. I think time_elapsed will be a reasonable approximation and might correlate with actual display time, but I wouldn't use it as a definitive measure. Getting actual display times from JavaScript isn't possible, because there is no API that gives access to the actual paint time on the monitor. 

To get actual display times, you need to stick a photocell on the monitor and measure the changes in brightness. We are actually working on some significant improvements to the code that jsPsych uses to time display durations, and are doing exactly this to validate the new approach. We also measured the accuracy of jsPsych's current display code, and generally found that somewhere around 70% of the trials will have the exact intended display duration (assuming the duration is a multiple of the frame rate) and the remaining 30% will be +/- one frame, and very rarely two frames.

Cheers,
Josh

--
You received this message because you are subscribed to the Google Groups "jsPsych" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jspsych+u...@googlegroups.com.
To post to this group, send email to jsp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jspsych/80fd1d64-86d4-40aa-bec6-e790db8ff0f2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

arnold....@gmail.com

unread,
Jul 12, 2018, 5:38:15 AM7/12/18
to jsPsych
Hi Josh,

Thank you for such a detailed answer! It is very helpful!
Just one last thing: so is it the case then that the difference increases in later trials because the starting and stopping times accumulate?


Arnold

Josh de Leeuw

unread,
Jul 12, 2018, 9:34:14 AM7/12/18
to arnold....@gmail.com, jsPsych
I'm not sure why the time is longer later in the experiment. The only explanation that comes to mind is that there is some kind of small memory accumulation over time, but I don't think that is particularly likely. Sorry I don't have a better answer at the moment!

arnold....@gmail.com

unread,
Jul 24, 2018, 9:44:37 AM7/24/18
to jsPsych
Hi Josh,

Thank you for your answers so far! I was thinking about this question further and have another idea. Could this increasing difference in RT vs. time_elapsed be due to the fact that in my experiment data was loaded as a .csv file to a web-server after each trial? Because the amount of data to be uploaded increased with every trial, it needed more time to be loaded. So the time_elapsed did not account for this time, whereas RT did?

In general, does the experiment pause running while data is being loaded into a web-server? Or is data uploading something that happens completely independently?

Arnold

Josh de Leeuw

unread,
Jul 24, 2018, 10:03:30 AM7/24/18
to arnold....@gmail.com, jsPsych
I think that's possible. The uploading generally happens independent of the experiment, if you are using some kind of async call like an XMLHttpRequest. But there might be some time involved in the conversion to .CSV format on the jsPsych side and that would add a small delay.

cslo...@gmail.com

unread,
Jun 18, 2020, 8:07:22 AM6/18/20
to jsPsych
Hi Josh,

I have an extension on this question...

In my experiment, participants sometimes respond with two key presses. I have done this by using two consecutive 'trials' (timeline events) and then concatenating the two responses before comparing this to the 'correct response' to determine the accuracy of the response. My experiment involves putting an 18x18 grid of small images on the screen which apparently takes ~60 ms to perform (the difference between 'rt' and 'elapsed time' calculation mentioned by Arnold).

When I'm calculating the actual time it took a participant to make the full response would I get a more accurate measure by (a) summing the two rts, (b) rt1 + rt2 + elapsed time difference between the two trials, (c) using the start_time and key_time measures from the relevant trials, or (c) some other method?

Any advice appreciated,

Cai


On Thursday, 12 July 2018 04:56:34 UTC+1, Josh de Leeuw wrote:
Hi Arnold,

I would trust the RT more than the time elapsed. Even though the overhead of starting and stopping a trial is small, it's nonzero. A few ms difference doesn't surprise me.

Actual display durations is tougher. I think time_elapsed will be a reasonable approximation and might correlate with actual display time, but I wouldn't use it as a definitive measure. Getting actual display times from JavaScript isn't possible, because there is no API that gives access to the actual paint time on the monitor. 

To get actual display times, you need to stick a photocell on the monitor and measure the changes in brightness. We are actually working on some significant improvements to the code that jsPsych uses to time display durations, and are doing exactly this to validate the new approach. We also measured the accuracy of jsPsych's current display code, and generally found that somewhere around 70% of the trials will have the exact intended display duration (assuming the duration is a multiple of the frame rate) and the remaining 30% will be +/- one frame, and very rarely two frames.

Cheers,
Josh

On Sat, Jun 30, 2018 at 5:11 AM <arnold...@gmail.com> wrote:
Hi Josh and community,

I have 2 questions regarding the exact timing of the stimuli display and RTs.

1. I noticed that there is a difference between the RT that jsPsych recorded and the number that I get if I subtract the time_elapsed value of the previous trial from the time_elapsed value of the current trial. What I get from calculating based on time_elapsed is always a bit longer than the RT given by jsPsych. During the first trials it is only 1-3 ms difference, but by trial 200 it becomes 7-10 ms difference.
I was wondering, what causes this difference and why does it increase over time?
Looking into the jsPsych code, I see that rt is actually calculated by subtacting start_time from key_time. Does it mean there is some lag before display of the next trial? So then the RT given by jsPsych is to be trusted more?

2. I actually ran a priming study with jsPsych. I set the text that served as a prime to be displayed for 83 ms. Now I would like to calculate the actual duration of the prime stimulus for each participant so that I know how long an average delay was. Can I do that by simply subtracting the time_elapsed from previous trial like I described for RTs?
Again, here too I see that the lag increases by some 8-10 ms by trial 200 or so.


Thank you very much for your answers beforehand!


Arnold

--
You received this message because you are subscribed to the Google Groups "jsPsych" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jsp...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages