Welcome!

Sign in with your CogSci, Facebook, Google, or Twitter account.

Or register to create a new account.

We'll use your information only for signing in to this forum.

Supported by

Changing the duration of a sketchpad depending on the response time

Hello,
I have some issue to access the response time value for compute the duration of a sketchpad.
In my experiment there is a Keyboard_response (called "risposta") with a duration of 10.000 (10s).
After that I have a sketchpad (ISI) and I want to show it for a duration of 10.000 - response_time_risposta.
I added a inline script ISI_duration in wich I creata a variable to compute the duration in this way
var.ISIdur= 10000-response_time_risposta
But OpenSesame says: NameError: name 'response_time_risposta' is not defined

I cannot find a way to access the variable "response_time_risposta", I saw it in the variable inspector tool.

What is the correct way to do it?

Thanks a lot,
Paolo

Here is my experiment's structure

opensesa.PNG 17.5K

Comments

  • eduardeduard Posts: 815
    edited July 11

    Hi Paolo,

    Sketchpads are drawn in the prepare phase, that is everything that is included in making them, needs to available at the prepare phase. To use information that are only computed in a trial itself (like RT), you should use feedback items (see here).

    Hope this helps.
    Eduard

  • bilancinobilancino Posts: 12

    I change the inline script accordingly to "the prepare-run strategy" and now is working.
    Thanks a lot for your help!
    Paolo

  • cescocesco Posts: 14
    edited July 11

    Alternatively, you should be able to use a sketchpad. Set duration to zero and put your Inline script after it.
    Something along these lines should work. But if there is a good reason to use feedback items instead, I'd like to hear it. Precision timing perhaps?

    # The time it needs to be presented for is 10 seconds minus the RT. For the loop calculations you need the current clock time, and your loop starts at 0
    Showtime = 10000 - var.response_time_risposta
    start_time = clock.time()
    current_time = 0
    
    # Update the presentation time while it's smaller than the time you want it to be presented for
    while current_time < Showtime:
        current_time = clock.time() - start_time
    
    # Always print when debugging
    print("In ms, ISI was presented for: ", current_time)

  • eduardeduard Posts: 815

    Not particular reasons. If anything, then using a feedback item will be slower, as it is executed in the run-phase. So if you need precise timing and have heavy displays, feedback items shouldn't be used (or the timing should be tested, at least).

    In general, I prefer having fewer items in my sequence, so if I can do something with only a feedback item instead of a sketchpad and an inline_script, I'd got for the feedback item. Well, actually, I would only use an inline_script and do the stimulus presentation entirely in it.

    Eduard

  • bilancinobilancino Posts: 12

    The timing is not so important in this case.
    I cannot figure it out how to use only the "feedback" item without the inline code.

    I choose a different solution:

    -An "Inline code" to compute the duration after "risposta" and before "ISI"

    set description "Executes Python code"
    set _run "var.ISIdur= 10000-var.response_time_risposta"
    ___prepare__
    var.ISIdur=0
    __end__

    -"Sketchpad ISI" with duration "[ISIdur]"

    Thanks
    Paolo

Sign In or Register to comment.