Randomize two different trials WITHOUT loop


I am looking to randomize two different trials (called trialemo and trialneutre) without looping and repeating them. Whenever a participant starts the study, one of the two trials should play at random. I have included a photo of the builder. Please let me know if this is possible and how.

Please describe your needs more precisely. e.g. if you don’t want a loop around the trials, why is there one in the screenshot?

Yes, it is certainly possible, but please clarify what you need.

Also be careful to specify what you mean by “random” - this is a very over-loaded term in experimental design.

The two trials I specified above will both flash several words to the participant. When the participant begins the study, I would like for the participant to see either the words of “trialemo” or “trialneutre”. Let me know if this makes more sense.

OK, so you do want a loop (i.e. multiple trials), but just want to control which sort of trial is shown.

There are several ways to do this. The easiest perhaps is to add fields to the experiment info dialog that allow you to control which condition will be shown. You haven’t clarified what you mean by “random”, but most people want pseudo-randomisation, so that the conditions are balanced across subjects. Let’s say you a dd a field called trial_type and enter a value of either emo or neutre at the start of each session.

Then insert a code component (from the “custom” component panel) on each routine, and put something like this in the “begin routine” tab of each one:

# for the emo routine:
if expInfo['trial_type'] != 'emo':
    continueRoutine = False
# for the neutre routine:
if expInfo['trial_type'] != 'neutre':
    continueRoutine = False

If you truly want automatic, random assignment of the trial type, then instead of manually entering the value, you could add code like this to the “begin experiment” tab:

expInfo['trial_type'] = randchoice(['emo', 'neutre'])

Having said that, there is a lot of duplication in your routine, with very many text components. That’s usually an indication of a non-optimal solution. It would seem likely that you could instead just have a single text component, and control its contents via a loop that is nested within your main trial loop.

Hi again, thanks for the response. I would actually want only one trial per participant, so no loops. I would ideally want pseudo-randomisation as you specified above. What would be the process to add this? I have only used builder and no code; would this be possible to do without code? I took Python several years ago but remember nothing.

Then just delete the loop.

Click the “experiment settings” icon on the toolbar and add a field called trial_type as suggested above.

The suggestions above are entirely based in Builder. Just follow the instructions to insert the very small snippets of code in a code component. That is still all done within the Builder graphical interface.

Thanks again for your help. I went ahead and deleted the loop. I then entered “trial_type” into the experimental settings. I then added the code for the automatic, random assignment of trial types into both of the two trials. For some reason it still is activating the trials in a sequential manner. Do I need to define “emo” and “neutre” somewhere?

I have attached screenshots.