Starting target highlight loop over after routine break occured


I am currently building a P300 Speller in Psychopy. I want to build a 6x6 character matrix and flash the rows and columns with human faces.

Therefore, one trial consists of 12 flashes and I have 15 faces which each flash 12 times. Thus, one run consists of 15 blocks.

At the beginning of each run I am highlighting one of the charatcers (a letter or a number) in the matrix. This target highlight has 36 possible locations which are supposed to be randomly selected from an excel sheet in the target loop.
I want to repeat this 5 times, thus have 5 runs, whereafter a 3 minute break is supposed to occur, which I build in as a routine. Thereafter, I want the condition to change to a different human face expression.
In the builder the experiment looks like this:

builder view

Now, I inserted a chunk of code in the heighlight routine so that it only runs 5 times, whereafter the break routine appears:


(In Beginn Experiment it says “my count = 0”)

For the first condition it runs fine, selecting the target highlight 5 times after which the routine break occus. However, when the condition changes after the break and the loop runs again, it selects the target only once, after which the break occurs again.

I am very new to Psychopy and I cannot find any solutions to this problem. I suppose psychopy assumes that 5 targets have already been selected and only adds one additonal target highlight after changing the condition.

Does somebody know what code I have to use to highlight 5 targets, one per each run, per condition and have a routine break afterwards?

Thank you very much in advance for your help.

Hi @Julia_Oehlmann,

Based on the information you have shared about your experiment, it sounds like the count is not returning to 0 after the break. You need to add the line count = 0 somewhere, probably in the if-statement:

count += 1 # count up
if count > 4: # if 5 trials have been performed
  target.finished = True # move onto the break
  count = 0 # reset the counter for the next loop

Hope that helps,

Hello @shabkr,

Thank you so much! That fixed everything :slight_smile:

Have a nice day.