Need a textbox component to appear for only a subset of trials

I am creating an experiment where I need a textbox component to appear but only for a subset of trials (2 out of 68 trials), is there any way to make this work? I haven’t tried anything myself yet as I’m not very competent in coding.


Hello, welcome to the forum!
Here is my way of solving it.

When the experiment starts, create a list containing two random ints between 0 to 67:

# Begin Experiment
import random

showTextBox = False
choosenTrials = random.sample(range(68), 2)

Then, whenever a new trial starts, check if the current number of repetitions is one of the chosen trials:

# Start Routine
if trials.thisN in chosenTrials:
    showTextBox = True
    showTextBox = False

Finally, create a condition to enable/disable the textbox:

1 Like

Thanks a lot, appreciate it.

1 Like