[open] Problem Accessing Global Variables
Hi there,
I'm currently designing an IAT experiment for an android tablet, but I'm having a couple of issues at the moment that I've been searching for answers too since last night so I thought I'd ask on here. I'm currently in the process of building an Implicit Association Task with Open Sesame, and I'm wanting to record the average reaction time of only answers for which the correct answer was '1', per block of trials. I then want to store that in a new global variable that can be called later and displayed / used to work out a ratio at the end.
The first problem with doing this is that I haven't got any idea of how you would only select certain cases(' reaction times), without waiting until the data has been outputted to a CSV and doing it manually, which would be very time consuming for the purposes of the one measure I'm taking from this study (a ratio of first block to second block answers), so I was hoping it could be automated in code?
The second problem I'm having (also variable related) is that my variable is semi-working (passes along the value - although seemingly as the variable name) but crashing the experiment with an error.
In an in-line script tag just after the first block of trials, I have:
practiceIdRt = exp.set('practiceIdRt', [avg_rt])
Immediately after the inline script there is a feedback form where I tried displaying it:
draw textline 0 128 "[practiceIdRt]" center=1 color=white font_family="mono" font_size=18 font_italic=no font_bold=no show_if="always" html="yes"
I also tried displaying it with self.get('practiceIdRt'), and several other variations which the programme didn't like either. At present it will run until the feedback page, when the experiment will crash, serving the error:
"Variable '787' is not set in item 'idFeedback'.
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."
The variable name it's giving is obviously the average reaction time, but I don't understand why or how to fix it. I've tried several variations on the syntax, and of all of them this is the only one that shows any sign of passing along the value of the variable. I've also tried it in the Prepare and Run sections, I've also tried calling it within a feedback or sketchpad item, but nothing seems to work.
EDIT: Having fiddled further with it, it appears that it works perfectly fine using psychopy for the backend, but crashes using all the others. Is there a difference in the way the back ends handle variables that I'm missing?
Thank you,
Nick
Comments
Hi Nick,
On you first problem: there is nothing you ever have to do manually, if you know how to program well enough. The CSV output can indeed be analysed using a spreadsheet editor like Excel, which offers you functions like
IF
andSUMIF
that seem perfectly fit for what you want to do. Another option is to read the files using a custom script, written in a programming language like Matlab or Python (e.g. using NumPy).Your second problem originates from a bit of confusion between Python inline scripting, and OpenSesame syntax. In an inline_script, the language to use is Python. To access an OpenSesame variable in Python, use the following:
my_var = exp.get("avg_rt")
. To use the exact same variable within all other bits of OpenSesame, use the square bracket notation used in OpenSesame syntax:[avg_rt]
.For the full explanation, see this page.
Good luck!