Howdy, Stranger!

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

Supported by

Assigning SOA randomly without repetition with Inline Script

S_HS_H
edited May 2016 in OpenSesame

Hi Everyone!
I'm trying to run a loop of 105 Prime-Target stimuli while each Prime-Target pair will be called randomly and will be assigned with a random SOA from 105 SOAs list. I'm having a problem with the SOAs assigning.

Before the Prime-Target loop, I set in Inline_Script the variables as follow:

import random
self.experiment.set("ChooseSOA",0)
ChooseSOA=[100 for i in range(50)]+[200 for i in range(55)]
random.shuffle(ChooseSOA)

Then, in the sequence running in the loop I wrote:

 self.experiment.set("SOA", self.experiment.get(ChooseSOA.pop()))

Then, I added a sketchpad with the duration "SOA".

when I'm running the experiment, the OpenSesame says:'int' object has no attribute 'pop'

Help? Anyone?

Comments

  • edited 1:07PM

    Hi S_H,

    Using print in inline script might give you some insight in a situation like this.

    print self.experiment.get("ChooseSOA")
    

    will print '0'

    print ChooseSOA
    

    will print your list [100, 100, 100, 200, etc. ]

    Basically you use both a local and a global variable ChooseSOA. You could make this work by filling the global variable ChooseSOA with you local list instead of '0' like this:

    import random
    ChooseSOA=[100 for i in range(50)]+[200 for i in range(55)]
    random.shuffle(ChooseSOA)
    self.experiment.set("ChooseSOA",ChooseSOA)
    

    Another thing; instead of

    self.experiment.set("SOA", self.experiment.get(ChooseSOA.pop()))
    

    you want to use

    self.experiment.set("SOA", self.experiment.get('ChooseSOA').pop())
    

    because you are trying to pop a value from list self.experiment.get('ChooseSOA')

    And last but not least if you are using OpenSesame 3 you want to be using the var object

    Hope this helps and please correct me if I'm wrong,
    Jarik

  • S_HS_H
    edited 1:07PM

    Dear Jarik!
    Thank you very much for your kind answer!

    I rewrote my code according to your detailed suggestions and now I'm having: "'unicode' object has no attribute 'pop'".

    I used print in order to spot the problem. at the end of the first script I wrote print(len(ChooseSOA)) and the length was 105, as it should be. at the beginning of the second script(before setting "SOA") I wrote print(len(self.experiment.get("ChooseSOA"))) and it oddly printed 616.

    Do you have any idea what am I doing wrong now? :(
    (btw, I am using version 2.8.7 and I'm not able to update it at the moment...)

    Thanks!

  • edited 1:07PM

    Couldn't find 2.8.7 so I used 2.9.7 to test:

    I think you will be OK using the local variable ChooseSOA because all inline_script items share the same workspace:

    self.experiment.set("SOA", ChooseSOA.pop())
    print self.experiment.get("SOA") #to check
    

    Note you will have to do

    self.experiment.set("ChooseSOA",ChooseSOA)
    

    after the shuffle if you want to be able to log the complete ChooseSOA list with the logger item!

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