Howdy, Stranger!

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

Supported by

[solved] Randomly present 2 stimuli from 2 lists

edited May 2015 in OpenSesame

Hello,

I am attempting to build an experiment where I will present two picture stimuli at once side by side (either on a sketchpad or as image buttons) in a random order and on random sides of the screen. One of the stimuli will be a 'real' while the other will be a 'foil'. Participants merely have to select one of the two stim.

Randomizing presentation on different sides of the screen for 'real' and 'foil' should be easily taken care of by a loop's built in randomization function (just divide trials in half for different sides). The real trick is determining how to draw from the file pool a random image that 1) has not been displayed before, and 2) is from a specified sub-pool (i.e., real or foil). Real and foil picture stim are matched, so there is an even amount.

I'm sure this is doable with some python coding, but it appears to be a bit beyond my coding prowess. Any help you can offer directing me in the right direction would be greatly appreciated!

Thanks,
Dan

Comments

  • edited May 2015

    Hi Dan,

    One way to go about this would be to insert an inline_script item, where you create two lists of all the images (e.g.: real_images = ['image1.png', 'image2.png', 'image2.png'])
    Every trial, you'd pick a random item from each list; there's a command that picks one and removes that item from the list as well, so you cannot pick it a second time: real_pick = real_images.pop(0) 'pops' the first element from the list. All you need to do now is shuffle the list before you pop: random.shuffle(real_images). Before you can use this command you need to insert 'import random' at the top of the inline script.

    Of course you also need to determine the random side the two pictures will appear on - e.g.: foil_side = random.pick('left', 'right'), and also:

      if foil_side == 'left': 
           real_side = 'right'
      else:
           real_side = 'left'
    

    So, you'll end up with a bunch of variables that together contain all the information you need for a trial. Now you just need to make them available outside the inline_script as well (so you can call them e.g. in a sketchpad). you can do this by inserting exp.set('foil_side', foil_side), exp.set('real_pick', real_pick) et cetera.

    Let me know how it goes!

    Cheers,

    Josh

  • edited May 2015

    Hi Josh.

    Thanks for your reply! I think that this will satisfy my experimental requirements. Two quick follow up questions, as I am still having a bit of trouble getting the experiment to run. First, I replaced random.pick with random.choice, as the former was not recognized when I attempted to run it.

    Second, I keep getting the error 'An empty string was passed to experiment.get_file(). Please specify a valid filename" when I attempt to run the experiment. Any ideas as to what may be causing this error? I apologize if it is a simple or easy fix, but I can't seem to shake the error on my own.

    I've reproduced my inline_script code and the full experiment code (http://pastebin.com/jan3Py1S) if you want to reference it. Thanks again for helping out!

    import random
    
    real_images = ['subject_nr_1061.jpg', 'subject_nr_1062.jpg', 'subject_nr_1063.jpg', 'subject_nr_1064.jpg']
    
    foils = ['Foil_00001_ori.jpg', 'Foil_00002_ori.jpg', 'Foil_00003_ori.jpg', 'Foil_00004_ori.jpg']
    
    random.shuffle(real_images)
    random.shuffle(foils)
    real_pick = real_images.pop(0)
    foil_pick = foils.pop(0)
    
    side=['left','right']
    foil_side = random.choice(side)
    if foil_side == 'left':
        real_side = 'right'
    else:
        real_side = 'left'
    
    exp.set('foil_side', foil_side)
    exp.set('real_side', real_side)
    exp.set('real_pick', real_pick)
    exp.set('foil_pick', foil_pick)
    
  • edited 1:30AM

    Hi Josh.

    Some follow up: I seem to have figured out my issue with some trial and error. However, it doesn't appear that the images are being removed from the list after they are presented once. I'm thinking that this is an issue of where the inline_script is placed within the experiment. Before I had it outside of the trial loop, but this caused only one image to be shown. Moving it inside the loop allowed for the desired effect, but the images are being repeated now.

  • edited May 2015

    A final follow up in case anyone else has the same issue: After a a few hours of fiddling around with the code and the order of the experimental parameters, it appears that you have to make the list in an inline_script outside of your trial loop, then call on the list inside your trial loop (i.e., image.pop()). Again, thanks to Josh for helping me work through this!

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