I have an experiment that involves presenting two images, participant clicks one of them and a feedback (points) with certain probability appears. The feedback is different for each image. There are 6 loops each containing different pair of images leading to a specific feedback for that image, and there are 100 trials in each loop.
Is it possible to present the images bounded to certain feedback in random location (right vs. left) between participants, but keep the location constant for each participant?
I tried this: in the routine AFTER participant made a choice, I put the code component for certain feedback to appear:
File âC:\Users\u1664328\Dropbox\1. Alina\Project\Computational and Mathematical Modeling of Behaviour and Cognition\1.My Project\2. Description-Told Group\DescriptionTold.pyâ, line 492, in
image.setPos(unchosenpos)
NameError: name âunchosenposâ is not defined
There are a number of reasons why the unchosenpos variable can be undefined at the time it is referenced.
In this case, the most likely reason is that none of your conditional statements are executed. event.getKeys() returns a list, even for a single key press (hence getKeys rather than getKey). So you should do a test like this:
if 'left' in keys:
rather than:
if keys == 'left': # will always be untrue as keys is a list
Also note that you are mixing references to your own variable keys and some other variable response.keys. Which one are you actually wanting to test?
In block1 loop there is an .xlsx file that specifies the odds of getting certain points for each image for 100 trials:
I tied this:
1.
if 'left' in keys and left11 == 'red.png':
Get Error:
Description-Told Group\DescriptionTold.py", line 500, in <module>
image.setPos(unchosenpos)
NameError: name 'unchosenpos' is not defined
keys = event.getKeys()
if 'left' in response.keys and left11 == 'red.png':
Get Error:
##### Running:
pyo version 0.8.0 (uses single precision)
Traceback (most recent call last):
Description-Told Group\DescriptionTold.py", line 469, in <module>
if 'left' in response.keys and left11 == 'red.png':
TypeError: argument of type 'NoneType' is not iterable
Traceback (most recent call last):
File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.2-py2.7.egg\psychopy\app\coder\coder.py, line 2638, in copy
foc.Copy()
AttributeError: 'AuiTabCtrl' object has no attribute 'Copy'
My question:
I canât get my head around how can I randomise the location of two images (that are bound to certain odds of getting points) between participants. Is there a way?
Also, what should I put in image and location for left11 and right11 images in Trial routine?
This line should deleted as you are using a keyboard component to check for keypresses:
keys = event.getKeys()
Because you are using a keyboard component rather than event.getKeys(), and presumably have it set to react to just a single key, you should indeed go back to using:
if response.keys == 'left'
as the keyboard component does just return a single key in that situation rather than a list (hence the error about about not being able to iterate.
Lastly, Iâm not sure where 'red.png' comes from (as it isnât in your conditions file), but you canât test whether an image component (left11) is equal to a string of characters representing a filename. They are quite different beasts. Iâm not sure what is really desired here, but probably you want to check whether the filename associated with that image component is 'red.png', in which case, I think you need to do something like this:
if left11.image == 'red.png'
But presumably you know which image files are being used for the stimuli if they arenât varying (i.e. coming from a conditions file), so not really sure what this test is for.
I donât really understand your questions in the last paragraph, as they are very broad. Perhaps just resolve your issues one a time before introducing other things.
My questions in the last paragraph are the main ones that I try to overcome with the code. That is, put the images (âred.pngâ or âgrey.pngâ) in the random location in Trial and then, depending on the location and the choice of a participant, show a feedback with certain probability.
Can I somehow randomise all 12 images (for 6 different lotteries) across all loops, in a way that, for example:
Participant 1 gets red image (or yellow or green) on the right, and grey (or purple or blue) image on the left. If he chooses ârightâ in this trial, he gets 5 points in 100% times. If he chooses âleftâ, he gets 6 points with 90% chance or 0 points otherwise. Red and grey images should stay in these positions for all 100 trials, bound to the same feedback and never appear in the next loops.
Participant 2 gets grey image (or yellow or green) on the right and red (or purple or blue) image on the left. Again, for example, if he chooses ârightâ, he gets 5 points in 100% times. If he chooses âleftâ, he gets 6 points with 90% chance or 0 otherwise. Again, the pictures should stay in these position for all 100 trials, bound to the same feedback and not appear in the next loops.
So, it doesnât matter which colour is bound to which feedback, but itâs important that itâs consistent for one participant for all 100 trials, doesnât occur again in the consequent loops and changes for the next participant.
Iâm not sure what code and where should I put it to implement this randomisation between participants.