n-Back Test with random letters/numbers

If anyone else is still having this problem, i solved it selecting distinct letters (in my case 5 vocals and 5 consonants) and put them in the letters list.

In the begin routine tab i could the run the following code:

n = 2
letterSelected = False

if not target:
    while not letterSelected:
        thisLetter = np.random.choice(letters)
        if len(presentedLetters) < n or thisLetter != presentedLetters[-n]:
            letterSelected = True
else:
    thisLetter = presentedLetters[-n]

presentedLetters.append(thisLetter)

The Presented Letter list was assigned in the begin experiment tab.

1 Like