#### 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

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.

@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

• 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

There's much bigger issues in the world, I know. But I first have to take care of the world I know.
cogsci.nl/smathot

• 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
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