[open] Random Time Display for Sketchpad?
Help...
I am trying to devise a flanker task in open sesame. I have created 1 experiment with 3 loops to hold a practice session (loop 1) and two trials (loop 2 and loop 3). Each loop contains a sketchpad with cross-hairs. I would like for each sketchpad to be displayed a random time between 800 - 2000 ms. (Can open sesame can do this?)
From browsing the web and the help of a colleague (Thank you, drogers!), I have tried to put together a script, but have not succeeded due to an alarming amount of pop-up errors. These are the sources I've used to create the script:
http://osdoc.cogsci.nl/python-inline-code/inlinescript-functions -- using 'self. experiment.set ()' for setting a variable
http://osdoc.cogsci.nl/python-inline-code/code-snippets -- example code
http://docs.python.org/library/random.html#random.randint -- brief description of how to generate a random integer N, a<=N<=b
And, here's the script:
# Set variable time
self.experiment.set("random820", "N, 800<=N<=2000") Setting variables to time self.experiment.set("cross_display", "random820") Getting variables print self.get("cross_display") Checking whether a variable exists if self.has("cross_display"):
print "cross_display exists" *** end of script ***
-- random820 is the random time value generated, between 800ms and 2000 ms.
-- cross_display is the variable to be assigned to time value.
I'm unable to run the experiment because of this error (or a variation of this error):
Error: Runtime error
Description: Variable 'random820' is not set in item 'crossp'.
You are trying to use a variable that does not exist. Make sure that you have spelled and capitalized the variable name correctly. You may wish to use the variable inspector (Control + I) to find the intended variable.
When I use the variable inspector, I am able to find the variable easily. After double-checking spelling and capitalization, there seems to be no error there. I'm not sure if the variable is correctly coded or if I'm placing the script in the correct location.
I've tried a few different variations on creating the variable, but they have not worked:
self.experiment.set("random820", "800<=random820<=2000")
self.experiment.set("random820", "800 <= N <= 2000")
self.experiment.set("random820", "800<=N<=2000")
self.experiment.set("random820", "N, 800<=N<=2000")
I have tried putting the inline-script immediately before the sketchpad (in the beginning of the loop) and immediately after the practice instructions (in the beginning of the experiment) with no success.
Link to open sesame file in dropbox: https://www.dropbox.com/s/6cjrbmikcjaibfb/flanker2.opensesame.opensesame.tar.opensesame.tar.gz
I hope that I have provided enough descriptions of my problem, but if not please feel free to message me back. Any kind of feedback would be great(!) Thank you.
Sarah
Comments
Hi Sarah,
I think if you make the following changes your experiment will be good-to-go:
If you want this value to vary between trials you should set "random820" with an inline script in every trial sequence rather than the experimental sequence. (Otherwise a random value is picked once, and used for the remainder of the experiment.) Also, you should put your script in the Prepare phase of your inline script instead of in the Run phase. After applying all this, you can use "random820" to determine the duration of a sketchpad by setting the duration to [random820], like you did in the practice sequence (but not in the sequence1 and 2).
And finally, I noticed that for one of your images the extension was typed as ".png", whereas ".PNG" is expected since you used "[pic].PNG" in the sketchpad editor. Depending on your operating system this could be problematic.
Does this solve your problems?
Please let us know if you have any further questions.
Best wishes,
Lotje
Did you like my answer? Feel free to