Branched Experiments in PsychoPy

Make an experiment that can take one of several routes depending on how your participants respond.


  1. Make a consent routine, a trials routine and an end routine.
  2. In the consent routine add a keyboard component that allows either the Y or N key to be pressed.
  3. Add a code component to your consent routine.
  4. In the code component use this in the End Routine tab:
if key_resp.keys == 'Y':
    trialLoopReps = 1
elif key_resp.keys == 'N':
    trialLoopReps = 0
  1. Add a loop around the trials routine (and trials loop) and set nReps to trialLoopReps. if the participant does not consent, this part of the experiment will be skipped!

For more tutorials please see the PsychoPy Youtube Channel

Dr. Rebecca J. Hirst
Dr. Rebecca J. Hirst
Cognitive Scientist

My research interests include multisensory perception and experimental design.