psychopy.org | Reference | Downloads | Github

Randomly assigning participants to an experimental condition

URL of experiment: The experiment is in early development, I don’t have any URL to share and don’t know yet if it is possible for me to share an URL without paying?

Description of the problem:
Hi all! I’m sorry I’m really uncomfortable with Python at the moment, but I wish to improve and learn.
I have a specific problem with an experiment that is quite simple (see Flow) : I want to display an information retrieved from the dialog box at the beginning of the experiment as a running head for half of the participants, but not for the other half (between participants design).
So I know how to create some code components that do display the information I want (see Code 1, 2 and 3).
Running my experiment works, and the information is displayed. See The two following images (without judging me for all the browser tabs :smile:)

However, my problem is that I would like that some participants (half of them), do not have this information displayed on their screen. In other words, my experimental condition is “Displaying of this information from the dialog box” vs “no displaying of the information from the dialog box”.

Do you know if it is possible?

Flow:
The important information is that the screenshot 1 is taken from the routine “Trial”

Code1: Code component added in the first routine “Trial” in the “Begin experiment” Tab

nameText = expInfo['Name']
expInfo['Name'] = None

Code2: Code components added in the routine “LDT Practice” in “Begin Experiment” tab

amor = visual.TextStim(win=win, name='amor',
    text= nameText,
    font=u'Cambria',
    pos=(0, 0.5), height=0.065, wrapWidth=2, ori=0, 
    color=u'black', colorSpace='rgb', opacity=0.5,
    depth=0.0);

Code3: Code in the “LDT practice” in the “Begin Routine” tab

if t >= 0.0 and amor.status == NOT_STARTED:
        # keep track of start time/frame for later
        amor.tStart = t
        amor.frameNStart = frameN  # exact frame index
        amor.setAutoDraw(True)

An information that might be important is that I have no way to guess what is going to be displayed: it depends on the information the participant will write in the dialog box at the beginning of the experiment.

If you need further clarifications, do not hesitate! I hope I am clear enough.

Thanks for your help!
Best

Jean

Hi Jean,

Try using this excellent tool from @wakecarter https://moryscarter.com/vespr/pavlovia.php

This will assign sequential participant ID’s to your participants then you can use that to set either the “text” or “no text” condition.

Since you have 2 conditions you would replace “x” with 2 where wakefield mentions condition = int(expInfo[‘participant’])%x in this link.

Then, in your Code1 component you would then say:

if condition%2:
    nameText = expInfo['Name']
else:
    nameText = ' '

Here if the assigned participant number is odd they will see the text, if it is even they will not see the text.

Hopefully this helps :slight_smile:
Becca

Hi Becca!

Thank you so much for your answer!
This tool looks great and simple, and might be just what I was looking for! … Unfortunately, since I can only use the piloting mode, I cannot test it yet. I think I’m going to buy some credits on Pavlovia to try it (unless you know of a way of testing if it works while in ‘piloting’ mode?).
Just to clarify, I guess the mention of condition = int(expInfo[‘participant’])%2 should be written in the Before Experiment tab of a code component?

Moreover, it will be my first time using Prolific as a platform to collect data. To your knowledge, do you think the use of the new URL generated by Wakefield’s tool won’t cause any issue with this platform?

Sorry for all the questions…
Thanks again for your answer!

Best,

Jean

Hi Jean,

Whilst you are piloting I would recommend just adding a dummy “condition” variable to your code to check everything works.

i.e. in your Code1 component add:
condition =x
and manually enter x to be the participant number that would be hypothetically generated from Wakefields tool (1, 2, 3 etc.).

If it works as you expect (i.e. text shows for odd numbers and not for even) then I would say it would be safe to assume you could use Wakefields tool and try it with a couple of tokens.

One thing to note is to make sure that you do not have a field named ‘participant’ in your initial exp info box (as this may overwrite the number generated by Wakefields tool).

Becca

1 Like

Hi,

That’s a great idea! I’m going to try this as soon as possible.
Thank you so much for your help!

Have a nice day,

Jean

1 Like

Hi Becca!

A little update: it works fine!
Thanks a lot for your help :smile:

Have a nice day!

Jean