SART task problem

# Initialize error counters
commission_error = 0
omission_error = 0

# Check if the current number is 3
if int(thisNum) == 3:
    print('Omission trial:', thisNum)

# Commission Error check
if len(response.clicked_name) > 0 and response.clicked_name[0] == 'Button_2':
    commission_error = 1
    print('Commission error:', response.clicked_name[0])
else:
    print('Commission trial:', thisNum)

# Omission Error check
if len(response.clicked_name) > 0 and response.clicked_name[0] != 'Button_2':
    omission_error = 1
    print('Omission error:', response.clicked_name[0])

# Save data
thisExp.addData('commission_errors', commission_error)
thisExp.addData('omission_errors', omission_error)

I believe this is in the right format

Your code will give a commission error whenever Button_2 is pressed and an omission error whenever something else is pressed. Please compare your code with this fixed code below.

# Initialize error counters
commission_error = 0
omission_error = 0

# Check if the current number is 3
if int(thisNum) == 3:
    print('Omission trial:', thisNum)

# Commission Error check ONLY IF NUMBER IS 3
    if len(response.clicked_name) > 0 and response.clicked_name[0] == 'Button_2':
        commission_error = 1
        print('Commission error:', response.clicked_name[0])
else:
    print('Commission trial:', thisNum)

# Omission Error check ONLY IF NUMBER ISN'T 3
    if len(response.clicked_name) > 0 and response.clicked_name[0] != 'Button_2':
        omission_error = 1
        print('Omission error:', response.clicked_name[0])

# Save data IN ALL CASES
thisExp.addData('thisNum',thisNum)
thisExp.addData('commission_errors', commission_error)
thisExp.addData('omission_errors', omission_error)

If the trial can end also without anything being clicked then you need different code for ommision errors, e.g.

# Omission Error check ONLY IF NUMBER ISN'T 3
    if len(response.clicked_name) > 0 and response.clicked_name[0] != 'Button_2':
        omission_error = 1
        print('Omission error:', response.clicked_name[0])
    elif  len(response.clicked_name) == 0:
        omission_error = 1
        print('Omission error:', 'nothing clicked')

Here is the output, after the first loop. It shows omission error: nothing clicked on every trial except those of number 3. In these trials, I was clicking on the button.

Commission trial: 6
Omission trial: 3
Commission error: Button
Commission trial: 5
Commission trial: 7
Commission trial: 1
Omission error: nothing clicked
Commission trial: 9
Omission error: nothing clicked
Commission trial: 4
Omission error: nothing clicked
Commission trial: 2
Commission trial: 8
Commission trial: 2
Commission trial: 7
Commission trial: 6
Commission trial: 9
Omission trial: 3
Commission trial: 4
Commission trial: 1
Commission trial: 8
Commission trial: 5
Omission trial: 3
Commission error: Button
Commission trial: 9
Commission trial: 5
Commission trial: 2
Commission trial: 4
Commission trial: 8
Commission trial: 6
Commission trial: 7
Commission trial: 1
Commission trial: 5
Omission error: nothing clicked
Commission trial: 4
Commission trial: 7
Commission trial: 1
Commission trial: 6
Commission trial: 2
Commission trial: 9
Commission trial: 8
Omission trial: 3
Omission trial: 3
Commission trial: 1
Omission error: nothing clicked
Commission trial: 2
Omission error: nothing clicked
Commission trial: 4
Omission error: nothing clicked
Commission trial: 7
Omission error: nothing clicked
Commission trial: 5
Omission error: nothing clicked
Commission trial: 8
Omission error: nothing clicked
Commission trial: 9
Omission error: nothing clicked
Commission trial: 6
Omission error: nothing clicked
Omission trial: 3
Commission trial: 2
Omission error: nothing clicked
Commission trial: 9
Omission error: nothing clicked
Commission trial: 6
Omission error: nothing clicked
Commission trial: 4
Omission error: nothing clicked
Commission trial: 5
Omission error: nothing clicked
Commission trial: 8
Omission error: nothing clicked
Commission trial: 1
Omission error: nothing clicked
Commission trial: 7
Omission error: nothing clicked
Commission trial: 4
Omission error: nothing clicked
Commission trial: 8
Omission error: nothing clicked
Commission trial: 2
Omission error: nothing clicked
Omission trial: 3
Commission trial: 5
Omission error: nothing clicked
Commission trial: 6
Omission error: nothing clicked
Commission trial: 1
Omission error: nothing clicked
Commission trial: 7
Omission error: nothing clicked
Commission trial: 9
Omission error: nothing clicked
Commission trial: 1
Omission error: nothing clicked
Commission trial: 5
Omission error: nothing clicked
Commission trial: 7
Omission error: nothing clicked
Commission trial: 6
Omission error: nothing clicked
Omission trial: 3
Commission trial: 9
Omission error: nothing clicked
Commission trial: 4
Omission error: nothing clicked
Commission trial: 8
Omission error: nothing clicked
Commission trial: 2
Omission error: nothing clicked

Did you update the name of your mouse response?

if len(response.clicked_name) == 0: when you are clicking then you must be asking about the wrong mouse component.

This is one of the disadvantages of using copies of routines. When you make a change, you have to change all of them but the component names are unique.

Looks like that resolved the issue!