Conditionally enter routine in builder

Hey all,

I was just wondering if it was possible, from within the builder, to conditionally enter a routine in your experiment flow? I.e. if you have two different trial types, a routine may have to be different (thinking basically like forced-choice versus free-choice tasks) between the two conditions. You would then conditionally enter one of the two routines for that phase of a task depending on the trial type.

If you were coding this from scratch in the coder, you can do this with a simple if trial_type == X: and code the two routines separately, but i’m not sure if this is possible from within the builder (specifically thinking about online experiments too). Or are there some inventive ways of using the builder to do exactly this?

Sorry for the potentially vague question!


Vague questions demands vague answers :relieved:. I think this might be a good starting point: Blocks of trials and counterbalancing — PsychoPy v2020.2

You can also use loop and code components in clever way to skip o present again trials (for example play the same routine until the desired answer, or after a certain number of correct answer etc.).


The best approach is either to use custom code elements so that you can make one routine run as either (any) of your routine types, or to use continueRoutine=False to end the routine(s) you don’t want early, or to use loops with nReps = a variable that is set to 1 if you want it and 0 if you don’t.

yeah i think begin routine code snippet with sth like if condition === False: continueRoutine = False would be ideal but i remember trying to do that with psychoJS code and it wouldnt work. But this was a few versions ago so it might be updated and we can access that now.

I do think it would be a good feature of the builder and would allow more intuitive conditional parts of tasks tho. its not uncommon for studies to require a slightly different routine depending on a trial type