Howdy, Stranger!

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

Supported by

[open] how to create feedback with different proportions

edited February 2013 in OpenSesame

Hello, we use a free choice task in which one of four relevant keys can cause an effect on the screen (a red circle changes its color to white and disappear).
We have a problem in creating different proportions of feedback to each one of the relevant keys.
for instance, a specific key will cause the effect on the screen in only 70% of the times it is pressed.

any suggestion or example how to do it will be very helpful

Noam

Comments

  • edited February 2013

    Hi Noam,

    Perhaps you can describe your problem in more detail? I.e. what exactly are you trying to accomplish, what do you have at the moment, and in what sense doesn't it work?

    Cheers!
    Sebastiaan

  • edited February 2013

    Hi

    We are new with Sesame so I will try to be more specific:
    we have created a response effect (a proceeding sketchpad) that appears when one is pressing any one of four relevant keys. The problem we are facing is how to create two proceeding "effects" (sketchpads) that will appear with different proportions after each key. For example, a sketchpad (a response effect) will follow a key press 70% of the times and different sketchpad (different response effect) after the other 30 % of the times the same key is pressed.
    it is a common procedure in experiments using feedback in a fixed proportion.
    thank you!

    Noam

  • edited February 2013

    Hi Noam,

    If I understand correctly, a given keyboard response should lead to the appearance of a 'desired' sketchpad in 70% of the cases, whereas it leads to a different sketchpad in the remaining 30% of the cases. Is that correct? The explanation below will give you an idea of how to achieve this. You can adapt this to your specific situation, for example by extending it to multiple keypresses which all have different 'desired' and 'different' sketchpads associated with them.

    1: Append an inline_script to your block_sequence, and place the following code in its "Prepare phase" tab:

    # Import the built-in Python module 'random':
    import random
    
    # Define constant variables. (Adapt those values
    # to your specific situation):
    
    nTrials = 10 # nr of trials in one block
    pWanted = .7 # chance that the intended response effect occurs
    pDifferent = .3 # chance that another response effect occurs
    
    # Create a list containing 10 items. 7 of the items have the value 
    # 'desired', 3 of the items have the value 'different':
    blockList = ["desired"] * int(nTrials * pWanted) + ["different"] * int(nTrials * pDifferent)
    
    # Next, use the random.shuffle() function to 
    # randomize the order of the items in the list:
    random.shuffle(blockList)
    
    # Finally, make the list global such that we
    # can use it in other inline_script items as well:
    
    global blockList
    

    2: Append an inline_script item to your trial_sequence and place the following code in its "Prepare phase" tab:


    # Determine which response effect will # appear after a keyboard response: # We'll do this by 'popping' (i.e. drawing without replacement) # one item from the previously prepared blockList. responseEffect = blockList.pop() # Set the variable using the exp.set() function. # By doing so, we make sure the variable is available # in the graphical interface as well. This enables us, # for example, to log the variable and to use the square- # bracket method. # See also: # http://osdoc.cogsci.nl/usage/variables-and-conditional-qifq-statements/ exp.set("responseEffect", responseEffect)

    3: Append two sketchpad items to your trial_sequence, one with the 'desired' and one with the 'different' content. Make sure those items are placed after the inline_script item and the keyboard_response item.

    4: Open your trial_sequence item, and set the "Run if" statement of the 'desired' sketchpad to [responseEffect] = desired. Adapt the "Run if" statement of the 'different' sketchpad according to similar reasoning.

    An example experiment can be downloaded here (simply save with the extension '.opensesame'):

    Note that I used a little bit of Python inline coding. If you're not familiar with Python, this might be a good start:

    I hope this helps you getting started! Please let us know if you have any further questions!

    Best wishes,

    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • edited 8:26PM

    You understand it correctly. thank you very match Lotje!

  • Hi Noam,

    You're welcome!
    Good luck with your experiment and don't hesitate to post more questions!

    Best,

    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • edited March 2013

    Hi again

    The script that you sent us worked very well. We defined one key that leads to two different sketchpads with different proportion. However, we still have problem in creating four keys that lead to different sketchpads with different proportions. For example, the key "s" leads to "sketchpad 1" in 30% of the presses and to "sketchpad 2" in 70%, while key "d" leads to "sketchpad 1" in 60% of the presses and to "sketchpad 2" in 40%.
    We would like to know how to define four keys for each proportion condition and what do we need to change in the script in accordance to the above.

    Thank you for your help
    Noam

  • edited March 2013

    Hi Noam,

    I think it's a good idea to make a Python dictionary at the start of your experiment, containing the possible keyboard presses as keys, and the corresponding probabilities of sketchpad1 as values.

    For example:

    # Make a dictionary containing probability of sketchpad1
    # for every possible keyboard response.
    
    # See also:
    # http://docs.python.org/2/tutorial/datastructures.html#dictionaries
    
    dict = {}
    
    dict["s"] = .3
    dict["d"] = .6
    dict["b"] = .9
    dict["l"] = .1
    
    # Make the dictionary global such that it is available in 
    # future inline_script items as well:
    global dict
    

    Next, you could append an inline_script to your trial_sequence and determine whether sketchpad1 or sketchpad2 is going to be presented by placing the following Python code in the Run phase tab. (Note that this item should be placed after the keyboard response is collected, but before sketchpad1 and sketchpad2.)

    # Here we determine which response effect will appear 
    # after a keyboard response:
    
    # Import the built-in Python module random()
    # See also: http://docs.python.org/2/library/random.html
    import random
    
    # Determine the given keyboard response by using the self.get() function.
    # See also: 
    # http://osdoc.cogsci.nl/usage/variables-and-conditional-qifq-statements/
    key = self.get("response")
    
    # 'Look up' in the dictionary what the probability of sketchpad1 is 
    # for this response:
    pSketchpad1 = dict[key]
    
    # Draw a random float and see whether the float is higher or lower than
    # as the probability that sketchpad1 will appear. 
    # This probability depends the keyboard response.
    randomChoice = random.random()
    
    if randomChoice <= pSketchpad1:
        responseEffect = "sketchpad1"
    else:
        responseEffect = "sketchpad2"
    
    # Set the variable using the exp.set() function.
    # By doing so, we make sure the variable is available
    # in the graphical interface as well. This enables us,
    # for example, to log the variable and to use the square-
    # bracket method.
    # See also: 
    # http://osdoc.cogsci.nl/usage/variables-and-conditional-qifq-statements/
    exp.set("responseEffect", responseEffect)
    
    # Also use some other variables for potential use in the GUI:
    exp.set("randomChoice", randomChoice)
    exp.set("pSketchpad1", pSketchpad1)
    exp.set("pSketchpad2", 1-pSketchpad1)
    

    The updated example experiment can be downloaded here.

    I hope this helps!

    Best wishes,

    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • edited 8:26PM

    thank you!

    We have another last question for the cuurent experiment, hope you could help us with this one too.
    We would like to add the data output another variable that counts the responses (key presses) whithin each trial.
    thank you again!
    Noam

  • edited March 2013

    Hi Noam,

    You're welcome!

    I don't completely understand what you mean by 'a variable that counts the responses within a trial'. Is the participant giving multiple responses in one trial?

    In general, all items in your experiment are automatically counted by OpenSesame. The counters are stored in the variables called 'count_' followed by the name of the item (e.g. 'count_keyboard_response') and automatically logged to your output file (provided that you appended a logger item to the end of your trial sequence, of course):

    image

    Note that in Python counting always starts at zero. So the first time a keyboard_response item is run, 'count_keyboard_response' has the value 0, whereas the second time it has the value 1, etc.

    Does this help? If it doesn't solve your question, please don't hesitate to post again!

    Best,

    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • edited 8:26PM

    thanks for the quick reply,
    Participants are instructed to respond only one time. However,some may respond more than one time in a single trial.
    "count_keyboard response" counts only the first response on each trial. I am interested on the actual number of presses within a trial (even though participants are instructed to press only one time per trial).
    Noam

  • edited 8:26PM

    Hi Noam,

    It's still not completely clear to me what you mean. If you don't want participants to give multiple keyboard responses before the response effect (your second sketchpad) is shown, you could set the duration of the first sketchpad to 0, and place a keyboard_response item immediately after it (see the example experiment I uploaded earlier). By doing so, the experiment will always immediately advance to the next item (in your case the second sketchpad) as soon as a key is pressed.

    If you want to continuously check whether your participants are pressing any keys (that will not have any effect anyway) throughout the whole experiment (i.e., during your first sketchpad, your second sketchpad, and any potential other sketchpad or feedback items), you'll need to run all of those items via inline scripts. I'm not sure whether that's worth all the effort.

    If you do want to count the number of presses anyway, could you provide us with some more information by for example adding a screen shot of the overview of your experiment or uploading your script? And could you tell us where exactly in your trial sequence you want to continuously pull the keyboard input?

    Best,

    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

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