Howdy, Stranger!

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

Supported by

Counterbalancing stimulus positions

Hello,

I'm trying to present two pictures simultaneously, counterbalancing their positions across participants.

In the trial, the two pictures are presented simultaneously after a fixation. One is presented in left side, the other is in right side.
Each picture should be presented just once, so half of participants will see the picture1 in left side, the other half will do in right side. Further, half of pictures are target stimuli and the other half are distracter stimuli, and they should be always paired. So participants see the target in either left or right side.

I was able to make just the trial sequence and present stimuli by stimuli.canvas function.
Now I think about using balanced_latin_squarefunction or Expyriment's example code of simon task.

Are there any better ways or suggestions?

Thanks

Comments

  • rrrrrr
    edited January 2017

    Hello,

    I made a script without using balanced_latin_square function as below.
    In the script, the positions are just randomized but not counterbalanced.

    ########### EXPERIMENTAL DESIGN ####################
    #import 2 lists of image file#
    #randomizing the two lists#
    listAB = [[i, j] for i, j in zip(listA, listB)]
    
    list_former = [listAB[j - 1] for j in random.sample([i + 1 for i in range(len(listAB))], int(len(listAB) / 2))]
    list_latter = [[i[1], i[0]] for i in tuple(set(map(tuple, list_former)) ^ set(map(tuple, listAB)))]
    list_former.extend(list_latter)
    all = [list_former[i] for i in random.sample(range(len(list_former)), len(list_former))]
    
    listLEFT = [z[0] for z in all]
    listRIGHT = [z[1] for z in all]
    
    t_fix = 1000
    ######### INITIALIZE ##############
    control.initialize(exp)
    
    fixcross = stimuli.FixCross()
    fixcross.preload()
    
    block = design.Block(name="block_all")
    for (l, r) in zip(listLEFT, listRIGHT):
        trial = design.Trial()
        trial.set_factor("Left_im", l)
        trial.set_factor("Right_im", r)
        canvas = stimuli.BlankScreen()
        l_image = stimuli.Picture(l, position=(-200, 0))
        r_image = stimuli.Picture(r, position=(200, 0))
        l_image.plot(canvas)
        r_image.plot(canvas)
        l_image.preload()
        r_image.preload()
        canvas.preload()
        trial.add_stimulus(canvas)
        block.add_trial(trial)
    block.shuffle_trials(block)
    exp.add_block(block)
    
    exp.data_variable_names = ["block", "trial", "Left_im", "Right_im", "Key", "RT"]
    ######### START ##############
    control.start(exp)
    
    for block in exp.blocks:
        for trial in block.trials:
            fixcross.present()
            exp.clock.wait(t_fix)
            canvas.present()
            btn, rt = exp.keyboard.wait([misc.constants.K_LEFT, misc.constants.K_RIGHT])
            exp.data.add([block.name, trial.id, trial.get_factor("Left_im"), trial.get_factor("Right_im"), btn, rt])
    

    In this case, the two images presented in each trial are always same while the exported data shows the images in left and right sides changed correctly every trial.

    Is there any way to counterbalancing the positions across participants, and what is the cause that the same stimuli are presented?

    Thanks

  • rrrrrr
    edited February 2017

    Hi,

    I found the cause of same stimuli.
    It was caused by canvas.present(). It runs as below by changing canvas.present() to trial.stimuli[0].present().

            block = design.Block(name="block_all")
            for (l, r) in zip(listLEFT, listRIGHT):
                trial = design.Trial()
                trial.set_factor("Left_im", l)
                trial.set_factor("Right_im", r)
                canvas = stimuli.BlankScreen()
                l_image = stimuli.Picture(l, position=(-200, 0))
                r_image = stimuli.Picture(r, position=(200, 0))
                l_image.plot(canvas)
                r_image.plot(canvas)
                l_image.preload()
                r_image.preload()
                canvas.preload()
                trial.add_stimulus(canvas)
                trial.preload_stimuli()
                block.add_trial(trial)
            block.shuffle_trials(block)
            exp.add_block(block)
    
        exp.data_variable_names = ["block", "trial", "Left_im", "Right_im", "Key", "RT"]    
            ######### START ##############
            control.start(exp)
    
            for block in exp.blocks:
                for trial in block.trials:
                    fixcross.present()
                    exp.clock.wait(t_fix)
                    trial.stimuli[0].present()
                    btn, rt = exp.keyboard.wait([misc.constants.K_LEFT, misc.constants.K_RIGHT])
                    exp.data.add([block.name, trial.id, trial.get_factor("Left_im"), trial.get_factor("Right_im"), btn, rt])
    
            ####### END EXPERIMENT ########
            control.end()
    

    I'm still looking for the clear way of counterbalancing the positions across participants.
    Are there any suggestions?

    Thanks!

  • How about creating a between-subject factor "picture_arrangement" with two levels ("x_is_left", "x_is_right"):

    import expyriment
    
    exp = expyriment.design.Experiment("My Experiment")
    exp.add_bws_factor('picture_arrangement', ['x_is_left', 'x_is_right'])
    

    And then later in the experiment (after calling expyriment.control.start(), i.e. after a subject ID has been entered):

    if exp.get_permuted_bws_factor_condition('picture_arrangement') == "x_is_left":
        # Present arrangement
    else:
       # Present other arrangement
    
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