randomize the length of cycle without repeating any of the stimuli ( OSPAN task )
``I am trying to program an Operation Span Task, participants are asked to read and verify simple math problem (such as "Is (4/2)-1=1 ?) and then read a letter after the operation (such as F). After a series of problems and words has been presented, the participants are asked to serially recall the letters presented to them. The number of operation-letters strings in a varies from 3, to 7 to measure the participant's operation span.
I tried to program the task in two ways - in the first I created a loop with all the math operations and letters stimuli in a csv file, and used inline code to present them. Before the trial sequence, I created a list with all the different trial sets and ensured that each setSize would only be called once. Then inside the loop item, I changed the set cycle item to the variable [setSize].
experimentSetSize = [3,3,3,4,4,4,5, 5, 5, 6,6, 6, 7,7, 7] # I actually divided these values by the number of math equations in my file ( 200).
def randomizeTrialLength(data):
size = len(data)
while size:
size = size - 1
index = random.randint(0, size)
var.setSize = data[index]
data[index] = data[size]
return var.setSize
randomizeTrialLength(experimentSetSize)
print var.setSize
It seems to have worked, however, what I want to know is whether my variables will be repeated or not. Is there some way to ensure that all my trials are unique once the loop repeats, (since this is pretty essential to my task)?
In the second way, I created a loop that only calls math operations from a csv file ( and set the cycle length to [setSize] again), and then put another loop inside of that to present the letter stimuli from another csv file, and set the cycle to repeat 0.12 times ( since there are 12 letters) and call the letters randomly. If I call them sequentially, I get the same letter over and over again - which would likely mean that my math equations are not unique either.
Hopefully someone has a solution.
Thanks!
Mariana