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

Set an incompressible duration of sketchpad while recording response time

Hi,

First of all, Opensesame is really useful and easy so thank you for that !

But I don’t succeed to do something that I thought would be easy to.
I would like to show a picture for at least 3000ms and allow the participant to answer (with keyboard) during that duration or after (the picture should stay at least that 3000ms and until the participant answers which can be for example 10s later).
If I set the duration of the sketchpad to 3000 and deselect the “clear key pressed before” on the keyboard_response it does work, but then I don’t have the response_time if the participant answer before the 3000ms.
If I set the sketchpad to 0ms then I can have the response_time directly after my picture appears but the picture disappears when the participant answers so it might not have been shown long enough (3s).

Does someone know how to handle that ?

Thanks

Comments

  • eduardeduard Posts: 875

    Hi,

    How about some python scripting? Set the duration of the sketchpad to 0 and replace the keyboard with an inline_script in which you will collect the response:


    kb = keyboard(timeout = 0) blank = canvas() start_time = clock.time() var.correct = NA var.resp_time = NA while True: k,t = kb.get_key() if k != None: var.resp_time = t-start_time var.correct = k==var.correct_response break if clock.time()-start_time > 3000: blank.show() elif clock.time() - start_time > timeout: break

    Edaurd

  • Thanks Eduard, the thing is that I don't know anything about Python...
    I did a copy/paste and it didn't work (It tells me variable "correct" doesn't exist). I guess that I should add some informations in this code but I really don't know what and how...

  • eduardeduard Posts: 875

    I see.


    kb = keyboard(timeout = 0) # initializes a keyboard response item with a timeout of 0 blank = canvas() # makes an empty canvas var.correct_response = 'd' # define what you consider a correct response. start_time = clock.time() # start time of reaction time measure var.correct = NA # initialize correct response variable var.resp_time = NA # initialize response time variable # loop for as long as you want, e.g. 10 seconds timeout = 10000 while True: k,t = kb.get_key() # sample key response if k != None: # if a key was pressed ... var.resp_time = t-start_time # ... measure response time var.correct = k==var.correct_response # and define whether response was correct if clock.time()-start_time > 3000: # if response was given after 3 seconds, .... break # break the loop if clock.time()-start_time > 3000: # after 3000 seconds blank.show() # show an empty canvas elif clock.time() - start_time > timeout: # after a certain time (defined earlier) ... break # break the loop

    YOu can also check out the documentation. It's not all that difficult:

    http://osdoc.cogsci.nl/3.1/manual/python/about/
    http://osdoc.cogsci.nl/3.1/manual/python/keyboard/

    Eduard

  • Hi Eduard,

    So I did the necessary to understand a bit python code but I still don't succeed.

    What I would like to have is :
    If a key is pressed but the response time is inferior at 3000ms : collect response time and correct response + my picture stays on the screen until it reaches this 3000ms of presentation (and unfortunately this until function doesn't exist...) and then move on to the next picture.
    If this is not the case : wait with my picture on the screen until the participant answers and then collect all informations and continue on next picture.

    Do you have any idea of what I should do ?

  • eduardeduard Posts: 875

    Did you try my code? It should work I think...

    kb = keyboard(timeout = 0) # initializes a keyboard response item with a timeout of 0 
    my_canvas = copy_sketchpad('my_sketchpad') # makes an empty canvas
    var.correct_response = ['q','m'] # define what you consider a correct response.
    start_time = clock.time() # start time of reaction time measure
    var.correct = NA # initialize correct response variable
    var.resp_time = NA # initialize response time variable
    # loop for as long as you want, e.g. 10 seconds
    timeout = 10000
    while True:
        k,t = kb.get_key() # sample key response
        if k != None: # if a key was pressed ...
             var.resp_time = t-start_time  # ... measure response time
             var.correct = k==var.correct_response # and define whether response was correct
             if clock.time()-start_time > 3000: # if response was given after 3 seconds, ....
                   break # break the loop
             else:
                   clock.sleep(timeout-(clock.time()-start_time) )
        if clock.time()-start_time > 3000: # after 3000 seconds
            blank.show() # show an empty canvas
        elif clock.time() - start_time > timeout: # after a certain time (defined earlier) ...
             break # break the loop
    

    Btw. Please post code as text, not as image, this makes working with it a lot easier.

    Eduard

  • I found something much easier which works as I want.

    self.sleep(3000-self.get('response_time'))

    Thank you a lot for your help !

    Ysia

Sign In or Register to comment.