Howdy, Stranger!

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

Supported by

Help with modifying a script

Here I have an experiment where (with help from this forum)! I was able to have a pair of images appear randomly either on the left or the right and a target image (that matches either the left or the right image) appear on top. The goal of the experiment is for the toddler to choose the match. So if the object that appears on the right matches the object that appears on the top the correct answer would be to touch the right box. As of right now, this works perfectly. Now, I just want to add a trial in between that always uses the same objects. for example:

trial1 uses object_9 and object_10,

trial2 uses object_1 and object 2,

trial 3 uses object_4_5,

trial 4 uses object_1 and object_2,

trial 5 uses object_7 and object_8

trial 6 uses object_1 and object_2 etc.

So between every "random trial" a repeated pair is inserted but the order of those objects would still be randomized. ie object 1 sometimes appears on the left, sometimes on the right and is sometimes the target and the same for object_2.

Could someone help me modify this script to accomplish this? Thank you so much!!


Comments

  • Hi Mollie,

    I think I roughly understand what you're trying to do, but the devil is in the details.

    Could you first explain exactly how you select the stimuli at the moment? What are the constraints? In what sense are you counterbalancing things (as the name of the counterbalancing_1 item suggests)? And how exactly does the script (which is pretty dense) accomplish this?

    Next, could you explain exactly what the constraints are for these repeated trials? E.g. are they sampled from the same set as the other stimuli? How often should they occur? Can they occur twice in a row, etc.?

    Cheers!

    Sebastiaan

  • edited October 2019

    Hey Sebastiaan!

    Thank you so much. At the moment the stimuli are paired such that object_5 and object_6 are always together. I have objects named object_5 through object_21.

    That is why I have the stim_match_1 and stim_match_2 part of the script so that those pairs always show up together.

    As of now, there are no repeated objects, which is how I want it.

    Basically, if it randomly selects object_6 that means it must also randomly select object_5 and that if object_5 shows up on the left then object_6 must show up on the right. Then, either object_5 or object_6 will be the top card(target). If the target is 6 then the subject must press the square on the right where object 6 was. (because they are a match).

    Additionally, I do not want the answer to be on the same side more than three times in a row which is the bottom part of the counterbalance_1.

    This is all exactly how I wanted it for the first design.

    Now, I want everything to remain the same, that is the same object pairs should stay together and be randomly assigned left or right and target, the correct answer should not be on the same side more than three times in a row, and the object pairs should not repeat. BUT, I now want one object pair to repeat over and over again and be 'sandwiched' between the non-repeated randomly selected pairs of objects.


    My current design is like so

    object_5 and object_6

    object 19_ and object_20

    object_9 and object_10

    Until 8 trials have happened and all pairs have been shown one time.


    What I would like to happen is:

    object_8 and object_7

    object_1 and object_2

    object_9 and object_10

    object_1 and object_2

    object_14 object_13

    object_1 and object_2

    etc. until all 8 pairs have been shown, none of them repeated, with the same answer not on the same side more than three times in a row.

    So same exact paradigm, just with a repeated pair every other. importantly, this repeated pair should follow the same randomization rules such that sometimes object_1 is on the right and object_2 is on the left and the target(top card) is the match for object_1. Sometimes, object_1 is on the right and object_2 is on the left and the target(top card) is the match for object_2. Sometimes, object_2 is on the right and object_1 is on the left and the target(top card) is the match for object_1. Sometimes, object_2 is on the right and object_1 is on the left and the target(top card) is the match for object_2.

    Sorry I know this is rather involved. I hope I did an ok job explaining it. I appreciate any help you are able to offer. Thank you so much again.

    Best,

    Mollie

  • edited November 2019

    Hi Mollie,

    I think I understand now. The main trick would be to add a repetition target (target_1 in my example) after every regular target. This is done in the 'randomise variables' part of the script. Then, you need to also add a matching stimulus for object_1, i.e. object_2. And finally the targe_side list should be twice as long as before, because we now have twice as many trials, i.e. 16 instead of 8.

    Does that get you started?

    Sebastiaan

    from random import shuffle, choice
    
    # script is written for even number of trials. This number does not include the
    # repeated targets!
    no_trials = 8
    
    # initialize variables
    var.target_side = [0,1] * no_trials 
    var.targets = ['object_%d'%choice([idx,idx+1]) for idx in range(5,21,2)]
    # make left and right match
    
    stim_match_1 = {'object_%d'%idx:'object_%d'%(idx+1) for idx in range(5,21,2)}
    stim_match_2 = {'object_%d'%idx:'object_%d'%(idx-1) for idx in range(6,21,2)}
    stim_match_1.update(stim_match_2)
    # Also add matches for the repeating targets
    stim_match_1['object_1'] = 'object_2'
    stim_match_1['object_2'] = 'object_1'  # Update
    
    # randomise variables
    shuffle(var.targets)
    targets_with_repetitions = []
    for target in var.targets:
    	targets_with_repetitions.append(target)
    	targets_with_repetitions.append('object_1')
    var.targets = targets_with_repetitions
    print(var.targets)
    
    # Rest of the script follows
    
  • Perfect!! Thank you so so much

  • edited November 2019

    Hey Sebastian!


    The only thing is that I don't want the target to always be the same in the repetition trials. Sometimes I want it to be object 1 and sometimes I want it to be object 2. I'm having trouble with the randomization of this here. Any help would be greatly appreciated!

    Thank you so much,

    Mollie

  • edited November 2019

    Hi Mollie,

    If I understand the logic correctly, then would simply change this line:

    targets_with_repetitions.append('object_1')
    

    To this:

    targets_with_repetitions.append(choice(['object_1', 'object_2']))
    

    Cheers!

    Sebastiaan

  • Hi Sebastian,


    Thank you so so much again. I'm getting an error. I notice there is a missing parenthesis but when I add another it still gives me an error. Any advice?


    Thanks,

    Mollie

  • Hi Sebastian,


    It gives me a weird error as I haven't changed anything with var.targets.

    If I change the parenthesis to

    targets_with_repetitions.append(choice(['object_1', 'object_2']))


    I get:

    Thank you so much again!

    Mollie

  • Hi Mollie,

    The problem is that 'object_2' is a key in the stim_match_1 dict. I updated the code above to show how you can add it (marked 'update').

    Cheers!

    Sebastiaan

  • 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