Howdy, Stranger!

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

Supported by

[open] Separate reaction time in one trial

edited April 2014 in OpenSesame

Hello.

First of all, I must say that OpenSesame is quite interesting little program for making experiments. I started to use it for my research, and I have a problem.

So, I'll present one stimulus to subjects binoculary and their task will be to hold specific keyboard button (e.g. a or l) for some amount of time. The stimulus will be presented for 10 seconds and subjects will have to hold A or L button during that time; of course, they can shift their response (e.g. hold key A for 5.67 sec and key L for 4.33 sec, or they can hold only ).

And, that's my problem. Is there any way for recording two separate reaction times (for each key separate, because I'm testing the amount of time looking at one part, and the amount of time looking at other part of stimulus) for one stimulus, during limited time?

Thanks!

p.s. I started learning python, but...I'm still a noob.

Comments

  • edited 5:41PM

    Hi Nikolas,

    So if I understand correctly, you want to log all key press and release events that occur within this 10 s period, right? This is not too difficult to implement using an inline_script like the one below. You you can also find many variations of this basic problem here on the forum.

    The script below deals only with key presses, though. Key releases are a bit tricky, and it depends on the back-end how you can capture those. See for example:

    Cheers!
    Sebastiaan

    from openexp.keyboard import keyboard
    # Specify a duration and a list of allowed responses
    duration = 10000
    allowed_responses = ['a', 'l']
    # Create a keyboard object. The 0 ms timeout means that we can use it for
    # continuous polling.
    my_keyboard = keyboard(exp, timeout=0, keylist=allowed_responses)
    # Loop for the duration of time
    start_timestamp = self.time()
    response_number = 0
    while self.time() - start_timestamp < duration:
        # Poll the keyboard
        key, response_timestamp = my_keyboard.get_key()
        # If a response was given, register it as `response_0`, `response_1`, etc.
        if key != None:
            response_time = response_timestamp - start_timestamp
            exp.set('response_%s' % response_number, key)
            exp.set('response_time_%s' % response_number, response_time)
            response_number += 1
    
  • edited 5:41PM

    Yep, that's what I would like to do :)

    And thanks a lot! I'll try to make some combination out of these scripts, and I'll send results :)

Sign In or Register to comment.