Howdy, Stranger!

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

Supported by

[solved] Coding help for numerical keyboard response post sequence

edited January 2016 in OpenSesame

Hi there,

I'm having a little trouble with coding for my experiment and would really appreciate some guidance.

Essentially, I am creating a counting task in which I am hoping to show participants a block of 15 stimuli in each sequence. After each I would like to ask a question, e.g. "how many faces did you see" and they would need to enter a keyboard response.

I am relatively new to coding and to OpenSesame (but I love the software already!). I am guessing that it might be possible to achieve this by creating a loop after my trial sequence, inserting a sketchpad and altering the script on this to insert a keyboard and numerical response. But as a newbie this is a little beyond my capabilities!

Any advice on this (or coding if possible) would be greatly appreciated!
Thank you!

Comments

  • edited 3:54AM

    Hi,

    If I understand correctly, one trial consists of 15 stimuli, followed by a question and a keyboard response?

    You could do this in multiple ways. The most straightforward way might be to just place 16 sketchpads in your trial sequence, 15 of which will display an image, and the 16th your question. But of course you want to control what kind of images are displayed. In the sketchpad item you can click "view script" in the upper-right corner, and write a line of code like draw image 0 0 "[image1].png" scale=1 center=1 show_if="always". This will grab an image from the filepool with its name corresponding to whatever text the variable image1 contains. For instance, you may have stated somewhere that image1 = "face". In this case, the first image is going to be "face.png" (given that this file was indeed in your file pool).

    Long story short, it comes down to defining what your sequence of images should look like for each trial. You can do this in an inline_script prior to to the sketchpads (but also in your trial sequence). I imagine this may depend on an experimental condition? Say you have amount_of_faces as condition, which could be set to 4, 6 or 8. In that case your inline script could look like this:

     images = [] # an empty list that will be given 15 elements.
    
     for i in range(0,exp.get("amount_of_faces")):
           images.append("face") # appends element "face" to the list
                                              # as many times as "amount_of_faces" dictates
     for i in range(0, 15-exp.get("amount_of_faces")):
           images.append("house") # appends "house" to the list until it contains 15 elements
    
     random.shuffle(images) # shuffles the list
    

    Now, in the line of code in each sketchpad, you use "[images[0]].png", "images[1]].png", "images[2].png", all the way up to "images[14].png" for your 15th sketchpad. Note that you're using only two images in this sequence: a face and a house. If you have multiple faces and houses (or whatever you want to display), this will complicate the code that builds up your sequence a bit - but the logic will stay the same.

    Let me know how it goes.

    Cheers,

    Josh

  • edited 3:54AM

    Thank you for the response Josh!

    Very useful and informative, however I am still having a small issue (but I don't think I described it properly to begin with).

    At present, I have managed to code one sketchpad to show the 15 stimuli in a random order. But I am still having a problem with the keyboard response.

    My experiment loop consists of a sequence which contains; a fixation dot, a blank sketchpad, an advanced delay and then the stimulus sketchpad. When I enter in a keyboard response, blank screen and logger file after this (in order for the participant to enter the amount of faces (targets) in the sequence) this affects the entire sequence and it will not run correctly. So I have tried to enter it after the trial sequence but I still seem to be having problems.

    Is there a way to use a sketchpad to show the question, e.g. "how many faces did you see?" and allow the participant to respond? and where should this be located in relation to the rest of the experiment.

    I apologise if this doesn't seem like a clear explanation.

    Thank you so much for your help so far - it is greatly appreciated!

  • edited 3:54AM

    I managed to solve the issue! Thank you for all of your help with the coding for the pictures.

    I ended up adding a sequence for the response after the trial sequence consisting of a form text input screen and logger. This has solved the issue - such a simple solution in the end!

    Thank you again Josh for your previous advice!

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