Switching between different routines (subtasks) after one trial each

OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): PsychoPy 2021.2.3
Standard Standalone? (y/n) : yes
What are you trying to achieve?: I want to present to present odors, pictures and words to participants in a random order.

What did you try to make it work?: I have created an experiment with three loops controlling each stimulus type. I want to present 8 odors, 8 words and 8 pictures in random order. I have created an outerloop to randomize the order of the subtasks. My problem is that I only want to present one trial of each stimulus per outerloop. Essentially, I want psychopy to go through an show one odor, one word and one picture in random order in each iteration.
I have tried to implement a counter.

Begin Experiment: loop_number=0
Begin Routine: loop_number=+1

And I for each stimulus type in the loop I added Selected Row: $(loop_number-1)

What specifically went wrong when you tried that?:
This is the error code:
File “C:\Users\Luisa\Documents\PhD\Experiments\vAM_1week\v_AM_1week_lastrun.py”, line 282, in
trialList=data.importConditions(‘stim_pictures.xlsx’, selection=(loop_number-1)),
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\data\utils.py”, line 470, in importConditions
elif len(selection) > 0:
TypeError: object of type ‘int’ has no len()

I can’t seem to find a similiar topic, which really surprises me. Thank you in advance!

Hi There,

This looks the right direction to me - what does the conditions file provided to your outermost loop look like? If you only want one of the inner loops to be presented per trial then it should loop something like:

repA repB repC trialype
0 0 1 odorTrial
0 1 0 wordTrial
1 0 0 pictureTrial

Where “repA” is used in the nReps firls of your first loop, repB for the second loop and repC for the third.

Hope this helps,
Becca

Hi Becca,
thank you so much for the reply!! Where would the trialtype variable come into play?

All the best,
Luisa

That variable is just a handy label (not used in the task but saved to the data file for future you!)

Becca

This doesn’t work for me unfortunately. It randomizes the order of the stimuli blocks but it doesn’t only show one trial.

Are you also feeding in a conditions file to each of the inner loops? because if so make sure that you do not have spreadsheets in the inner loops - only one spreadsheet in the outer loop