OS: Ubuntu 20.04
PsychoPy version: 2020.2.10
Standard Standalone? : yes
I am working on a task where I present strings of text for participants to type. I have a bank of 24 strings that need to be repeated 10 times. I would like the presented strings to be randomized but not have any repeated strings. However, even when randomizing without duplicates there is the possibility that trials could have repeated stimuli when the string bank gets refreshed.
I have tried implementing the solution from this forum post where you pre-shuffle the stimulus list to be in an acceptable order: Randomisation without consecutive presentations
I am able to print a pre-shuffled string list, but struggling to successfully translate that list to be the presented stimuli. Does anyone know how I might go about doing this?
Any help would be appreciated and thanks in advance!
It sounds like you are generating your stimulus list at the beginning of the experiment before the trials loop begins. If this is correct, then this solution should work for you.
First, after you create your stimulus list you can write it to a csv where each column is a variable in your trial. Then you have two options, you can (1) hard code a name for that csv file and write over the file every time you run your experiment, or you can generate a file name based on the participant or session or any other information and create a variable in your code to hold that file name.
For option (1), you can enter your selected file name into the Conditions field of the trials Properties pop up window. Then, also in the trials Properties window, you should set loopType to sequential, and nReps to 1. PsychoPy will automatically insert that file name as a parameter into the TrialHandler’s importConditions function which will load your file and allow you to access all of your trial variables by their column name. For now we will assume the column name for your string variable is word.
For option (2), you can generate the file name and store it in a variable in your code. We’ll say you save it as curFileName.Then, instead of entering a file name into the Conditions field of the trials Properties, you enter $curFileName. This will insert your file name variable into the importConditions function and then load the stimulus file and allow you to access your trial variables in the same way as option (1). Also, the loopType and nReps fields will be the same as in option (1).
So, now that your trial conditions are set up, you can create the text object in the Builder window that will present your string. In the Text field of the text properties pop up window, type in $word, and then for each trial the text will be updated to the next string from your stimulus list.
I hope this helps!
Thank you so much Rebekah! Your solution worked beautifully. <3