Help Needed: Adjusting the Letter and Number Positions in TMT B Condition

OS : Win10
PsychoPy version: 2023.3.2.3

Hi everyone,

I’m currently working on a Trail Making Task in PsychoPy and facing some issues with the positions component. Specifically, I need to modify the TMT B condition so that it includes 13 numbers and 12 letters. Currently, it has 12 letters and 12 numbers. I’m having difficulty adjusting the positions of the letters and numbers to fit the desired format.

When I change the excel folder to have one more number and add some positions, psychopy says: “IndexError: list index out of range”

When I try to add or remove letters/numbers, the task seems to break completely—it stops functioning as intended. I’ve looked into the code, but I don’t fully understand how the positions are being handled or how I can make these adjustments without disrupting the task. (I am not good with coding).

Has anyone dealt with a similar issue? Any tips or guidance on how to properly modify the positions in PsychoPy would be greatly appreciated!

Thank you in advance for your help.

Are you modifying an experiment that worked with 12 and 12?

If so, what modifications did you make?

Hello @wakecarter ,

We are currently working on a Trail Making Task (TMT) that you shared with us earlier (vespr / trail-making · GitLab). First, we want to thank you for sharing this task with us. It has made a significant contribution to our work and plays an important role in our project.

In our project, we aim to adjust the TMT B condition to include 13 numbers and 12 letters. This is necessary because we calculate participant scores as TMT B reaction time - TMT A reaction time, and ensuring consistency with the original format is important, especially to avoid issues when preparing our work for publication later.

To achieve this, we tried modifying the positions component in the original Excel file (i.e., posArray1 and posArray2 arrays). However, during these adjustments, we encountered some errors, such as “IndexError: list index out of range,” and the task sometimes stopped functioning as intended.

We would greatly appreciate your guidance or suggestions on how to adapt the task properly. Specifically, how can we adjust the TMT B condition to include 12 letters and 13 numbers? Any tips on how to make these changes without disrupting the task would be extremely helpful.

Thank you again.

Please could you upload your new Excel file?

You can see the file attached.

Best,

conditions.xlsx (8.7 KB)

I remember now. The code you need to change is in code_instr in the instr routine

# Customise the instructions with the current target list
msg = ''
targetList = []
for Idx in range(Numbers):
    targetList.append(str(Idx+1))
    if Letters:
        targetList.append(alphabet[Idx])
for Idx in range(3):
    msg += str(Idx+1) + ', '
    if Letters:
        msg += alphabet[Idx] + ', '
if Numbers > 4:
    msg += " ... "
msg += str(Numbers) + ', '
if Letters:
    msg += alphabet[Numbers-1] + ', '
msg = msg[:-2]

thisExp.addData('Condition',Condition)

This code assumes that there is the same number of letters as numbers.

One solution would have been to reduce the number list to 24 from 25 but to have 25 items in both cases, you could change the code to:

# Customise the instructions with the current target list
msg = ''
targetList = []
for Idx in range(Numbers):
    targetList.append(str(Idx+1))
    if Letters and Idx < 12:
        targetList.append(alphabet[Idx])
for Idx in range(3):
    msg += str(Idx+1) + ', '
    if Letters:
        msg += alphabet[Idx] + ', '
if Numbers > 4:
    msg += " ... "
if Letters and Numbers > 12:
    msg += str(Numbers-1) + ', ' + alphabet[Numbers-2] + ', '
msg += str(Numbers) + ', '
if Letters and Numbers < 12:
    msg += alphabet[Numbers-1] + ', '
msg = msg[:-2]

thisExp.addData('Condition',Condition)

I think this should work

1 Like

Thank you so much for your help.

Best,