Howdy, Stranger!

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

Supported by

Error with conditional statement

edited September 2018 in OpenSesame

This is regarding a small dissertation project. I am trying to implement a masking paradigm in opensesame. The design is as follows:

The experiment starts with a mask (## symbols) 480ms followed by a cue the position of the cue on the screen is determined by a variable "cuetype" which has 4 levels. This is again followed by a mask 22ms. This is followed by a prime which is may be presented for either 27 ms (prime condition) or 160 (normal condition). The prime's location and cue's location can be same or different. The prime is followed by mask which is presented for 80 ms. Which is followed by target screen where the subject has to determine if the screen bears a predetermined target or not. The target's location can be same as it was of cues location or it can be different.
Design: cuetype (4) X prime location (4) X Condition (2: 27 ms prime condition; 160 normal condition)

The subject is instructed to see if the target displayed is equal either 2 or 4 or 6 or 9. I have added a inline script to determine the correct response:

target_set = [2,4,6,9]
numbers = range(1,10)

num = random.sample(numbers,1)

for i in target_set:
    if i==num:
        var.correct_key=='.'
    else:
        var.correct_key=='z'

I have also written a piece of code to determine if the trial was congruent or incongruent

So if the cue's location is same as of target's location it is a congruent trial else its an incongruent trials:

if var.cuetype==var.location:
    var.congruency='cong'
else:
    var.congruency='incong'

I have added separate sketchpads to present cues at different locations. I have edited the conditional statements so that those sketchpads are presented when it matches with entry on loop of cuetype or prime location. Thus, there are 4 sketchpads for cues, sketchpad for prime and 4 sketchpad for target (which are matched by cuetype)
Running the experiment shows me a very strange error

'' is not a valid conditional statement

I have attached the experiment file.

Can someone please help me resolve this ? :/
@sebastiaan this is not the first time I have encountered an error relating conditional statements. Am I doing something wrong or is it bug??

Thanks

Vatsal

Comments

  • Hi Vatsal,

    The prime items have a textline element in them that have an empty show-if statement:

    draw textline center=1 color=white font_bold=no font_family=mono font_italic=no font_size=28 html=yes show_if="" text="[=num[0]]" x=-64 y=-64 z_index=0
    

    I'm not sure how this happened, but it's easily resolved by simply replacing the show_if="" by show_if="always".

    Cheers!
    Sebastiaan

  • Hey @sebastiaan

    Thanks for pointing out that. It was so silly of me. However, I have been experiencing another error now:

    `Traceback:

    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libqtopensesame\misc\process.py", line 154, in run
    exp.run()
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\experiment.py", line 449, in run
    self.items.execute(self.var.start)
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\item_store.py", line 103, in execute
    self.run(name)
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\item_store.py", line 122, in run
    self[name].run()
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\sequence.py", line 51, in run
    self.experiment.items.run(_item)
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\item_store.py", line 122, in run
    self[name].run()
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\loop.py", line 341, in run
    self.experiment.items.execute(self._item)
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\item_store.py", line 102, in execute
    self.prepare(name)
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\item_store.py", line 142, in prepare
    self[name].prepare()
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\sequence.py", line 124, in prepare
    self.experiment.items.prepare(_item)
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\item_store.py", line 142, in prepare
    self[name].prepare()
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\sketchpad.py", line 143, in prepare
    temp_name = element.draw()
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\sketchpad_elements_textline.py", line 63, in draw
    properties = self.eval_properties()
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\sketchpad_elements_base_element.py", line 244, in eval_properties
    self.sketchpad.syntax.eval_text(val, round_float=round_float))
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\syntax.py", line 315, in eval_text
    val = self.experiment.python_workspace._eval(py)
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\python_workspace.py", line 191, in _eval
    return eval(bytecode, self._globals)
    File "", line 1
    num[0
    ^
    SyntaxError: unexpected EOF while parsing`

    Is there an easier way to display items generated from inline script?? Should I do use the python inline script to draw canvas and display the item?

    I have attached the experiment file.

    Thanks
    Vatsal

  • Hi Vatsal,

    You can present canvases also via inline-scripts. Check out this to get an idea how.

    Eduard

    Buy Me A Coffee

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