Howdy, Stranger!

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

Supported by

Variable Timeout

Hi, I couldn't find anything online for my problem, so I hope someone can help me.

I have a keyboard response timeout of 2000 ms and afterwards a fixation star should be displayed. The Timeout of the fixation star should be something like this: [2500ms + Jittering - response time]. Is there an easy way to implement this? Unfortunately I am still very new to Python and OpenSesame.

Thanks in advance

Tobi

Comments

  • Hi Tobi,

    in an inline_script, you can compute the new timeout.

    It is important to put the code in the run phase, because otherwise no response will be defined.

    jitter = 2000 # or whatever you want
    var.star_dur = 2500 - var.resp_time + jitter
    

    Importantly, the star then needs to be shown in the feedback item, not a sketchpad. See here why:

    Good luck,

    Eduard

  • edited December 2019

    Thank you, that solved my problem. Though I have another little thing: I want to show the text "Wrong!" when the wrong key was pressed and "Too slow!" when nothing was pressed, but if I use [correct] as variable for "Wrong" it is shown when nothing was pressed as well, so what variable do I have to use?

    Additionally, I want to use a custom keyboard, is there an easy way to implement this?

  • Hi,

    What do you mean with custom keyboard?

    Splitting the feedback into wrong and too late is possible, for that you need to use an additional variable though. For example, you can use var.response which indicates whether a response was given, so if [response] = 'None' and [correct]=0, then you would want to show too late, otherwise wrong.

    Good luck,

    Eduard

  • Hi, thanks for the help.

    With 'custom keyboard' I mean a response pad with 4 buttons, which can be accessed via ports, so I can't just use the normal keyboard response, but had to write an inline script where I access the port. I tried the following code, but I get an 'invalid syntax' (I think for the if condition), do you know why, and if the code would be working as intended?


    timeout_start = clock.time()

    timeout = 2000

    while clock.time() < timeout_start + timeout:

    var.response = io.DlPortReadPortUchar(port+1)

    if var.response == (4 or 5 or 6 or 7)

    var.response_time = clock.time() - timeout_start

    break

  • @Mkengine You have asked the exact same question in this post. Please don't do that in the future, and help us keep the forum clean!

  • Sorry, I won't do that again. After some time I just thought this thread was buried and it's faster to open a new one.

Sign In or Register to comment.