Howdy, Stranger!

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

Supported by

Some rookie questions: random sketchpad duration + re-running a loop

Hi,

I'm a newbie using OpenSesame and it's very likely both the questions I'm asking here are answered somewhere, but I haven't been able to find the answers, so here I am.

I'm trying to program a simple Flanker task (with some modifications), with the following structure (perhaps it is not the best way to do it, so comments on this are welcome too):


New experiment
Flanker sequence {seq}
Instructions
Practice loop
Practice_seq
Pr_loop {variables, correct responses, stimuli... set here}
Pr_trial_seq
Target (sketchpad; with the stimuli)
(keyboard_response)
ITI (sketchpad; actually a black screen)
Practice_end (sketchpad)
Experiment loop
... {as in the Practice loop}
Bye
Logger


Now, the questions:

  • How can I set a random ITI (sketchpad) duration between, for example, 650 and 750 msec, without having to set a variable in a loop?
  • I'd like to give the participants the option to repeat the Practice by a key press, for example "R". How can I do this?

Thank you very much in advance!

V

Comments

  • edited September 2016

    Hi Vic,

    How can I set a random ITI (sketchpad) duration between, for example, 650 and 750 msec, without having to set a variable in a loop?

    Include an inline_script in your Pr_trial_seq somewhere before ITI and paste this code into its prepare phase:

    import random
    var.ITI = random.randint(650,750)
    

    Next, you set the duration of your ITI sketchpad to [ITI], and you should be done.

    I'd like to give the participants the option to repeat the Practice by a key press, for example "R"

    Again, an inline_script does the trick. Put it in between Practice loop and Experiment Loop, e.g. after the practice_end sketchpad (in the run phase).

    Text = "Do you want to repeat the practice?\n Press 'y' to indicate yes, 'n' otherwise"
    
    cv = canvas()
    kb = keyboard()
    cv.text(Text)
    cv.show()
    key,time = kb.get_key(key_list = ['y','n'])
    if key == 'y':
        items.execute(u'Practice loop')
    

    Hope this helps,

    Eduard

    Buy Me A Coffee

  • VicVic
    edited September 2016

    Hi Eduard,

    First of all, thank you for answering. I've tried both your solutions.

    The first one (random sketchpad duration) was brilliant. However, when I tried the second Inline_script (re-running a loop), the task stopped showing the following message:

      TypeError: get_key() got an unexpected keyword argument 'key_list'
    

    I've tried some naive-guy-trying-to-code things, but I haven't been able to correct the error. So, once again, I'm asking for your help with this problem.

    Anyway, when I first tried to re-run the loop I did so with the 'repeat_cycle' item, because in the Practice_end sketchpad item, the image included some text giving the chance to repeat the practice pressing some key. Wouldn't it be easier doing it this way, instead of using the Inline_script?

    Thanks again.

    Vic

  • Hi Vic,

    They line should have been key,time = kb.get_key(keylist = ['y','n']). Sorry, for the confusion.

    Anyway, when I first tried to re-run the loop I did so with the 'repeat_cycle' item, because in the Practice_end sketchpad item, the image included some text giving the chance to repeat the practice pressing some key. Wouldn't it be easier doing it this way, instead of using the Inline_script?

    Maybe, but honestly, I have never worked with repeat_cycles and I don't really know what it does. From its description however, I have the impression that it rather repeats single repetitions from a loop rather than the entire loop.

    Eduard

    Buy Me A Coffee

  • Hi again Eduard,

    This time, it does work, although I have to press the key twice for the experiment to respond (however, it gets correctly to wherever I want to go in the sequence).

    To be noted, I've changed the instructions in the Inline a little bit. Instead the 'y' and 'n' keys you proposed, I've set 'r' and 'space', which are more consistent with the whole experiment (due to the rest of instructions the participant would read). Everything else, remains as you wrote it in your previous comment (except for the Text instructions, in which I've added the new keys), as follows:

    Text = "Do you want to repeat the practice?\n Press 'r' to repeat, or space to continue with the experiment" 
    
    cv = canvas()
    kb = keyboard()
    cv.text(Text)
    cv.show()    
    key,time = kb.get_key(keylist = ['r','space'])
        if key == 'r':
            items.execute(u'PracticeLoop')
    

    I must also say that, when I used your original keys ('y' and 'n'), it ran prefectly with just one key press. Is there any way I can maintain the 'r' and 'space' keys without having to press any of them twice?

    Thanks!!!

    Vic

  • Hi Vic,

    Did you remove the keyboard_response item from your trial sequence? As you are sampling for keypresses in the inline_script you don't need it any more. Once it is gone, it should proceed right away after either r or space has been pressed.

    Eduard

    Buy Me A Coffee

  • Hi Eduard,

    I've tried both, with and without the keyboard_response item, before writing the comment, and the result is the same...

  • Can you quickly upload your experiment?

    Buy Me A Coffee

  • Hi Eduard,

    I tried permanently deleting the keyboard_response item, and now it runs perfectly.

    Will the experiment still log (using a logger item as the last item of the experiment) the keyboard presses? If not, where would be appropiate to include the keyboard_response item to prevent the short circuit with the inline_script?

    I attach the experiment in case you want to take a look what to whatever was wrong.

    Thank you!

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