# Memory Recognition Task Randomization Issue

Hi! I am new to psychopy and coding and I’ve been working on this for a few days and can’t seem to figure it out… I have a list of 14 statements and there is a new and old version of each statement. I managed to program the experiment so that participants are randomly presented with 7 new statements and 7 old statements (they can only see one version of each statement). The statements are organized in a csv file with each type in a different column.

However, I want to add 7 foil statements to the experiment so that a total of 21 statements (7 of each type) are randomly presented. I’ve managed to add the foil statement but it is only presenting 14 trials and there is a random number of each statement.

This is what my code looks like:
Begin experiment:
import random

#randomize the Excel file by row
all_rows=[0,1,2,3,4,5,6,7,8,9,10,11,12,13] #if you have 20 rows in your Excel sheet, this field should be 0-19
random.shuffle(all_rows)

OLDorNEW=[“old”, “new”,“foil”]*7 #if you want 7 trials randomly selected between old and new, change 4 to 7 here
random.shuffle(OLDorNEW)

Begin routine:
trial_type = OLDorNEW[trials.thisN]

if trial_type == “new” or trial_type == “foil”:
continueRoutine = False
else:

And here’s the loop:

Shouldn’t this be 0 to 20 for 21 trials?

Is there a reason why you are using selected rows? Does the spreadsheet have a different number?

The spreadsheet has 3 columns (statement_new, statement_old, statement_foil) & each column has 14 rows. Initially, it had 2 columns (old, new) and I added a new one when I added the foils. I don’t know if it’s the proper way to add them though?

I tried 0 to 20 and removed selected rows from the loop properties and I am still getting only 14 trials. I also removed the selected rows and it didn’t change anything, I had it previously to randomize before adding the loop.

Thank you for the help btw!

For 21 trials you should have 21 rows.

Either

Three columns with 21 statements in each

or

Put the 7 foil statements in different rows from your 14 new/old statements. You could put x in the statement_new column and then have something like:

``````if statement_new == 'x':
thisStatement = statement_foil
trial_type = "foil"
elif OLDorNEW.pop() == "old":  # or possibly == ["old"]
thisStatement = statement_old
trial_type = "old"
else:
thisStatement = statement_new
trial_type = "new"

``````