Dear Stackoverflow fam,
I wish to run some experiments whereby I import some parameters for a stimulus (random dot kinematogram) and I chose to do this by creating a CSV with said parameters (total of 8 parameters I wish to cycle through). I need to pseudo-randomise the trials so I used the numpy.random.shuffle function to create this array. With this new array "shuffledRDK" i made the following loop
for b in range(2):
for fps in range(120):
blank_trial.draw()
mywin.flip()
time.sleep(6)
print("Trial: " +str(trial_counter) + " , Orientation " +str(shuffledRDK[x,0]) + " Coherence " +str(shuffledRDK[x,1]))
trial_counter += 1
if x in range (9):
x += 1
for fps in range(120):
SignalDots = visual.DotStim(win=mywin, color=(1, 1, 1), dir=(shuffledRDK[x-1,0]), coherence=(shuffledRDK[x-1,1]), fieldSize=(20,20), speed=1, dotSize=5, dotLife=3, nDots=50, fieldShape='circle')
SignalDots.draw()
mywin.flip()
My issue is that at the end of the 8th parameter I wish for the cycle to start again. I get IndexError: index 8 is out of bounds for axis 0 with size 8 which I understand is out of the boundaries of the array but I don't know how to restart it. I've tried putting in if x > 8 statements or similar lines but I still get the index error. Would someone be able to help me out please?
Many thanks in advance
You shouldn't have to increment x up each time; it will do it on it's own as it iterates through the loop. I suppose you are doing this because you want your x to start at 1 and end at 9? you can specify that range explicitly.