Re: [psychopy-users] Randomly assign participants to conditions

247 views
Skip to first unread message

Rebecca Sharman

unread,
Jul 25, 2012, 8:49:25 AM7/25/12
to psychop...@googlegroups.com
Hi Nina,

You'll need to use a code component. It will need to randomly allocate the participant to the condition (probably randomly generate either a 1 or a 0) and the write an 'if' statement to say what to do for each.
For the one where you want them to see all the slides you won't need to change anything but for the other you will need to terminate the routine that would display 'A' early.

More details on code components and how they work can be found here:

http://www.psychopy.org/builder/components/code.html

Hope that helps,
Becky

On Wed, Jul 25, 2012 at 12:07 PM, NinaA <nina.a...@googlemail.com> wrote:
Hi,

I've only been using PsychoPy for one day so I'm very clueless at the moment. I want to randomly assign participants to one of two conditions at the start of the experiment, where participants in one condition see slides A, B, C, D and participants in the other condition see only slides B, C, D. So far I've just made the A, B, C, D version in Builder.

I haven't been able to find anything online about how to do this. Can anyone help?

Thank you,
Nina

--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To post to this group, send email to psychop...@googlegroups.com.
To unsubscribe from this group, send email to psychopy-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/psychopy-users/-/glYatWVMJGsJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

NinaA

unread,
Jul 25, 2012, 10:30:47 AM7/25/12
to psychop...@googlegroups.com
Thanks! I'll give it a go.

Nina


On Wednesday, July 25, 2012 1:49:25 PM UTC+1, Rebecca Sharman wrote:
Hi Nina,

You'll need to use a code component. It will need to randomly allocate the participant to the condition (probably randomly generate either a 1 or a 0) and the write an 'if' statement to say what to do for each.
For the one where you want them to see all the slides you won't need to change anything but for the other you will need to terminate the routine that would display 'A' early.

More details on code components and how they work can be found here:

http://www.psychopy.org/builder/components/code.html

Hope that helps,
Becky

On Wed, Jul 25, 2012 at 12:07 PM, NinaA <nina.a...@googlemail.com> wrote:
Hi,

I've only been using PsychoPy for one day so I'm very clueless at the moment. I want to randomly assign participants to one of two conditions at the start of the experiment, where participants in one condition see slides A, B, C, D and participants in the other condition see only slides B, C, D. So far I've just made the A, B, C, D version in Builder.

I haven't been able to find anything online about how to do this. Can anyone help?

Thank you,
Nina

--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To post to this group, send email to psychopy-users@googlegroups.com.
To unsubscribe from this group, send email to psychopy-users+unsubscribe@googlegroups.com.

Nate Vack

unread,
Jul 25, 2012, 10:57:08 AM7/25/12
to psychop...@googlegroups.com
On Wed, Jul 25, 2012 at 7:49 AM, Rebecca Sharman
<rebecca...@gmail.com> wrote:

> You'll need to use a code component. It will need to randomly allocate the
> participant to the condition (probably randomly generate either a 1 or a 0)
> and the write an 'if' statement to say what to do for each.

One thing to keep in mind: you might actually want to have the group
be stable with respect to some identified (participant number, for
example) -- otherwise, if you run the script twice for a ppt, you
might put them in different groups.

A solution is to generate a hash based on, say, ppt number, and then
look at whether that hash (or a part of it) is even or odd:

import hashlib
h = hashlib.sha1()
h.update(participant_number) # participant_number is defined Somewhere Else
group_num = int(h.hexdigest()[0], 16) # Check if the first digit in
the hash is even or odd

-n
Reply all
Reply to author
Forward
0 new messages