End Routine got error

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

OS: Win10
PsychoPy version: 2022.2.4
**Standard Standalone? Yes
What are you trying to achieve?:
My task was running correctly. I didn’t limit the image and mouse duration. After that, I wanted to change my stimuli and mouse duration time to 7s and this time my task didn’t run and gave me an error.
What did you try to make it work?:
I tried to change my code but it didn’t work. I insert the image below. looks like it’s a problem with my code in end routine part.
What specifically went wrong when you tried that?:
File “C:\Master’s\Master’s Thesis\NYU CAFE Database\EMT-Female\EMT-Female_lastrun.py”, line 488, in
clickedStimuli = mouse.clicked_name[0]
IndexError: list index out of range


I’m new to coding so I would very appreciate it if you help me.

It’s probably because clicked_name is empty.
What are the conditions to end the routine? Can the participant end the routine when he doesn’t click on any object?

Check that your mouse has the End Routines on press to valid click. Also, define which stimuli are clickable:

I did all of these before.
Everything was fine but when I set 7s in duration, I got that error.
I set 7s duration to all images too.

Do you get the error only when the participant doesn’t press any button during those 7 secs?
If this is the case, you’re getting the error because, at the end of your routine, the mouse isn’t pressed on any object. You are trying to access the first item in mouse.clicked_name, but it’s empty. Your range is empty. Therefore you get out of range error.

A condition checking if mouse.clicked_name is empty will fix your error.
For example:

if mouse.clicked_name:
    clickedStimuli = mouse.clicked_name[0]
else:
    clickedStimuli = 'empty'
1 Like