If obj.contains(mouse): AttributeError: 'str' object has no attribute 'contains'

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): MacOS Sequoia 15.1
PsychoPy version (e.g. 1.84.x): v.2024.1.5
Standard Standalone? (y/n) If not then what?: y
What are you trying to achieve?: Trying to show 8 images as clickable choices, and then show feedback based on the click of the subject

What did you try to make it work?: It would be easier to show it in a video I believe:

What specifically went wrong when you tried that?: please check the video above, it is short, straight to the point, and shows what I did and the error after
Include pasted full error message if possible. “That didn’t work” is not enough information.
stims.csv (1.7 KB)

This is the csv I uploaded in the loop

The object itself can’t easily be referenced in a spreadsheet. However, you could compare mouse.clicked_name with your spreadsheet value.

I am sorry, I couldn’t understand. So, by the stimulus name you mean 'img_1" …etc, between quotations? I already did that and I got the same error. If I understood wrongly, could you tell me what you meant?

Please show your mouse component and relevant code.

Thanks for your help, that’s my code and mouse component:

Add print(mouse.clicked_name,corrAns) next to your Add Data code to investigate.

1 Like

I did, got the same error:


The print statement was to investigate the error rather than fix it. However, if you are still getting an error related to “contains” when you have no reference to contains in your code then it must be the mouse component itself causing the error.

I know there was a bug in 2024.1.5 which meant it was worse (for me) than 2024.1.4 but I can’t remember what it was. Try setting the version to 2024.1.4 or removing the clickable stimuli and setting the mouse to end routine on any click to test. The latest version 2024.2.4 should be fine.

Are you trying to set a mouse correct answer (in the data tab of the mouse component). I know that can cause this error.

Here are a couple of other threads about this error.

1 Like

I was already able to set a mouse correct answer, but now I am trying to make image components clickable, that’s when I started facing that issue. I originally had the later version for MacOS, but I was advised to download an older version: v.2024.1.5

are you suggesting downloading v.2024.1.4?

I did delete the mouse component and added it again, same issue unfortunately.

I got this in the logs:

40.1128 INFO Loaded monitor calibration from [‘2024_04_29 17:04’]
40.1266 INFO Loaded monitor calibration from [‘2024_04_29 17:04’]
Generating PsychoPy script…

Running: /Users/zyadelmahdy/Documents/the talking mouse (psychopy)/0.1/#1_lastrun.py

85.3783 INFO Loaded monitor calibration from [‘2024_04_29 17:04’]
85.3958 INFO Loaded monitor calibration from [‘2024_04_29 17:04’]
2024-11-07 17:17:06.102 python[2910:70534] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to /var/folders/72/2czhyr_d2d3fb3__p0rx3fnw0000gn/T/org.opensciencetools.psychopy.savedState
2024-11-07 17:17:07.457 python[2910:70534] +[IMKClient subclass]: chose IMKClient_Modern
[-0.00666667 0.07166667]
[-0.00833333 0.07333333]
[-0.00833333 0.07333333]
[-0.00833333 0.07333333]
[-0.00833333 0.07333333]
[-0.00833333 0.07333333]
[-0.00833333 0.07333333]
[-0.00833333 0.07333333]
[-0.00833333 0.07333333]
[-0.00833333 0.07333333]
[-0.00833333 0.07333333]
[-0.00833333 0.07333333]
[-0.00833333 0.07333333]
[-0.00833333 0.07333333]
[-0.00833333 0.07333333]
[-0.00833333 0.07333333]
[-0.00833333 0.07333333]
[-0.00833333 0.07333333]
[-0.00833333 0.07333333]
[-0.00833333 0.07333333]
[-0.00833333 0.07333333]
[-0.00833333 0.07333333]
[-0.00833333 0.07333333]
[-0.00833333 0.07333333]
[-0.00833333 0.07333333]
[-0.00833333 0.07333333]
[-0.00833333 0.07333333]
[-0.005 0.07333333]
[0. 0.07333333]
[0.00166667 0.07333333]
[0.00166667 0.07333333]
[0.00166667 0.07333333]
[0.00166667 0.07333333]
[0.00166667 0.07333333]
[0.00166667 0.07333333]
[0.00333333 0.075 ]
[0.005 0.075]
[0.00666667 0.075 ]
[0.00833333 0.075 ]
[0.01 0.075]
[0.01 0.075]
[0.01 0.075]
[0.01 0.075]
[0.01 0.07666667]
[0.01 0.07666667]
[0.01 0.07666667]
[0.01 0.07666667]
[0.005 0.07666667]
[0.00333333 0.07666667]
[0.00333333 0.07666667]
[0.00333333 0.07666667]
[0.00333333 0.07666667]
[0.00333333 0.07666667]
[0.00333333 0.07666667]
[0.00333333 0.07666667]
[0.00333333 0.07666667]
[0.00333333 0.07666667]
[0.00333333 0.07666667]
[0.00333333 0.07 ]
[0.00166667 0.06666667]
[0.00166667 0.06666667]
[0.00166667 0.06666667]
[-0.00166667 0.065 ]
[-0.00333333 0.065 ]
[-0.005 0.06333333]
[-0.00666667 0.06333333]
[-0.01 0.06166667]
[-0.01166667 0.06166667]
[-0.01166667 0.06 ]
[-0.01333333 0.06 ]
[-0.01333333 0.06 ]
[-0.01333333 0.06 ]
[-0.015 0.06166667]
[-0.01666667 0.06166667]
[-0.02833333 0.07166667]
[-0.03666667 0.08 ]
[-0.04333333 0.08833333]
[-0.05 0.09666667]
[-0.07833333 0.13333333]
[-0.08666667 0.14333333]
[-0.09166667 0.15 ]
[-0.11666667 0.19166667]
[-0.12333333 0.20666667]
[-0.13166667 0.22333333]
[-0.15333333 0.285 ]
[-0.15333333 0.285 ]
[-0.15333333 0.285 ]
[-0.16 0.32333333]
[-0.16 0.32833333]
[-0.155 0.34333333]
[-0.14833333 0.35166667]
[-0.145 0.355]
[-0.11666667 0.37666667]
[-0.10833333 0.38333333]
[-0.09833333 0.38833333]
[-0.07166667 0.4 ]
[-0.06833333 0.4 ]
[-0.06166667 0.40333333]
[-0.06166667 0.40333333]
[-0.05833333 0.40333333]
[-0.05833333 0.40333333]
[-0.05833333 0.40333333]
[-0.05833333 0.40333333]
[-0.05833333 0.405 ]
[-0.05833333 0.405 ]
[-0.05833333 0.405 ]
[-0.05833333 0.405 ]
[-0.05833333 0.405 ]
[-0.05833333 0.405 ]
[-0.05833333 0.405 ]
[-0.05833333 0.405 ]
[-0.05833333 0.405 ]
[-0.05833333 0.405 ]
[-0.05833333 0.405 ]
[-0.05833333 0.405 ]
[-0.05833333 0.405 ]
2024-11-07 17:17:07.457 python[2910:70534] +[IMKInputSession subclass]: chose IMKInputSession_Modern
Traceback (most recent call last):
8.4195 DEBUG Fullscreen settings ignored as running in pilot mode.
8.4206 INFO Loaded monitor calibration from [‘2024_04_29 17:04’]
8.6398 EXP Created window1 = Window(allowGUI=True, allowStencil=False, autoLog=True, backendConf=UNKNOWN, backgroundFit=<method-wrapper ‘getattribute’ of attributeSetter object at 0x7f97213b7ee0>, backgroundImage=<method-wrapper ‘getattribute’ of attributeSetter object at 0x7f97213b7e80>, bitsMode=UNKNOWN, blendMode=‘avg’, bpc=(8, 8, 8), color=array([0, 0, 0]), colorSpace=‘rgb’, depthBits=8, fullscr=<method-wrapper ‘getattribute’ of attributeSetter object at 0x7f97213b7c70>, gamma=None, gammaErrorPolicy=‘raise’, infoMsg=UNKNOWN, lms=UNKNOWN, monitor=<psychopy.monitors.calibTools.Monitor object at 0x7f97213af7f0>, multiSample=False, name=‘window1’, numSamples=2, pos=[556.0, 341.0], screen=0, size=array([1600, 1200]), stencilBits=0, stereo=False, title=‘PsychoPy’, units=‘height’, useFBO=True, useRetina=True, viewOri=0.0, viewPos=None, viewScale=None, waitBlanking=True, winType=‘pyglet’)
8.6399 EXP window1: backgroundImage = ‘’
8.6399 EXP window1: backgroundFit = ‘none’
8.6400 EXP window1: mouseVisible = True
8.6405 EXP window1: mouseVisible = True
8.6408 EXP window1: mouseVisible = True
8.6430 EXP window1: mouseVisible = True
8.6435 EXP window1: mouseVisible = True
8.6486 DEBUG TextBox2 loaded 1 chars with 0 blanks and 1 valid
8.6489 DEBUG TextBox2 loaded 1 chars with 0 blanks and 1 valid
8.6495 DEBUG TextBox2 loaded 1 chars with 0 blanks and 1 valid
8.6503 DEBUG TextBox2 loaded 1 chars with 0 blanks and 1 valid
8.6511 DEBUG TextBox2 loaded 1 chars with 0 blanks and 1 valid
8.6518 DEBUG TextBox2 loaded 1 chars with 0 blanks and 1 valid
8.6525 DEBUG TextBox2 loaded 1 chars with 0 blanks and 1 valid
8.6528 DEBUG TextBox2 loaded 1 chars with 0 blanks and 1 valid
8.6531 DEBUG TextBox2 loaded 1 chars with 0 blanks and 1 valid
8.6533 DEBUG TextBox2 loaded 1 chars with 0 blanks and 1 valid
8.6540 DEBUG TextBox2 loaded 1 chars with 0 blanks and 1 valid
8.6547 DEBUG TextBox2 loaded 1 chars with 0 blanks and 1 valid
8.6549 DEBUG TextBox2 loaded 1 chars with 0 blanks and 1 valid
8.6554 DEBUG TextBox2 loaded 1 chars with 0 blanks and 1 valid
8.6559 DEBUG TextBox2 loaded 1 chars with 0 blanks and 1 valid
8.6565 DEBUG TextBox2 loaded 1 chars with 0 blanks and 1 valid
8.6570 DEBUG TextBox2 loaded 1 chars with 0 blanks and 1 valid
8.6574 DEBUG TextBox2 loaded 1 chars with 0 blanks and 1 valid
8.6580 DEBUG TextBox2 loaded 1 chars with 0 blanks and 1 valid
8.6585 DEBUG TextBox2 loaded 1 chars with 0 blanks and 1 valid
8.6592 DEBUG TextBox2 loaded 1 chars with 0 blanks and 1 valid
8.6598 DEBUG TextBox2 loaded 1 chars with 0 blanks and 1 valid
8.6603 DEBUG TextBox2 loaded 1 chars with 0 blanks and 1 valid
8.6610 DEBUG TextBox2 loaded 1 chars with 0 blanks and 1 valid
8.6615 DEBUG TextBox2 loaded 1 chars with 0 blanks and 1 valid
8.6620 DEBUG TextBox2 loaded 1 chars with 0 blanks and 1 valid
8.6627 DEBUG TextBox2 loaded 1 chars with 0 blanks and 1 valid
8.6629 DEBUG TextBox2 loaded 1 chars with 0 blanks and 1 valid
8.6631 DEBUG Uploading Texture Font fontname to graphics card
8.6669 DEBUG Upload of Texture Font fontname complete
8.6693 EXP window1: mouseVisible = True
8.6694 EXP window1: mouseVisible = True
8.6698 EXP window1: mouseVisible = True
8.6702 EXP window1: mouseVisible = True
8.6736 DEBUG TextBox2 loaded 1 chars with 0 blanks and 1 valid
8.6743 DEBUG TextBox2 loaded 1 chars with 0 blanks and 1 valid
8.6744 DEBUG Uploading Texture Font fontname to graphics card
8.6764 DEBUG Upload of Texture Font fontname complete
9.9036 INFO keyboard.Keyboard is using ptb backend.
10.2201 INFO keyboard.Keyboard is using ptb backend.
10.2201 EXP #1: status = STARTED
10.2204 EXP window1: mouseVisible = True
10.2567 EXP Created text = TextStim(class=<class ‘psychopy.visual.text.TextStim’>, alignHoriz=method-wrapper(…), alignText=‘center’, alignVert=method-wrapper(…), anchorHoriz=‘center’, anchorVert=‘center’, antialias=True, autoDraw=False, autoLog=True, bold=False, color=array([1., 1., 1.]), colorSpace=‘rgb’, contrast=1.0, depth=0.0, draggable=False, flipHoriz=False, flipVert=False, font=‘Arial’, fontFiles=, height=0.05, italic=False, languageStyle=‘LTR’, name=‘text’, opacity=1.0, ori=0.0, pos=array([0., 0.]), rgb=UNKNOWN, text=str(…), units=‘height’, win=Window(…), wrapWidth=1)
10.2568 EXP window1: mouseVisible = True
10.2682 EXP Created question_img = ImageStim(class=<class ‘psychopy.visual.image.ImageStim’>, anchor=(‘center’, ‘center’), autoLog=True, color=array([1., 1., 1.]), colorSpace=‘rgb’, contrast=1.0, depth=-2.0, draggable=False, flipHoriz=False, flipVert=False, image=‘default.png’, interpolate=True, mask=None, maskParams=None, name=‘question_img’, opacity=1.0, ori=0.0, pos=array([0., 0.]), size=array([0.2, 0.2]), texRes=128.0, units=‘height’, win=Window(…))
10.2683 EXP window1: mouseVisible = True
10.2718 EXP Created img_1 = ImageStim(class=<class ‘psychopy.visual.image.ImageStim’>, anchor=(‘center’, ‘center’), autoLog=True, color=array([1., 1., 1.]), colorSpace=‘rgb’, contrast=1.0, depth=-3.0, draggable=False, flipHoriz=False, flipVert=False, image=‘default.png’, interpolate=True, mask=None, maskParams=None, name=‘img_1’, opacity=1.0, ori=0.0, pos=array([0. , 0.4]), size=array([0.2, 0.2]), texRes=128.0, units=‘height’, win=Window(…))
10.2719 EXP window1: mouseVisible = True
10.2753 EXP Created img_2 = ImageStim(class=<class ‘psychopy.visual.image.ImageStim’>, anchor=(‘center’, ‘center’), autoLog=True, color=array([1., 1., 1.]), colorSpace=‘rgb’, contrast=1.0, depth=-4.0, draggable=False, flipHoriz=False, flipVert=False, image=‘default.png’, interpolate=True, mask=None, maskParams=None, name=‘img_2’, opacity=1.0, ori=0.0, pos=array([0.5, 0.4]), size=array([0.2, 0.2]), texRes=128.0, units=‘height’, win=Window(…))
10.2754 EXP window1: mouseVisible = True
10.2786 EXP Created img_3 = ImageStim(class=<class ‘psychopy.visual.image.ImageStim’>, anchor=(‘center’, ‘center’), autoLog=True, color=array([1., 1., 1.]), colorSpace=‘rgb’, contrast=1.0, depth=-5.0, draggable=False, flipHoriz=False, flipVert=False, image=‘default.png’, interpolate=True, mask=None, maskParams=None, name=‘img_3’, opacity=1.0, ori=0.0, pos=array([0.5, 0. ]), size=array([0.2, 0.2]), texRes=128.0, units=‘height’, win=Window(…))
10.2787 EXP window1: mouseVisible = True
10.2819 EXP Created img_4 = ImageStim(class=<class ‘psychopy.visual.image.ImageStim’>, anchor=(‘center’, ‘center’), autoLog=True, color=array([1., 1., 1.]), colorSpace=‘rgb’, contrast=1.0, depth=-6.0, draggable=False, flipHoriz=False, flipVert=False, image=‘default.png’, interpolate=True, mask=None, maskParams=None, name=‘img_4’, opacity=1.0, ori=0.0, pos=array([ 0.5, -0.4]), size=array([0.2, 0.2]), texRes=128.0, units=‘height’, win=Window(…))
10.2819 EXP window1: mouseVisible = True
10.2851 EXP Created img_5 = ImageStim(class=<class ‘psychopy.visual.image.ImageStim’>, anchor=(‘center’, ‘center’), autoLog=True, color=array([1., 1., 1.]), colorSpace=‘rgb’, contrast=1.0, depth=-7.0, draggable=False, flipHoriz=False, flipVert=False, image=‘default.png’, interpolate=True, mask=None, maskParams=None, name=‘img_5’, opacity=1.0, ori=0.0, pos=array([ 0. , -0.4]), size=array([0.2, 0.2]), texRes=128.0, units=‘height’, win=Window(…))
10.2852 EXP window1: mouseVisible = True
10.2886 EXP Created img_6 = ImageStim(class=<class ‘psychopy.visual.image.ImageStim’>, anchor=(‘center’, ‘center’), autoLog=True, color=array([1., 1., 1.]), colorSpace=‘rgb’, contrast=1.0, depth=-8.0, draggable=False, flipHoriz=True, flipVert=False, image=‘default.png’, interpolate=True, mask=None, maskParams=None, name=‘img_6’, opacity=1.0, ori=0.0, pos=array([-0.5, -0.4]), size=array([-0.2, 0.2]), texRes=128.0, units=‘height’, win=Window(…))
10.2886 EXP window1: mouseVisible = True
10.2920 EXP Created img_7 = ImageStim(class=<class ‘psychopy.visual.image.ImageStim’>, anchor=(‘center’, ‘center’), autoLog=True, color=array([1., 1., 1.]), colorSpace=‘rgb’, contrast=1.0, depth=-9.0, draggable=False, flipHoriz=False, flipVert=False, image=‘default.png’, interpolate=True, mask=None, maskParams=None, name=‘img_7’, opacity=1.0, ori=0.0, pos=array([-0.5, 0. ]), size=array([0.2, 0.2]), texRes=128.0, units=‘height’, win=Window(…))
10.2921 EXP window1: mouseVisible = True
10.2952 EXP Created img_8 = ImageStim(class=<class ‘psychopy.visual.image.ImageStim’>, anchor=(‘center’, ‘center’), autoLog=True, color=array([1., 1., 1.]), colorSpace=‘rgb’, contrast=1.0, depth=-10.0, draggable=False, flipHoriz=False, flipVert=False, image=‘default.png’, interpolate=True, mask=None, maskParams=None, name=‘img_8’, opacity=1.0, ori=0.0, pos=array([-0.5, 0.4]), size=array([0.2, 0.2]), texRes=128.0, units=‘height’, win=Window(…))
10.2953 EXP window1: mouseVisible = True
10.2960 EXP Created fb_txt = TextStim(class=<class ‘psychopy.visual.text.TextStim’>, alignHoriz=method-wrapper(…), alignText=‘center’, alignVert=method-wrapper(…), anchorHoriz=‘center’, anchorVert=‘center’, antialias=True, autoDraw=False, autoLog=True, bold=False, color=array([1., 1., 1.]), colorSpace=‘rgb’, contrast=1.0, depth=-1.0, draggable=False, flipHoriz=False, flipVert=False, font=‘Arial’, fontFiles=, height=0.05, italic=False, languageStyle=‘LTR’, name=‘fb_txt’, opacity=1.0, ori=0.0, pos=array([ 0. , -0.3]), rgb=UNKNOWN, text=‘’, units=‘height’, win=Window(…), wrapWidth=1)
10.2961 EXP window1: mouseVisible = True
10.2992 EXP Created fb_img = ImageStim(class=<class ‘psychopy.visual.image.ImageStim’>, anchor=(‘center’, ‘center’), autoLog=True, color=array([1., 1., 1.]), colorSpace=‘rgb’, contrast=1.0, depth=-2.0, draggable=False, flipHoriz=False, flipVert=False, image=‘default.png’, interpolate=True, mask=None, maskParams=None, name=‘fb_img’, opacity=1.0, ori=0.0, pos=array([0., 0.]), size=array([0.5, 0.5]), texRes=128.0, units=‘height’, win=Window(…))
0.0827 INFO Keyboard events cleared
0.0827 EXP text: autoDraw = True
0.6419 DATA Mouse: Left button down, pos=(396,344)
0.7161 DATA Mouse: Left button up, pos=(396,343)
1.9645 DEBUG Read csv file with pandas: stims.csv
1.9672 DEBUG Clearing unnamed columns from stims.csv
1.9681 EXP Imported stims.csv as conditions, 15 conditions, 10 params
1.9696 EXP Created sequence: random, trialTypes=15, nReps=1, seed=None
1.9697 EXP New trial (rep=0, index=0): OrderedDict([(‘question’, ‘img/1_x.png’), (‘ans_1’, ‘img/1_a.png’), (‘ans_2’, ‘img/1_b.png’), (‘ans_3’, ‘img/1_c.png’), (‘ans_4’, ‘img/1_d.png’), (‘ans_5’, ‘img/1_e.png’), (‘ans_6’, ‘img/1_f.png’), (‘ans_7’, ‘img/1_g.png’), (‘ans_8’, ‘img/1_h.png’), (‘corr_ans’, ‘ans_1’)])
2.0775 DATA Keypress: return
2.0831 EXP text: autoDraw = False
2.0831 EXP question_img: image = ‘img/1_x.png’
2.0831 EXP img_1: image = ‘img/1_a.png’
2.0831 EXP img_2: image = ‘img/1_b.png’
2.0831 EXP img_3: image = ‘img/1_c.png’
2.0831 EXP img_4: image = ‘img/1_d.png’
2.0831 EXP img_5: image = ‘img/1_e.png’
2.0831 EXP img_6: image = ‘img/1_f.png’
2.0831 EXP img_7: image = ‘img/1_g.png’
2.0831 EXP img_8: image = ‘img/1_h.png’
2.0831 EXP question_img: image = ‘img/1_x.png’
2.0831 EXP img_1: image = ‘img/1_a.png’
2.0831 EXP img_2: image = ‘img/1_b.png’
2.0831 EXP img_3: image = ‘img/1_c.png’
2.0831 EXP img_4: image = ‘img/1_d.png’
2.0831 EXP img_5: image = ‘img/1_e.png’
2.0831 EXP img_6: image = ‘img/1_f.png’
2.0831 EXP img_7: image = ‘img/1_g.png’
2.0831 EXP img_8: image = ‘img/1_h.png’
2.0831 EXP question_img: autoDraw = True
2.0831 EXP img_1: autoDraw = True
2.0831 EXP img_2: autoDraw = True
2.0831 EXP img_3: autoDraw = True
2.0831 EXP img_4: autoDraw = True
2.0831 EXP img_5: autoDraw = True
2.0831 EXP img_6: autoDraw = True
2.0831 EXP img_7: autoDraw = True
2.0831 EXP img_8: autoDraw = True
3.0245 DATA Mouse: Left button down, pos=(365,543)
3.0404 EXP window1: mouseVisible = True
3.0414 DEBUG Saving data for #1 ExperimentHandler
3.0425 INFO saved data to /Users/zyadelmahdy/Documents/the talking mouse (psychopy)/0.1/data/479458_#1_2024-11-07_17h17.06.538.psydat
3.0429 INFO saved data to ‘/Users/zyadelmahdy/Documents/the talking mouse (psychopy)/0.1/data/479458_#1_2024-11-07_17h17.06.538.csv’
3.0445 WARNING Stopping key buffers but this could be dangerous ifother keyboards rely on the same.
3.0446 WARNING Stopping key buffers but this could be dangerous ifother keyboards rely on the same.
File “/Users/zyadelmahdy/Documents/the talking mouse (psychopy)/0.1/#1_lastrun.py”, line 1197, in
run(
File “/Users/zyadelmahdy/Documents/the talking mouse (psychopy)/0.1/#1_lastrun.py”, line 956, in run
print(mouse.clicked_name,corrAns)
NameError: name ‘corrAns’ is not defined
################# Experiment ended with exit code 1 [pid:2910] #################

Sorry – your code uses corr_ans not corrAns

2024.1.4 might be better but try again with 2024.1.5 after fixing the print statement

1 Like

I changed it to corr_ans, and it didn’t work, then when I downgraded the psychopy version, it worked fine. Thanks a lot.

Just one more thing though, it always shows the wrong answer feedback message even when I choose the correct answer:

if correct == 1:
    fb_msg = 'Good boy!'
    feedback_img = 'img/kiss.jpeg'

    
else:
    fb_msg = 'WROOOONG!'
    feedback_img = 'img/wrong.jpg'

print("Setting feedback image to:", feedback_img)    
    
fb_img.setImage(feedback_img)

What is the outcome of the print statement?

this is the output:

13.4566 INFO saved data to ‘/Users/zyadelmahdy/Documents/the talking mouse (psychopy)/0.1/data/662541_#1_2024-11-07_18h39.46.425.csv’
13.4575 INFO saved data to /Users/zyadelmahdy/Documents/the talking mouse (psychopy)/0.1/data/662541_#1_2024-11-07_18h39.46.425.psydat
13.4711 EXP window1: mouseVisible = True
13.5329 DEBUG Saving data for #1 ExperimentHandler
13.5340 WARNING Stopping key buffers but this could be dangerous ifother keyboards rely on the same.
13.5341 WARNING Stopping key buffers but this could be dangerous ifother keyboards rely on the same.
################# Experiment ended with exit code 0 [pid:5096] #################

Are you sure there isn’t anything higher up. There should be Setting feedback image to: img/wrong.jpg and the output of print(mouse.clicked_name,corr_ans)

Yes, it was too long to paste, I uploaded it to Google Docs:

Here’s the key bit

['img_8'] ans_2
Setting feedback image to: img/wrong.jpg

mouse.clicked_name[0] was “img_8”
corr_ans was “ans_2”

They don’t match

I am sorry, couldn’t understand what you mean. Do you mean that I get the wrong image because I choose the wrong answer? But I chose the correct ones too and still got the wrong image as feedback

Your image components are all called img_x
Your correct answer therefore also needs to be of the form img_x
What is ans_x?

1 Like

It worked, thank you so much

We had a problem with this same error. My understanding from looking into this is that the error results from the translation between python and javascript. The javascript file that is automatically generated includes a “contains” function and that is missing in javascript (but present in python). This error will occur as long as there are things listed in “Clickable stimuli” on the mouse object. We worked around this error by eliminating the “Clickable stimuli” – there is nothing in that box. Then we added code to score the mouse component. The code we added was in the “End Routine” section. We have 6 boxes that participants need to choose from and click on the correct one (where a stimulus was previously). The variable “Correct” is from the stimulus file. Here is the code. In short we use a series of if…elif…elif…else to check if each box has been clicked.

ThisItemCorrect = 0
if mouse_resp.isPressedIn(Box1test):
    #debug_text.text = "Correct: "+str(Correct)+" Box1"
    if(Correct == 1):
        ThisItemCorrect = 1
elif mouse_resp.isPressedIn(Box2test):
    #debug_text.text = "Correct: "+str(Correct)+" Box2"
    if(Correct == 2):
        ThisItemCorrect = 1
elif mouse_resp.isPressedIn(Box3test):
    #debug_text.text = "Correct: "+str(Correct)+" Box3"
    if(Correct == 3):
        ThisItemCorrect = 1
elif mouse_resp.isPressedIn(Box4test):
    #debug_text.text = "Correct: "+str(Correct)+" Box4"
    if(Correct == 4):
        ThisItemCorrect = 1
elif mouse_resp.isPressedIn(Box5test):
    #debug_text.text = "Correct: "+str(Correct)+" Box5"
    if(Correct == 5):
        ThisItemCorrect = 1
elif mouse_resp.isPressedIn(Box6test):
    #debug_text.text = "Correct: "+str(Correct)+" Box6"
    if(Correct == 6):
        ThisItemCorrect = 1
        
NumItemsCorrect = NumItemsCorrect + ThisItemCorrect
# increments for ThisItemCorrect has been set to 1

if(ThisItemCorrect == 1):
    if(NumItemsCorrect >= int(NumResp)):
        NumTrialsCorrect = NumTrialsCorrect + 1
        NumItemsCorrect = 0
    if(NumTrialsCorrect >= 1): # stopping rule
        NumTrialsCorrect = 0
        NumItemsCorrect = 0
        SixItemTrials.finished=True
else:
    NumItemsCorrect = 0
    NumTrialsCorrect = 0 # trials correct in a row
    # for stopping rule, so an error resets the counter
    if press_to_quit.keys:
        if press_to_quit.keys == 'q':
            thisExp.saveAsExcel()
            core.quit()