Howdy, Stranger!

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

Supported by

[solved] response time timing

edited April 2014 in OpenSesame

Hello,
Love open sesame, super easy to use. Having a little trouble though.
I'm trying to program a response time task to an audio beep. What I want to have is a series of beeps times 1200ms apart (with 300ms jitter), where Ps press the Space bar as quickly as possible when they hear the tone. I need that timing I've chosen to remain consistent. Here's my setup
-Loop
-Sequence
-Advanced Delay
-Synth
-Keyboard Response
-Logger
In my loop I have it set to cycle as many times as the study calls for. My synth is 100ms in duration, my advanced delay is set to 1200ms with 300ms jitter. my keyboard response is set so SPACE is an allowed response. Here's my problem:
-If i have the timeout on the keyboard response left blank or set to infinite, when I run the experiment, the computer will wait until I press SPACE, then start the next advanced delay, which screws up the timing.
- If I have the timeout set to 0, the beeps follow the timing perfectly, but no data is recorded. In my data set under response time, it just reads NA over and over.

I could set the timeout to something like 900ms and then subtract that out of the advanced delay, but then the audio beeps are going to be spaced out different for all my participants. Basically I want the beeps to be performing like the timeout is set to 0 (and all the beeps are set about 1200ms apart) but to be recording the data.
Is there a way to do this? Or a setup I can use that will work better for this?
Look forward to getting a response.

Comments

  • edited 8:06PM

    Here's a screen cap of the setup
    image

  • edited 8:06PM

    Hi,

    I could set the timeout to something like 900ms and then subtract that out of the advanced delay, but then the audio beeps are going to be spaced out different for all my participants.

    You're close. What I would do is define the interval+jitter already in audio_loop. To do this, you can make use of the fact that you can define your variables using Python, by prepending an = sign, like so:

    image

    See also:

    Then you can set the timeout of your keyboard_response to [interval]. Next, directly after the keyboard_response, you use a simple inline_script to pad the time that remains after the participant has responded:

    time_to_pad = self.get('interval') - self.get('response_time')
    self.sleep(time_to_pad)
    

    Does that make sense?

    Cheers,
    Sebastiaan

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • edited 8:06PM

    OK I've tried that, I have created the variable 'interval' and set it to =900+randint(0,600). i set the timeout on my keyboard response to that, but what do I put as the interval in the advanced delay? When I set it to 'interval' my beeps sound much further apart, almost twice as far apart as they should.
    I did a quick run and I've noticed that it still lists response times when I don't respond. Under response it will say none, but it will have a reaction time listed.

  • edited 8:06PM

    OK I got it working, I had forgotten to include spaces in the inline script (I'm such a n00b). You guys are so helpful!
    I'm still have the issue in the data though. I've included a screen shot of my data table. Where the response is listed as "none" should I assume the RT listed is the timeout?
    image

  • edited 8:06PM

    i set the timeout on my keyboard response to that, but what do I put as the interval in the advanced delay?

    Right, just to clarify. You are now using the keyboard_response plus inline_script to do all the sleeping. So you don't need the advanced_delay anymore and you can remove it from your trial sequence. Does that solve the issue?

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • edited 8:06PM

    That seems to have done the trick! thank you!

  • Hello!
    I am trying to achieve something similar as the original query. My participants will pay attention to a word loop, but also click the spacebar whenever they hear a click sound. However, my click sounds are randomly distributed throughout my word loop with no defined interval between them (there just is a specific number of them). I am not entirely sure how to tackle this issue with the solution above. Here is my full code so far: https://pastebin.com/PTyKaQzM

    I would like it so that each word in the word loop is shown for 240ms (as I have set in the sketchpad duration).

    In my inline script for the keyboard, if I set the timeout to 0 it does not record response times at all (NAs throughout). When I set it to 450ms (like it is now) it slows down the duration between words in the word loop, but records the RTs. Ideally, I would like to set the keyboard timeout to 1000ms without affecting the 240ms duration of the words displayed. That is, we will not analyse any response that takes more than 1000ms. Is this possible?

    The current set up:

    Thanks for your time :)

  • Hi,

    For some reason, your pasted code doesn't load into Opensesame. Can you also share the experiment? Anyway, I wrote a little script that should do what you are looking for. You just have to adapt it to your needs.

    import random
    
    cv = Canvas()
    blank_cv = Canvas()
    kb = Keyboard()
    
    # define and shuffle the word list
    nonwords = ['asd','fewsda', 'htergf']*3
    random.shuffle(nonwords)
    
    # define durations of each phase
    non_duration = 240
    blank_duration = 495
    
    # 10 sounds, randomly in 10 seconds
    sounds = random.sample(range(10000),10)
    # load sound 
    src = pool['bark.ogg']
    my_sampler = Sampler(src, volume=.5)
    # keeps track of which sounds have been played
    sound_idx = 0
    # list to collect all the responses
    var.resps = []
    
    # draw the first word 
    idx = 0 
    cv['word'] = Text(nonwords[idx])
    t0 = cv.show()
    
    # start_timer
    t1,t2 = clock.time(),clock.time()
    while True: 
        # get the key presses
        k,t = kb.get_key(timeout = 1)
        if k != None:
            var.resps.append([k,t])
            kb.flush()
    
        # show a blank and draw the next word
        if clock.time()-t1>240:
            t1+=1000
            t2 = blank_cv.show()
            idx += 1
            if idx == len(nonwords):
                break
            cv['word'].text = nonwords[idx]
    
        # show the next word and reset timers
        if clock.time()-t2>500:
            t1 = cv.show()
            t2 += 1000
    
        # play the sounds if it is time
        if not sound_idx == len(sounds):
            if clock.time()-t0>sounds[sound_idx]:
                my_sampler.play()
                sound_idx += 1
    

    Eduard

    Btw. Which version of Opensesame are you using? From your screenshot it appears to me that it isn't the latest one.

Sign In or Register to comment.