Understanding trials.thisIndex
I recently discovered that several experiments I’d written for students this year had incorrect data. They were recognition memory tests where a set of images or words were presented at time 1 and then presented again at time 2 mixed in with additional items.
The mistake I made was to determine whether an item was old or new using if trials.thisIndex in useRows: (where useRows was the list of rows presented at time 1. This method worked if the entire list was presented at time 2, but failed when time 2 also presented a subset of the possible items.
The reason, I have discovered, is that .thisIndex does not refer to the row number in the spreadsheet, as I first thought, but to the position of the row number in the list of row numbers passed to the loop. Therefore, for example, if you have a sequential loop with one repetition, then trials.thisN and trials.thisIndex will be identical.
Here’s an example of some of my randomisation code:
negatives = []
positives = []
controls = []
for Idx in range(30):
negatives.append(Idx)
controls.append(Idx+30)
positives.append(Idx+60)
shuffle(negatives) # Indices 0 to 29
shuffle(controls) # Indices 30 to 59
shuffle(positives) # Indices 60 to 89
useRows = []
useRows2 = []
for Idx in range(3): # Three items of each valence will be seen at times 1 and 2
useRows.append(controls[Idx])
useRows.append(positives[Idx])
useRows.append(negatives[Idx])
useRows2.append(controls[Idx])
useRows2.append(positives[Idx])
useRows2.append(negatives[Idx])
calc1 = 0
for Idx in range(3): # Three items of each values will only be seen at time 1
calc1 = Idx + 3
useRows.append(controls[calc1])
useRows.append(positives[calc1])
useRows.append(negatives[calc1])
for Idx in range(12): # Twelve items of each valence will only be seen at time 2
calc1 = Idx + 6
useRows2.append(controls[calc1])
useRows2.append(positives[calc1])
useRows2.append(negatives[calc1])
At time 2 I had
if trials.thisIndex in useRows:
Answer = 'Old'
...
However, this failed and I now realise I should have had:
if trials.thisIndex < 9:
Answer = 'Old'
...
because the first nine items added to useRows2 were presented at time 1.