Display first name of participant taken from expInfo

OS (e.g. Win10): macOS Sierra Version 10.12.6
PsychoPy version (e.g. 1.84.x): PsychoPy 3 2021.2.3
Standard Standalone? (y/n) yes

Hi, can someone help me with this please?

I created a dot probe task in which I have different kinds of distractors. I want one distractor to be the first name of the participant, which is entered at the beginning of the experiment. To use the first name, I have created a variable, “nameText”, with the following code (in the “begin experiment” field):

nameText= expInfo[‘prénom’]

(“prénom” means “firt name” in French, and it is the title of the field where participants type in their first names)

For the dot probe task, I have created an Excel file with all the relevant parameters for the task (see image).

Capture d’écran 2022-03-01 à 12.32.43

The distractors are in the “dot” column, and the name of the text component that displays the distractor is “text_6”. My question is: what do I have to do so that in some trials of the dot probe task, the displayed distractor is the first name of the participant (and all the other parameters for a given trial are taken from the same line of the excel file)? I think some version of an if command would work, in a code component at the beginning of the routine for the dot probe task (the loop is called “dotprobe”, and the routine for distractor display is called “dot_task”, see image for the builder view), but I’m not sure how to code it.

I hope the question is clear.

Many thanks,


What would you like to be presented in the text component when it isn’t the nameText?

You probably want Begin Routine code like:

nameText = 'Control text'
if dottype == ‘soi':
     nameText = expInfo[‘prénom’]


Thank a lot. For the other trials, I want to display the stimuli that will be in the dot column.


1 Like

In that case just replace the first line of my code with nameText = dot

Put $nameText set every Repeat in the text component

That is splendid! Thanks again!

Hi again,

I’m sorry to come back with this, but when I use the code you suggested:

nameText = dot

if index_y == ‘y’:

nameText = expInfo[‘prénom’]

The task runs but the parameters of the stimuli are off. What happens is that in each trial, text parameters are not taken from the same line of the Excel file. It looks like each parameter is taken from a different line, say the color from line 3, the position from line 46, the text itself from some other line… Have I misspecified something? The loop type is random, and the parameter of the text component are specified as “set every repeat”. I need all the parameters in one trial to be taken from the same line of the Excel file.

Thenk you in advance,


Try moving the code component to the top of the routine

The code component is in the “Begin routine” section. If I put it in the “End routine” section, the same thing happens (it runs but with mixed-up parameters). What am I doing wong? I’m not sure I understand what is the “top” of the routine, sorry.


In your screen shot text_6 is above code_4 which means that the text in text_6 is set before the code_4 Begin Routine code runs. Right-click code_4 and select “Move to top”.

Yes, that seems to solve the problem!

Thank you very much for your help.