Howdy, Stranger!

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

Supported by

[solved] Two independent sequences in parallel

edited April 2013 in OpenSesame

Hello board!
To begin with, OpenSesame's obviously a great piece of software. I find it easy to create basic experiments, and the best thing about it might be that it teaches me some Python. Sebastiaan, I told you I'd use OpenSesame for the next thing I'm going to pre-register :) (This is intended for Cortex.)

Still, I'm stuck with my current experiment. I'm trying to program an RSVP sentence presentation experiment that allows the participant to immediately respond to individual words, and get immediate auditory feedback while the sentence keeps being presented.
So I've programmed two sequences. One presents a sentence word by word, with individual words on sketchpads with fixed timing (around 500 ms per word). The other sequence contains 1. a delay (depending on which word is the critical word, set by the loop), 2. a keyboard response, 3. two samplers with "yay!" and "boooh!" sounds, depending on the value of [correct]. And then I've simply put both sequences into a "parallel" item.
The idea is that the two sequences should work completely independently, with the sentence being presented in full, with strict timing, unperturbed by participant behaviour, and a keyboard response (when the participant detects a certain word in the stream) that is immediately followed by auditory feedback, without waiting for the sentence presentation sequence to finish..
Note that the average sentence is around 5 seconds, the average reaction time around 1 second, and the critical word appears halfway through the sentence.

It doesn't work, so far. Keyboard response (I'm on a Mac btw., so it's probably not the Windows/multithread bug I've seen mentioned here) are not recognized, 'correct' is stuck on "0" and the timing of the sentence sketchpads seems to be influenced by the events in the other sequence.
Is the basic approach sound? If so, I would put up my script on pastebin and kindly ask for more specific feedback. Or is it simply not possible the way I'm trying to do it right now?
I appreciate any feedback! Thanks,
Jona

Comments

  • edited April 2013

    To begin with, OpenSesame's obviously a great piece of software. I find it easy to create basic experiments, and the best thing about it might be that it teaches me some Python. Sebastiaan, I told you I'd use OpenSesame for the next thing I'm going to pre-register (This is intended for Cortex.)

    Thank you, and good luck with the new format!

    Is the basic approach sound? If so, I would put up my script on pastebin and kindly ask for more specific feedback. Or is it simply not possible the way I'm trying to do it right now?

    The basic approach should be sound, if the parallel plug-in would function as you would hope. Unfortunately, on many systems it doesn't. I don't use a Mac myself, but it sounds like a threading problem again.

    My recommendation would be to implement the RSVP task through an inline_script. It's not that difficult, and it will save you considerable headaches. The basic idea is demonstrated in this script:

    from openexp.canvas import canvas
    from openexp.keyboard import keyboard
    
    N = 10 # Nr. of canvases
    SOA = 495 # Just short of 500ms
    
    # Create a list of canvases. These could in principle
    # also be copied from sketchpad items, using
    # `self.copy_sketchpad()`.
    canvas_list = []
    for i in range(N):
        my_canvas = canvas(exp)
        my_canvas.text('%s' % i)
        canvas_list.append(my_canvas)
    
    # Create a keyboard object that also servers as a
    # delay period.
    my_keyboard = keyboard(exp, timeout=SOA)
    
    # Alternately show canvases and record keypresses,
    # until a key has been pressed.
    t1 = self.time()
    for i in range(N):
        canvas_list[i].show()
        key, t2 = my_keyboard.get_key()
        if key != None:
            break
    
    # Set the response variables
    exp.set('response_time', t2-t1)
    exp.set('response', key)
    

    Cheers!
    Sebastiaan

  • edited April 2013

    Thanks Sebastiaan! I think I mostly understand what's going on in that script. It will take me some time to implement it though. Alas, at least I'm learning Python.

    However, one thing I'm worrying about is that the feedback sound cannot be time-locked to the text presentation, but must be time-locked to the button press (after some delay), while the canvas presentation should go on unperturbed (the sentence must be fully presented, and at the same speed). If I understand correctly the "if key != None:" line, whatever happens afterwards would start at the next iteration of the loop (when a new canvas would have been presented), and anything with a real duration here will delay the next canvas.

    I think I have a vague idea of how to manage that - delay the sound file by a value dependent on RT (t2), as in the mock code here:


    t1 = self.time() flag = 0 for i in range(N): canvas_list[i].show() if key != None: key, t2 = my_keyboard.get_key() # after a delay based on RT, play either hit or miss sound # ... but only if no sound has been played before in this cycle if key = [correct_response] and flag = 0: self.sleep(500-t2) (play "hit" soundfile) flag = 1 elseif key = [incorrect_response] and flag = 0: self.sleep(500-t2) (play "miss" soundfile) flag = 1

    However, this would also delay the presentation of the next phrase. And as far as I understand it, updating SOA to a new value wouldn't change anything in the loop? Seems like I need a real parallel process again.

    Best,
    Jona

  • edited 11:00PM

    Okay, I've had a co-worker explain things to me a bit and I see where I understood your script, Sebastiaan. I will fiddle around with myself some more for now, please don't concern yourself with fixing what I should be able to do myself :) I'll post again when I run into actual problems.
    Thanks for the help.

  • edited April 2013

    I've adapted Sebastiaan's proposed solution and it works up to this point. The main problem was getting the next canvas to be delayed after a button press, and only allowing key presses once the critical event of the sequence had been presented, which I solved using something not especially elegant, but functional.
    Here is a link to what I did: http://pastebin.com/sP8J9Z0B

    I've changed the thread tag to [solved] accordingly.

  • edited 11:00PM

    Great, and good luck with the experiment!

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games