psychopy.org | Reference | Downloads | Github

Select limited number of items, based on type, in different blocks

Hello,

I am attempting to help a student create an autobiographical memory task in PsychoPy. I have attached a screenshot of the experiment, which runs fine, but the issue we have comes with stimuli selection.

There are 3 blocks, Specific, Categorical and Alternating.

We have a list of 8 negative words, 8 positive words and 8 neutral words.

The list is currently setup in the excel file to have all 24 words under “Word” and then beside it the word emotion (Emotion).

The Specific and Categorical blocks both need to display 6 words (2 of each emotion), the words will be shown in a random order, and cannot be carried over into the next block.

The Alternating block will then display the remaining 12 words (4 of each emotion), the instructions for this also need to randomize between 2 types of instruction.

I understand that something like this might be possible with code components, but I don’t know where to start.

Hopefully I have explained this well enough. Essentially it’s 3 blocks, 24 words total, with 3 word types. The first 2 blocks need to show 6 words (2 of each type) without repeating across blocks. The final block will show the remaining words, whilst also alternating between which instruction set is shown.

I have attached the list and the PsychoPy file for guidance.

Thank you!

WordList.csv (417 Bytes) MemoryV2.psyexp (40.8 KB)

Have a look at my proposal on another thread here: Two types of image stimuli, 9 of each, want experiment to randomly select four of each kind for every trial

Hi Wakefield,

I’ve followed your steps there and it works for the first block. The issue I have now is that in the second and third block it’s displaying the same words. Is there a way to code it so that once the words are shown, they cannot appear in another block?

Best wishes

Jake

MemoryV2.psyexp (60.3 KB)

There are three methods.

One is to use a function called pop:
thisWord=wordList.pop() deletes the last item from a list after assigning it to thisWord

Two is to make sure you are addressing later items, either by using firstLoop.thisN+secondLoop.thisN (this may not work for the first item – so it may need an additional +1, or a fixed number.

Three (and the method I tend to use because I’ve only recently come across .pop()) is to have a separate variable that is incremented after each selection wordList[thisTrial] then thisTrial+=1

Hello,

I thought I would pop this in here. I couldn’t get the methods you suggested to work (coding novice so it’s a bit difficult to follow!)

However I was able to adapt it into this, inelegant, but working solution below. Thank you for the help as it was still the initial solution which got this working.

Best wishes

Jake

positive=[[‘Festival’,‘p’],[‘Humour’,‘p’],[‘Lucky’,‘p’],[‘Paradise’,‘p’],[‘Truth’,‘p’],[‘Party’,‘p’],[‘Cash’,‘p’],[‘Win’,‘p’]]

negative=[[‘Disaster’,‘n’],[‘Failure’,‘n’],[‘Miserable’,‘n’],[‘Nightmare’,‘n’],[‘Rejected’,‘n’],[‘Tragedy’,‘n’],[‘Distressed’,‘n’],[‘Hurt’,‘n’]]

neutral=[[‘Bag’,‘e’],[‘Chair’,‘e’],[‘Envelope’,‘e’],[‘Ladder’,‘e’],[‘Steam’,‘e’],[‘Taxi’,‘e’],[‘Knot’,‘e’],[‘Shadow’,‘e’]]

shuffle(positive)
shuffle(negative)
shuffle(neutral)

words=[]
words2=[]
words3=[]

for Idx in range(2):
words.append(positive[Idx])
words.append(negative[Idx])
words.append(neutral[Idx])
shuffle(words)

for i in range (2,4):
words2.append(positive[i])
words2.append(negative[i])
words2.append(neutral[i])
shuffle(words2)

for i in range (4,8):
words3.append(positive[i])
words3.append(negative[i])
words3.append(neutral[i])
shuffle(words3)

1 Like