Applying pre-existing randomisation by participant number
Hi so I'm wanting to run an experiment where participants are randomly assigned to one of two video stimuli exposures. It will be run across multiple tablets simultaneously, and I don't really want to use odd/even or other counterbalanced approaches I have seen in the tutorials as I would prefer to be blinded to participant condition. The approach I would ideally like to take is have a third party generate an excel sheet with all my participant numbers in column A and randomly assigned 'condition' (0 or 1) in column B - adding this list into open sesame somehow. Then when the participant number is entered on open sesame I want it to identify what condition that participant number is assigned to (i.e., based on the excel doc) and play the appropriate stimuli, presumably using the 'condition' variable in the 'Run if' function.
Is this possible? If so, can anyone give me a bit of guidance?
Cheers!
Comments
Hi Kezzo,
The idea of a double blind study is a very good one, I like it. One simple way to do it is copy pasting a random list into an inline script and using the subject number as an index to retrieve the random value at that index.
I guess one potential problem is that if you completely randomize an long list there is a slight chance that you will get a repetition of condition 1 for the first xx subjects.
A primitive way to avoid that:
This way you randomize per 'batch' so that after each number of 10 subjects your design is balanced, of course you can reduce or increase this batch number according to your needs, and indeed once you have the random condition variable you can use it in the same manner as described in the example experiments. Hope this helps, good luck
Hi Roelof,
Thanks for your response, you have come at the problem in a slightly different way to how I had thought about it. Yours is much more elegant I think. Really helpful.
I am new to open sesame and doing inline scripts so bear with me. So just to make sure I understand how this works, in the most basic example if I added the code below into an inline script:
random_list = [1,1,1,0,0,0]
var.condition = random_list[var.subject_nr]
I would then have a new variable [condition] I can refer to elsewhere in open sesame in which subject numbers 0, 1 and 2 have a value for [condition] of 1. And subject numbers 3, 4 and 5 have a value for [condition] of 0. And any other subject numbers will not have a value for the variable [condition]. Is that correct?
If so this will almost certainly do what I require - but just as a quick extension... is there anyway the random_list can be retrieved from an external file (i.e., an excel) - that way I would never even have to see the random list (as I would if I copy & paste it into inline script) so there can be no possible way I, for example, might remember the first few in the sequence.
Yes, you are completely correct about the description of the assignment of condition number and subject numbers. There is a way to store the codes in an external file and read in the number in an inline script definitely, you have to be careful with running the experiment on multiple platforms though since if the folder structure is different you would have to change the working directory ('log_path') for each device.
and then in the inline script:
Now you can use the 'condition_list' the same way as before using the subject number as the index
Thats great - thanks Roelof!
@Roelof - I've actually had a bit of trouble implementing this. The bit in spyder works fine (although seems to create twice as many numbers as specified in nr_subjects):
`import random
nr_subjects = 100
batch_nr = 10
total = []
for i in range(0,nr_subjects // batch_nr):
nr = [0,1]*batch_nr
random.shuffle(nr)
total = (total + nr)
file_name = 'random_numbers'
log_path = '/Users/Kieran/Desktop/'
f = open('%s\%s.txt' %(log_path, file_name), 'w')
f.write(str(total))
f.close()`
However, in open sesame when I put in the following code:
`file_name = 'random_numbers'
log_path = '/Users/Kieran/Desktop/'
f = open('%s\%s.txt' %(log_path, file_name), 'w')
for row in f:
condition_list = eval(row)
var.condition = condition_list[var.subject_nr]`
I get this error - IOError: File not open for reading
Any suggestions?
Indeed the total number of subjects is twice as large since we are adding two numbers with every execution of the for loop, that is a bit confusing.
As for the error, if you change the 'w' to an 'r' I think it should work (w= write, r = read)
f = open('%s\%s.txt' %(log_path, file_name), 'r')Let me know if there are any other implementation problems, good luck.