| Reference | Downloads | Github

Randomize conditions within a trial

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): v 3.2.3

Hi, I am a student working on my thesis. I am very new to psychopy and have limited knowledge of python. I am struggling to learn.

I have designed an experiment where a stimulus is presented followed by 3 different tasks (written in text) associated with the stimulus. I would like to randomize the presentation of these tasks within a trial.
My excel conditions file looks something like this:

Stim TaskA TaskB TaskC
Stim1 Task1A Task1B Task1C
Stim2 Task2A Task2B Task2C
Stim3 Task3A Task3B Task3C

I am trying to present each task for 4 seconds sequentially without repetition in random order. For example, for Stim1, Task1A - Task1C - Task1B; for Stim2, Task2B - Task1C - Task1A…

I have tried advised solutions from other posts about similar issues and youtube videos; but none of them worked. I have a vague understanding (although uncertain) that I have to
a) create a Tasklist = [TaskA, TaskB, TaskC],
b) shuffle them (shuffle(Tasklist)),
c) save the order (thisExp.addData(‘Taskorder’, Tasklist)), and
d) call each in the text properties ($Tasklist[0]; $Tasklist[1]; $Tasklist[2]) using ‘set every repeat’ option.

The problem is I do not know how to read the respective tasks for each stimulus from excel file in code. The examples that I have tried (even using importConditions or xlrd) seemed to print the actual syntax (e.g. “$TaskA”; “Tasklist.pop()”) not the content of the task… I will appreciate tremendously for anyone who could give me advice.