2

I have a simple experiment with 3 blocks. Instead of putting stimulus (words) into three different files, I set them in one file and want to use ‘selected rows’ to assign them to different tasks (blocks). Below is the flow.

[selected rows: np.random.choice(15, size = 5, replace = False)]

enter image description here

The problem is that after 5 trials (first block-level condition), all the words will be reshuffled so that the words appeared in block 1 may also appear in block 2/block 3.

Are there any solutions to achieve that if a word has been used in a block, then it will not appear again in the following blocks? Many thanks!

E.Coms
  • 11,065
  • 2
  • 23
  • 35
Xiaotong
  • 43
  • 4

1 Answers1

1

The issue is probably arising because you are effectively randomising multiple times: both with the selection of the subset of rows but also with the randomisation of the loops themselves. i.e. your loops should be set to be sequential rather than random, because you are handling the randomisation yourself by selecting a subset of rows.

Even if you do that, you now have a second problem: if you choose a subset of 5 rows for each block via np.random.choice(), those selections are independent and so it is quite likely that some variable number of rows will be selected multiple times. So what you need to do is ensure that rows are selected without replacement, across the entire experiment.

I'd suggest that you randomly shuffle all 15 row indices in a list, and then apply subsets of that list in each block. That way you can ensure that there will be no multiple selection of rows. e.g:

row_order = range(15)
np.random.shuffle(row_order)

Then in each of the three blocks, you would use these subsets:

row_order[0:5]
row_order[5:10]
row_order[10:15]

This gives you a randomised selection in each block but with no duplication of rows.

Michael MacAskill
  • 2,411
  • 1
  • 16
  • 28
  • Hi Michael, thank you so much for your clear explanation and solution. I guess I’ve got what you mean (the programming logic) but I don’t exactly know how to achieve this in the actual Psychopy interface. By using row_order[0:5]/[5:10]/[10:15], do you suppose there are 3 block routines and I need to put the subsets in the selected rows dialogs respectively? But there is only 1 block routine. I accomplished 3 block loops by connecting another xlsx file which includes 3 rows. It would be much appreciated if you could explain a little bit further about how to use the subsets you’ve wrote. Thx! – Xiaotong Oct 30 '18 at 11:11