How to randomize the presentation of old stimuli and new stimuli

OS (e.g. Win10): win 10
PsychoPy version (e.g. 1.84.x): 2020.2.4
What are you trying to achieve?:
In my memory experiment, divided into two parts, the learning trail and the recognition trail.
My conditions doc has a list of 50 words, and I wanna the learning randomly presents 10 of them, the recognition part randomly presents 20 of them, and 10 of them appear in the previous learning part.
What did you try to make it work?:


I have finished the first part, but I don’t know how to randomly present both old words and new words in the second part.
Thank you so much for your comments /advice in advance.

Hi There,

OK, so to streamline your word1_code component, I think the following should also do what you need instead of using the loop method:

index2 = np.random.randint(50, size=10)

To then randomly select 20 rows you would use something like:

index2 = np.random.randint(50, size=20)

To save the words that are presented in order to present them again try something like this:

In the ‘begin experiment’ tab:

presented_words=[]#an empty list we will add to

in the ‘begin routine’ tab:

presented_words.append(word)#replace word with whatever the column header for your word stimuli is

Then when it comes to the loop where you ‘re-present’ old words, add a code component and in the 'begin routine tab:

word = presented_words[trials.thisN]

Hope this helps,
Becca

Hi Becca,

Thank you so much for your help! I probably didn’t make myself clear before,what I want to achieve is the 20 non repetitive word stimulus in the second part(recog_loop), which contains 10 words from the first part(study_loop), and 10 of the remaining 40 words in my condition document.


Do you have any recommendations for this? Thanks again!

Aha I see, so the 20 word condition consists of 10 old and 10 new words? so the first sampling needs to be sampling without replacement?

Yes, all 10 words in the first sampling will be presented with new words in the second, these 20 non repetitive words will be randomly presented. Thank you for your patience.

In that case I would make yourself 2 lists say:

index1and2 = np.random.randint(50, size=20)
index1=index1and2[0:10]
index2=index1and2[10:20]

then use each set of rows accordingly (I think that would be index 1 for the first 10 trials, then index1and2 for the ‘mixed’ condition)

Becca

Thank you so much for the suggestion! I really appreciate it.