Howdy, Stranger!

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

Supported by

[solved] collecting free responses and response time

edited January 2014 in OpenSesame

Hi!

First of all I'm completely new to OpenSesame so my question may be a noob question. I'm trying to create a simple procedure - show stimuli for period of time (say 60s) and collect every keypress (to be exact 4 keys) that subject makes, along with time interval between each keypress (to know for how long thet percive some givan state) Is it possible to do so?

Thanks in advance!

Comments

  • edited January 2014

    Hi Dorgar,

    That's possible, but you'll need to use some inline code to do so. The script below shows how to loop through a number of responses, reducing the timeout with each response so that the total timeout is 60s. This should hopefully get you started.

    For more info, see:

    from openexp.keyboard import keyboard
    
    # Uncomment for 0.25 and before
    # exp = self.experiment
    
    # Nr of responses
    n_resp = 4
    
     # 60s total timeout
    total_timeout = 60000
    
    # Get the onset of the sketchpad change 'my_sketchpad'
    # to the name of the preceding sketchpad.
    start_time = self.get('time_my_sketchpad')
    
    # Create a keyboard object
    my_keyboard = keyboard(exp)
    
    # Initially set all responses to some default value, so
    # they aren't empty if a timeout occurs
    for i in range(n_resp):
        exp.set('response_%d' % i, 'timeout')
        exp.set('response_time_%d' % i, 'timeout')
    
    # Collect multiple responses using a loop
    for i in range(n_resp):
    
        # The timeout for this response
        timeout = total_timeout - self.time() + start_time
        resp, resp_time = my_keyboard.get_key(timeout=timeout)
    
        # Timeout occurred!
        if resp == None:
            break
    
        # Log the response and response time
        exp.set('response_%d' % i, my_keyboard.to_chr(resp))
        exp.set('response_time_%d' % i, resp_time - start_time)
    

    Cheers!
    Sebastiaan

Sign In or Register to comment.