Changing stimuli presented each loop

OS (e.g. Win10): Windows 11
PsychoPy version (e.g. 1.84.x): 2024.2.4
Standard Standalone? (y) If not then what?:
What are you trying to achieve?:
I have 48 stimuli in an excel sheet. 8 stimuli need to be presented sequentially every “fullexp” loop (total:6). The group of 8 stimuli should be different every loop. But, the group of eight words presented in triala1, triala2, triala3, and triala4 should be the same the entire loop. The 4 trial loops also have code in the Num. repeats slot for counterbalancing purposes, so I believe I need code for this solution but I have not been successful so far. Any help would be greatly appreciated.

What did you try to make it work?:

  1. created a code component with the following code
  1. created a code component with the following code: [quote=“JensBoelte, post:2, topic:35279”]
if block.thisRepN == 0:
    useRows = '2:5'
elif block.thisRepN == 1:
    useRows = '6:9'

[/quote]
and initialized it

  1. I have also added

if trials.thisN ==7:
trials.finished = True

What specifically went wrong when you tried that?:

  1. This worked initially, but soon it gave an IndexError: pop from an empty list. and the experiment would not continue.
  2. Unfortunately, this did not change the words every loop.
  3. The words stayed the same every loop.

Hello

This indicates that you have tried to read an element from an empty list. Yourlist.pop() removes the last element from your list. So each time you pop() your list gets shorter by one element until there is no element left. You are calling yourlist.pop() one too many times.

Am I right in assuming that you have modified the code to suit your needs?

Does that mean that you say the same set of eight words in all relevant routines despite the fact that your looped over the the routines six times?

Best wishes Jens

Hello @ar3

OK, I hope I have understood your experimental procedure correctly.

Insert a routine before your loop fullexp. In this routine, add a code component and specify the following in the Begin experiment tab of this code component

useRows = '0:1'
stimList = ['0:8','8:16','16:24','24:32','32:40','40:48']

shuffle(stimList) #if you want random block presentation

Set the loop fullexp to 6 iterations. Leave the condition file empty.

Add a routine containing a code component as the first routine in the fullexp loop. In the begin routine tab of this code component, add

useRows = stimList.pop()

Then add your stimulus presentation routines, each surrounded by its loop, and set repetition to 1. Set the condition file to the Excel file containing your stimuli, and set the Selected rows parameter to $useRows. If you want a random presentation of the stimuli in a block, set the Loop type to random.

Best wishes, Jens

Thank you so much! This worked