[open] Stimulus presentation, keyboard timing and feedback beep
Hi everyone!
I have had a lot of help from this forum for creating my Face Flanker task, so thanks so far!
It's a version of the Eriksen & Eriksen (1974) visual noise stimuli task.
I have a problem to do with stimulus timing, keyboard response timing and feedback sounds.
Basically, I want to present a set of three stimuli for 300ms, then present a visual mask for 3000ms, all the while polling for a SHIFT key response, left or right, and when a shift key is selected, I want a beep to sound, to let the participant know that their response has been recorded, and I want the loop to progress past all this once a correct or incorrect response is recorded. I want the participants reaction time (in ms) to be recorded in one data variable, and whether their response was correct also in one variable.
I have had several tries at organising all this into an experiment file, but I have not been able to achieve all those requirements in one attempt. It seems any arrangement of objects I try within a loop (see my three versions below), there is always one or more elements that I am missing. There are three different attempts at this that I would like to show you lovely people to see if one of them is capable of doing all I need.
Version 1.
https://www.dropbox.com/s/eef6fynmqv8g3m9/GM_take_5.osexp?dl=0
http://i.imgur.com/GyWXZVA.png
This version is just a logical progression of stimuli (300ms), then mask (1ms), then keyboard response (3000ms; so the sketchpad and the keyboard response both technicall run for 3000ms), then beep. The issue with this version is that if the participant responds within the first 300ms, no response is recorded. Theoretically, a response before 300ms is quite unlikely, but my supervisor and I do not want to have a systematic loss of some data. All ms response times, due to the keyboard polling beginning after the 300ms stimulus therefore need 300ms added onto it. A script to do that I have not had success in creating.
Version 2.
https://www.dropbox.com/s/iyriotu66b5ldd4/GM_take_5_Coroutines_Edit.osexp?dl=0
http://i.imgur.com/45WzHDF.png
This version uses the coroutines plugin for 3300 ms; 0-300ms are the stimulus, and from 300ms onwards, the mask is presented. The keyboard response item runs the entire 3300ms. The issues here are that a beep sound cannot be included into the coroutine, so participants do not have feedback when their response is recorded. This also means if participants hit a response key more than once, the keyboard response item seems to only log the latest keyboard press.
Version 3.
https://www.dropbox.com/s/tptxzf3xuhqeedw/GM_take_5_Two_KB_Inputs.osexp?dl=0
http://i.imgur.com/mE6Z5X3.png
This version uses two keyboard response items, one after each sketchpad. While this is arguably the most logical of the three versions, I have not had luck in having two beep items run conditionally on whether a response key was entered previously, nor was I able to have the visual mask sketchpad and the second keyboard response item run conditionally also; it just seemed that they ran every time. This organisation also gave me two keyboard responses, one of which was a timeout, the other would contain useful response time data. Also, in the output it is not apparently clear whether the participant actually pressed the right key.
I am hoping there might be a way to meet all the requirements I would like from my OpenSesame task. Any input you might have will be greatly appreciated!
Thanks!!
Rhett
Comments
Hi Rhett,
How about a version 4
I hope this code makes sense to you. It doesn't work as it is right now, because I don't have defined any canvases and also no sound. If you need help, just ask or check out the documentation on how to do these kinda things in
inline_scripts
: http://osdoc.cogsci.nl/python/ (in particular, check outcanvas
andsampler
)Good luck,
Eduard
Edit: To log the variables, you either have to use
log.write_vars()
in the end of your code, or add alogger
item after theinline_script
.Hey Eduard!
I think I am beginning to understand your code. Thank you very much for your response!
The actual stimulus sketchpad consists of three images displayed along the x axis. Their filenames are variables that are randomly changed within the experiment loop.
When I run your code, with the canvas defined in the prepare stage, it says that the variables that are the file names (i.e. one image points to [Center_Object].jpg, and [Center_Object].jpg has different values (i.e. Face_1, Face_1, etc) between each set) are not defined.
How do I prepare sketchpads in advance of running that script, where objects within the sketchpad are linked to variables?
Thanks!!
Rhett
Hi rhett,
If you want to draw 3 images on one canvas, you need to provide all the names for each file. One way to get this done rather easily, is to have three variables in the loop table, e.g. file1, file2,file3. Later in the inline_script, you then have to initialize and draw the images on it.
Of course, you need to make sure that the filename is a valid path to the files.
Is this what you wanted to know? Let me know if you need more info.
Good luck,
Eduard
Hey Eduard,
I actually have the code in place for the images, but in the 'loop' object, there are variables (center object, left object, right object) that change between sets (i.e. center object becomes t_n1.jpg, left object becomes t_t1.jpg, etc)
In the code, it looks like this http://imgur.com/a/LhKOc
Hope this helps to elucidate my question!
Thanks!
Rhett
Hi Rhett,
Sorry for the late response. Unfortunately, I'm still unsure whether I understand your issue. Let's take a step back and make sure we're on the same page.
With "change between sets", do you only mean, that the file names are different between trials of your experiment, or in some other way?
According to how I understand your design, the only thing that changes between trials is which images are presented. Everything else (position,timing, response sampling) doesn't change, right? If so, which parts of the design are already working as you want them to?
Nice. But again, according to my understanding, having the image presenting part set, goes hand in hand with having the
loop
structure set. If this is not the case for you, maybe you should consider rethinking the image presentation code?I hope this make sense. Let me know whether I get you right.
Good luck,
edaurd
Hey Eduard,
Thanks for your patience.
I'll step it back~
In the 'prepare' phase of my script, I have the stimuli and mask sketchpads written up (as per the screenshot in my comment above)
The path of the file is path = exp.pool[[Flank_Object].bmp], 'Flank_Object' is a variable that changes between trials, from t_t, to t_t2 etc. The files in the file pool are named t_t1.bmp, t_t2.bmp etc
When I run the OpenSesame task, it errors out when it comes to running the script part (i.e. it runs everythins before that) saying:
item-stack: MainRun[run].Tr_Face[run].Tr_Face_Seq[prepare].Tr_Face_Script[prepare]
exception type: NameError
exception message: name 'Flank_Object' is not defined
item: Tr_Face_Script
time: Fri Apr 01 10:38:22 2016
phase: prepare
Any idea as to what might be causing this?
Here's a link to the experiment at this point in time~ http://bit.ly/1Y2SjFp
Thanks!
Rhett
Hi Rhett,
Here a version of that prepare phase that doesn't throw an error:
A couple of comments:
once you created an instance of a canvas (let's say, you called it my_cv), you have to use this label to call all the canvas functions. That is use
my_cv.image()
instead ofcanvas.image
It might be easier and more efficient, if you're loop table already contained the path towards the files, not just the name, so also including the suffix (instead of
t_n1
, uset_n1.BMP
as value in the table). Once you do it that way, you don't have to go through the trouble of adding the extension to the file (the main reason why it didn't work for you)when you want to access variables that you define in the
loop-table
from within aninline_script
, it is not [variable] (like it would insketchpads
and such), but rathervar.variable
.I hope this makes more sense now.
Eduard
Hey Eduard,
Thanks for your help! I think that resolves that problem!
However, some other ones have come up.
Firstly, the fixation cross only appears after the first set of facial images, and not before. I can't decipher what is telling the faces to appear prior to the fixation dot?
Secondly, past the fixation dot / facial mixup, the experiment errors out, claiming that response_time is not defined. I have not had to define it in my other loops (i.e. the ones I have not implemented your code in) and it records time accurately in those loops. What am I missing?
Thanks again for your help!
Rhett
Hi Rhett,
Are you sure that the fixation cross is really not there? Sometimes, it just appears so, but in fact Opensesame proceeds to the next item super quickly, so that you just can't see it. In this case, changing the
duration
feature would fix it. Maybe it is also a problem of the ordering of the items in your experiment? Obviously, things that appear first in a sequence are executed first. I guess these are the most likely reasons for the fixation cross to not appear.I'll have a look on it tomorrow, and let you know what could have caused that.
Eduard
Hey Rhett,
the script in
TR_Face_Script
has code in theprepare
and in therun
phase. Of all elements in asequence
Opensesame executes first all prepare phases and moves then on to the run phase. This probably explains your first problem, right?Indeed, the variable
response_time
is not defined, still you want to log it. The variable that logs the response time in your firstsequence
is calledvar.resp_time
. So you would have to use this variable name to log it. However, variables with the prefixvar
are automatically logged. So you don't need to add it manually.Does this help?
Eduard