Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

retrieve response time within trial to adjust ISI

Hi there,

Sorry for double posting this question, but it might be a particular issue related to collecting my response with mousetrap:

This must be something really straightforward, but I am stuck here. I have a trial that presents a canvas with visual response options and a sound file, both initialized by a mouse click on a start button. While listening to the sound, participants have to click on one of the responses to proceed. 

Each sound file has a certain length and I want participants to be able to give an early response if they want to but because I am also tracking their eye fixations, I do not want the canvas to proceed before the end of the sound file. I collect my mouse responses with the mousetrap plugin (interested in mouse trajectories). Apparently, the trajectories are not collected until the previous canvas/sound has finished, so I have to set the duration of canvas / sound = 0. 

My idea is to present a second canvas with a duration defined by the length of the sound file minus the response time of the mouse click. However, if I try to retrieve the [response_time] it spits out the RT of the previous trial. How can I access the response time of the just made response and incorporate it into calculating the duration of the following canvas? Any suggestions? Sorry if this is a silly question. Any help would be highly appreciated.




  • Hi Timo,

    The response time variable is being created by the mouse_response or keyboard_response item (whichever you are using). So if you would add the the second canvas after that item, it should use the current response time. Alternatively (and maybe even easier), you could just sample the current system time (clock.time()) right before the canvas starts and once again the response has been given, take the difference et voila! You'll have your response time.

    Hope this helps,


  • Thank you Eduard, but I am struggling big time.

    Just to be sure: I insert a inline script right after the canvas and audio is initiated that clocks the time:

    var.start = clock.time()

    I then insert another inline script after the response and before the intended spill-over canvas that clocks the time again and calculate the difference between the two timestamps, correct

    var.end = clock.time()

    var.start_end = var.end - var.start

    This should give me the time from start button click to response click. But it doesn't, the numbers are off and I have no clue what happens.

    (var.RT_self = self.get("response_time") doesn't make sense either)

    For sanity check, I printed the values of these variables on the following canvas.

  • Have you put the code in the run phase of the inline_script? Can you share your experiment here? (Or, if it is very complex, a simplified version?)

  • Somehow I cannot upload the file here:

  • One thing to do is to start recording eye data before taking the start time. Pygaze_start_recording takes about 300-400 ms to initialize. I don't think this causes delays but I usually start play the sounds before showing the image. Do these changes solve the issue? (They should)

    Aside of that, I don't know how exactly response times are calculated with the mousetrap plugin. Maybe @Pascal can help?


  • Does the logic of the script makes sense to you tho? None of the numbers make any sense to me. Even if you throw out the pygaze objects (or put it before taking the start time), the number remain weird...

  • Hi Timo,

    I think that I do not completely understand the procedure you want to implement, but maybe some general comments that might help:

    The response time is recorded by the mousetrap_response item in the variable response_time_[item_name] so should be able to use it directly without computing it yourself.

    As the response time is available only after the response is given, you can only use it in the run phase of your inline scripts.

    If you use a sketchpad to display the response time / time left you calculated, it will display the response time from the last trial, as the sketchpad is prepared before the trial is run. If you want to display the value of the current trial, you would have to use a feedback instead of a sketchpad item. See prepare-run distinction in the OpenSesame documentation:

    I think that you can still change the presentation duration of a sketchpad item in the run phase (I think this behavior might have changed between different versions of OpenSesame, but I am not sure). In general, I think that it would still be best practice to use a feedback item if you want to change the display duration during the trial.

    Mousetrap_response items do allow you to specify a timeout, after which they automatically continue, which might be of interest to you. You could set the number of buttons to 0 for a mousetrap_response item and specify a timeout value, to just collect mouse movement for a specified amount of time without the user being able to give a response. Afterwards, you could insert a second mousetrap_response item to collect the response.

    Does this help in some way?



  • Hi Pascal,

    there is a bunch of useful information in your response, I am sure it will help us figure out who to circumvent our problem. Thank you!



Sign In or Register to comment.