Created
November 1, 2020 16:54
-
-
Save mark-andrews/a37be6e65ae7e30634dc26b11f629340 to your computer and use it in GitHub Desktop.
Python code to make a n-back sequence of 9 letters of length 36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import string | |
from random import choice | |
letters = list(string.ascii_uppercase[:9]) | |
n = 2 | |
K = 36 | |
stimuli = [None] * K | |
response = [None] * K | |
for i in range(K): | |
if i < n: | |
stimuli[i] = choice(letters) | |
else: | |
if choice([True, False]): | |
stimuli[i] = stimuli[i-2] | |
response[i] = 'same' | |
else: | |
while True: | |
stimuli[i] = choice(letters) | |
if stimuli[i] != stimuli[i-2]: | |
break | |
assert stimuli[i] != stimuli[i-2] | |
response[i] = 'different' | |
# look at the stimuli and the correct responses | |
list(zip(stimuli, response)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment