[solved] vary a sketchpad duration according to the previous response time
I want a sketchpad duration to vary according to a previous RT. Setting the duration '2000-[response_time]' does not work it seems because "-" is not recognized as an operator. How can I do this?
Comments
Hi,
The 'duration' box in a sketchpad item only takes fixed variables. As a solution, you can calculate the desired duration in an inline_script item placed immediately before your sketchpad item. Next, you can use the square-bracket method (e.g.
[my_duration]) in the duration box.You can calculate the desired duration by placing something like the following code in the Prepare phase tab of your inline script:
This code will work on all trials except the first trial of your experiment, because at that time the variable 'response_time' does not have a value yet. Therefore, you should also append a second inline_script item to the very beginning of your experiment, and give 'response_time' a starting value. You can do this by placing something like this in the Prepare phase tab:
Your experimental overview should look something like this:
Does that make sense?
Best wishes,
Lotje
Did you like my answer? Feel free to

Great! It perfectly works. Thanks a lot.
Hi,
I just realized that with your help I collect the rt of the previous trial, but I would like to collect the rt of the current one.
I tried several things but coulnd not find any solution for the moment. Would you have any idea, please?
Best,
I found the beginning of a solution.
When I use your code in the "Run Phase" and I display response_time in the debug window, my_duration displays the correct current RT.
My last remaining problem is that, now, I cannot access to the variable "my_duration" on another sketchpad (placed after the inline of course). I tried to declare it as "global" but that does not work.
My problem was not an access problem. I forgot to give "my_duration" a starting value as you mentioned...
Thanks again for your help!
Hi,
I'm not sure whether you already worked it out, but here's a small tip anyway. You can 'pad' the remaining time after a response with this simple script:
So let's say that you have sketchpad1, followed by a keyboard_response, and then you want to 'pad' the remaining 5 seconds while showing sketchpad2. You can do this with the following sequence:
Does that make sense? So you don't use the 'duration' parameter of the sketchpad, but simply use an
inline_scriptitem.Hope this helps!
Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
thank you very much, it perfectly works as I wanted with this strategy.