Help creating catch trials

I need to insert some catch trials into my experiment and I’m not sure how to do it. I’ve inserted some screenshot of my builder to help explain my experiment and what is required.

Screen Shot 2020-09-14 at 2.40.54 pm

The second of these screenshots is the part that I’m focusing on that actually needs the catch trials.

The ‘cue’ routine is just a video that is specified by the excel sheet that I’ve uploaded to the outer ‘trials’ loop. The cue will either be a ‘no cue’ video where participants only see a bright screen and hear wind or one of four actual ‘cues’ that correspond to the experimental condition - participants see green and orange birds in a tree of different percentages (e.g. 90% green and 10% orange, or 70% orange and 30% green).

The trial routine is what is shown in the bigger screenshot - participants here a sequence of sounds that correspond to green and orange birds and have to update their position on a response scale (coded using the two image components) to indicate the proportion of birds in the tree.

I need to have a catch trial after either every cued condition (i.e., not after the ‘no cue’ video or after only half of the cued conditions.****

The cued videos are specified as follows in the conditions excel spreadsheet:

The no cue is specified as follows:

In the catch trials the participants are asked to indicate the proportion of birds in the most recent video that they saw, to ensure they were paying attention to the cues (this will be done using the response scale and they just press the return key to indicate they’ve made their estimate). Following this, the next trial should begin

One solution could be:

Define a column in your Excel-sheet with the values of 0 or 1. Set all cued conditions to 1 and all other conditions without a catch trial to 0. Insert a routine for your catch trial follwing your experimental trial. Surround this routine with a loop. Set the loop-counter to the column containing the 0/1 of your Excel-sheet.

Cheers Jens

Hi Jens,

Thanks for your response!

Just want to make sure I understand what to do properly:

  1. Insert a new routine following the ‘trials’ routine above - this is for my catch trial. This routine will contain the actual catch trial task
  2. Set an inner loop (within the outer loop above) around that routine
    2a. Set the ‘conditions’ parameter of that loop to the 0/1 column in the excel sheet

I’m a bit confused where to go from here… is there a code component I have to add that defines whether this routine plays or not based on whether the column value is 0 or 1?

Thanks, Lauren

Hello Lauren,

when testing my proposed solution I had to learn that I does not work. The nRep$ can not (?) access variables (columns) of an Excel-sheet.

Sorry Jens

Hi Jens,

No worries, thanks for trying.

I feel like your approach could work with some tweaking perhaps. If I used your column and 0/1 approach I think I could insert a code component that says something along the lines of ‘if (column name) = 1, play this routine, else continue with the trial routine’

My only problem is that I’m not very good at writing my own code components… I guess I’ll keep trawling through the forum.

Thank you though! Lauren

Hello Lauren,

ok, I made an error in my first attempt. See the attached screenshots and files for a solution
There is a variable, “rep”, in the Excel-sheet that identifies catch trials (0/1).



Test.psyexp (9.4 KB) Textcount.xlsx (8.4 KB)

loopType is sequenial for testing purposes only.

Cheers Jens

Hi Jens,

Thanks for that. I’m still not sure how to specify when the catch trial plays based on which cue is played (obviously this is specified in the excel sheet) but I don’t see how that is specified in your files.

I’ve attached a practice trial that I’ve run with 5 blocks within that trials routine and the conditions excel sheet that I’ve created to specify which cue video plays and which block plays.

experimentBlockpractice.psyexp (16.4 KB)
Block1.xlsx (9.1 KB) Block2.xlsx (9.1 KB) Block3.xlsx (9.1 KB) Block4.xlsx (9.1 KB) Block5.xlsx (9.0 KB) chooseBlocks.xlsx (9.6 KB)

Not sure if you need all of the files within that (video files, image files, sound files) but if they would be helpful let me know and I can upload them.


Hello Lauren,

it is the column rep. 1 means show, 0 means do not show

Cheers Jens

Okay thanks Jens, I’ll try it out now!

Hi Jens,

Why have you got the exptext set to $rep

is this an extra routine I will have to add after my ‘trials’ routine and before the ‘catch’ routine?

Hello Lauren,

I set exptext to $rep to have a visual indication if a catch trial is following. The routine expttrial is your “Tria…”. You have to add the catchtrial routine. It has to follow your “Tria…” routine ( I can’t read its whole name.).

I would need all files to test your experiment. But I pretty sure we get this solved without you sending me your files.

Cheers Jens

Hi Jens,

It worked!! I’m just going to try it on my big experiment now but I think it should be fine! Thank you so much, a life saver :smiley:


Hey Jens,

I have it working properly in the psychopy builder however when I sync it to Pavlovia it comes up with this error.

I assume this is some error in the auto translating from python to javascript. Any ideas how to get around this?


The program does not know rep. You have to use the counter that you use in your Excel-file aso.

I’m not sure I understand what you mean

Hello Lauren,

there is a difference between the online and offline version of the experiment. offline it is python code, online it is javascript. PsychoPy “autotranslates” its python code to javascript. This does not always work.

So, when the program ran offline, you still might have to make some adjustements to your script (see Wake Carter’S crib sheet).

The error message tells you that the online progam does not know the variable rep. Therefore it stops.

cheers Jens

Hi Jens,

Thanks I’ll see if I can figure out how to fix that with the crib sheet.

Thanks again!