Win10
PsychoPy3 (v2020.1.3)
Standard Standalone? (y/n) yes
What are you trying to achieve?:
I have 42 images, which I want to show one by one in a set order. The participant has to selcect with each image, if the image belongs to the indicated category by clicking on the image. So “yes” means clicking on the image and “no” means clicking on a small text button under the image (like “No, next”). I want to show a feedback to the participant, so I want the image to turn green if they click on it. This selection should be able to undo. Best case scenario, all clicks and undone clicks should be stored in the csv file and also be compared to a list which has the correct answers for each image.
This is my code component so far:
My Mouse component ist called “mouse_Indiv”
Beginn Experiment:
# Add all your image variables to a list
imagesIndividual = [image_Folie37, image_Folie2, image_Folie33, image_Folie8, image_Folie38, image_Folie18, image_Folie21, image_Folie4, image_Folie14, image_Folie42, image_Folie31, image_Folie13, image_Folie27, image_Folie34, image_Folie7, image_Folie20, image_Folie15, image_Folie29, image_Folie32, image_Folie1, image_Folie22, image_Folie23, image_Folie36, image_Folie11, image_Folie12, image_Folie25, image_Folie40, image_Folie10, image_Folie6, image_Folie28, image_Folie19, image_Folie41, image_Folie24, image_Folie9, image_Folie35, image_Folie16, image_Folie5, image_Folie39, image_Folie3, image_Folie26, image_Folie17, image_Folie30]
Each frame:
for stimulus in [image_Folie37, image_Folie2, image_Folie33, image_Folie8, image_Folie38, image_Folie18, image_Folie21, image_Folie4, image_Folie14, image_Folie42, image_Folie31, image_Folie13, image_Folie27, image_Folie34, image_Folie7, image_Folie20, image_Folie15, image_Folie29, image_Folie32, image_Folie1, image_Folie22, image_Folie23, image_Folie36, image_Folie11, image_Folie12, image_Folie25, image_Folie40, image_Folie10, image_Folie6, image_Folie28, image_Folie19, image_Folie41, image_Folie24, image_Folie9, image_Folie35, image_Folie16, image_Folie5, image_Folie39, image_Folie3, image_Folie26, image_Folie17, image_Folie30]:
if mouse_Indiv.isPressedIn(stimulus):
stimulus.setOpacity(.9) # fade image to show it was clicked
stimulus.setColor = 'green'
#if mouse_Indiv.isPressedIn(stimulus) == 1:
#stimulus.setOpacity.reset(0)
#stimulus.stim.color.reset
for clicked in mouse_Indiv.clicked_name:
# Check the list of clicked images
if clicked.imagesIndividual in [corrAnsIndiv]:
# is the clicked image name in the list of correct answers
response = 1 # 1 for correct
else:
response = 0 # for incorrect
thisExp.addData("responseCorrIndiv", response)
# store the correct answer in your datafile
# end the trial once done here:
continueRoutine = False
# stop any further checking:
break
I’m getting an error message in the “Each frame” Tab with setting the color, reseting the click &color again and the last “for …” python code.
The problems:
- After clicking on the first image the experiment crashes without ever turnig green and an error message appears, e.g.:
if clicked.imagesIndividual in [corrAnsIndiv]:
AttributeError: 'str' object has no attribute 'imagesIndividual'
##### Experiment ended. #####
(I’ve changed “imagesIndividual” to “stimulus” or “images” but nothing works…)
- The first image shown ist not the one I set to be the first one, although I selected “sequential” in the Routine Loop.
Pretty sure the Python code snippet is somehow wrong but I have tried everything I can think of and read so so many articles in the PsychoPy forum but nothing really changes in the long run. Please help me, I’m at a loss here!