Howdy, Stranger!

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

Supported by

[solved] pseudo-randomisation

edited October 2015 in OpenSesame

Hi everyone,

I am a novice in using OpenSesame and python. I would like to be able to program a pseudo randomisation of my durations.

In my protocol, I have 2 variables:

1/ Facial expression: neutral, sad, happy, angry, fear

2/ Duration: 400 ms, 600ms, 800ms, 1000ms ,1200ms, 1400ms ,1600ms

For a trial, I show a facial expression (e.g sad) for a certain duration ( e.g 400ms).

In my experience I have 35 combinations = 5 (facial expression) x 7 durations
For each combination I must have 8 trials

However, it is necessary that in the first seven trials I show all my durations.
The same thing for trial 8 at 14, trial 15 at 21 etc……

image

Could you, please, help me?

Thank you very much! Agnès

Comments

  • edited 2:29AM

    Hi Agnès,

    Normally you would have a loop item running a (trial-)sequence item, with all conditions appearing at random, meaning you'd have no guarantee of having all durations appear every 7 trials. To take control over this, you could place another loop item within your loop item item, and make sure the trial sequence is contained by the second loop item rather than the first one. (So in total you'd have a loop containing a loop containing a sequence).
    Next: in the second loop item, you create the variable duration, and let it have 7 cycles containing the values 400 to 1600. Each cycle should be run 1 time. If I'm correct, all durations occur 40 times (8 times with each of the 5 faces). So the first loop should run the second loop 40 times.
    We now need to make sure that all duration/face combinations occur evenly. To do that, you need 7 lists, that each contain each emotion 8 times. Place an inline_script at the top of your experiment, and create 7 lists by means of

      dur_400 = []
      dur_600 = []
      dur_800 = []      # et cetera.
    

    Then you want to add emotions to them. Either you could insert the 40 emotions to each list by means of adding them manually (e.g. change [] into ['sad','sad'...], or by creating a for loop:

      emotions = ['sad','happy','angry','afraid','neutral']
    
      for i in range(0,8):
            for j in range(0,5):
                   dur_400.append(emotions[j])
                   dur_600.append(emotions[j])
                   dur_800.append(emotions[j])  # et cetera.
    

    You then want to give these lists a shuffle:

      import random
      random.shuffle(dur_400)   # as well as the other lists
    

    Finally, in the (trial-)sequence item you can insert another inline_script, and here we will create the variable that sets the emotion for that specific trial:

      duration = exp.get('duration')
      if duration == 400:
            emotion = dur_400.pop(0)  # takes first element from list.
      elif duration == 600:
            emotion = dur_600.pop(0)  # and so forth.
    

    If you're using a sketchpad in the sequence to display your stimuli, make sure you 'set' the emotion variable so it becomes available outside of the inline script:

      exp.set('emotion', emotion)
    

    In the sketchpad, the duration can be set to [duration], and the image will be [emotion].jpg (of course that is if you actually named your pictures happy.jpg and such).

    Good luck!

    Josh

  • edited 2:29AM

    Solved problem
    Thanks a lot for the solution

    Agnès

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