I’m reaching out for help with an issue I’m having in PsychoPy.
OS Win10 PsychoPy version 2024.2.4 Py 3.8 Standard Standalone Installation? Yes Do you want it to also run online? Yes What are you trying to achieve? I am setting up a 4AFC acoustic perception experiment. Choices must be selected by clicking on text according to the audio stimuli perceived.
What did you try to make it work?: I configured clickable stimuli as follows, but when I run the experiment and make a choice, it stops and get the error described in the topic.
What specifically went wrong when you tried that?:
Traceback (most recent call last):
File “C:\Users\acost\Documents\Psychopy\Prueba1_lastrun.py”, line 799, in
run(
File “C:\Users\acost\Documents\Psychopy\Prueba1_lastrun.py”, line 662, in run
if obj.contains(mouse_resp):
AttributeError: ‘str’ object has no attribute ‘contains’
2.7207 WARNING Monitor specification not found. Creating a temporary one…
ioHub Server Process Completed With Code: 0
################ Experiment ended with exit code 1 [pid:17452] #################
Thanks in advance for your time and help. I’m just starting out and would really appreciate any guidance!
Do you have any fields in your conditions file which have the same name as any of your stimuli? If so, those stimuli names will be overwritten by the value of those fields each trial, so when other Components try to interact with them by name (as the Keyboard Component does) it gets the value from the conditions file rather than your Component.
Thank you very much for your reply. I did it but unfortunately I obtained the same error
######## Running: C:\Users\acost\Documents\Psychopy\Prueba1_lastrun.py #########
Traceback (most recent call last):
File “C:\Users\acost\Documents\Psychopy\Prueba1_lastrun.py”, line 799, in
run(
File “C:\Users\acost\Documents\Psychopy\Prueba1_lastrun.py”, line 662, in run
if obj.contains(mouse_resp):
AttributeError: ‘str’ object has no attribute ‘contains’
2.9817 WARNING Monitor specification not found. Creating a temporary one…
ioHub Server Process Completed With Code: 0
################ Experiment ended with exit code 1 [pid:10368] #################
I don’t know much about builder… does it produce a python source file? It looks like confusion between the names of stimuli (maybe sound files or images) being passed as strings rather than variables. Are the op*_t stimuli Visual.Shapes of some sort? Or, are you trying to click a label that is supposed to be the ‘button’ for a sound file, but actually is the sound file ( a WAV )?
What does that dialog do with hidden/escape/non-ascii/EOL characters? Does it filter them out. Are the conditions/stimuli read-in from a text file or spread sheet? I still get haunted by files that contain CRLF ( \r or ^M).
I’ve found the issue. You are using the correct answer field in your mouse component.
However, it is pointing to a column in your spreadsheet containing the text of your text components, not the text object names. It should look more like this:
audio
op1
op2
op3
op4
correcta
audios/1.Y hasta pozo.wav
pozo
piso
peso
pasa
op1_text
audios/2.Digo piso.wav
pozo
piso
puso
pasa
op2_text
audios/1.Y hasta pozo.wav
pozo
peso
piso
pasa
op1_text
audios/3.Digo peso.wav
pozo
peso
puso
pasa
op2_text
audios/1.Y hasta pozo.wav
pozo
paso
peso
pisa
op1_text
audios/4.Dije paso.wav
pozo
paso
puso
pisa
op2_text
audios/3.Digo peso.wav
peso
piso
paso
poza
op1_text
audios/8.Digo pupa.wav
peso
piso
puso
poza
op2_text
audios/9.Dije pepa.wav
pasa
pesa
poza
piso
op1_text
audios/6.Digo pesa.wav
pasa
pesa
blusa
piso
op2_text
audios/4.Dije pasa.wav
pasa
pisa
pesa
pozo
op1_text
audios/7.Dije pisa.wav
pasa
pisa
poza
peso
op2_text
audios/8.Digo pupa.wav
pupa
pepa
papa
Pipo
op1_text
audios/9.Dije pepa.wav
pupa
pepa
popa
papo
op2_text
audios/8.Digo pupa.wav
pupa
papa
Pepa
Pipo
op1_text
audios/10.Dije papa.wav
pupa
papa
popa
Pepo
op2_text
audios/11.Y hasta turre.wav
turre
torre
tarro
tira
op1_text
audios/12.Dije torre.wav
turre
torre
Tere
toro
op2_text
audios/13.Digo fula.wav
fula
fila
Fela
fole
op1_text
audios/14.Dije fila.wav
fula
fila
falo
Felo
op2_text
I note that you also have at least one sound file issue
ValueError: setSound: could not find a sound file named audios/4.Dije pasa.wav
The file in the folder is called “4.Dije paso.wav”
I’ve made the changes, but unfortunately I’m still encountering the same error
Were you able to run the experiment in the project I shared with you?
Thank you again for your help.
Best regards,
if obj.contains(mouse_resp):
AttributeError: ‘str’ object has no attribute ‘contains’
2.8203 WARNING Monitor specification not found. Creating a temporary one…
ioHub Server Process Completed With Code: 0
################ Experiment ended with exit code 1 [pid:14596] #################