[OS web, Java] Counterbalancing stimuli for three groups of participants
in OpenSesame
Dear all,
My experiment has three blocks of stimuli. Since there are specific conditions across the three blocks, I physically divided them for my convenience, as in the screenshot.
I have to present my blocks in the orders of A→B→C, B→C→A, and C→A→B to three groups of participants.
Is there any way I can implement this in JavaScript?
Thank you so much in advance.
Comments
Hi @Soan,
If you're gonna run your OSWeb experiment on a JATOS server, please note that you cannot make sure that the same number of participants will be allocated to each of the three orders. Instead, the task will allocate random a subject number base on the OSWeb settings of your experiment:
Here I set it up to be 0, 1 or 2.
If you're gonna run the task in the browser but in the lab and introduce yourself the subject number, then you can of course use whatever subject number you'd like for each particiapnt and set your task to use that number to select one of the three condition orderings.
The key is to include the three loops within a higher level loop that has its number of cycles set to 3:
You then need to use some javascript coding in an inline_javascript object to declare a few variables and a list contaning the possible ordering of the conditions (corresponding for example to loops called A, B and C). that code must run at the very start of the experiment, so before the higher level loop and preferably in the "prepare" section of the inline_javascript object:
order_index = subject_nr % block_orders.lengthuses something called the mod funciton:In programming, the modulo (or "mod") operation, often represented by the symbol
%(e.g.,a % b), calculates the remainder of a division. It returns the value left over after dividing one number (the dividend) by another (the divisor). For example,7 % 3would result in 1, because 7 divided by 3 is 2 with a remainder of 1. This basically ensures to chose one of the possible orders contained in block_orders based on the subject number (0, 1 or 2, whatever the subject number is).You can then store that order in a global variable, the index of which we'll later navigate to know which block (A, B or C) should be shown.
chosen_block_order = block_orders[order_index]Finally, notive that we set a
blocknumber to 0 and also declare acurrent_blockvariable by setting it to nothing ('').Then, in the first step of the higher level loop, we need to set the value of the current block depending on what block number we're in. So, if the order picked for the subject is B-C-A and we're at block 0, the current block would be B.
At the end of the higher level loop, we need a little more code to increment the block variabe by one unit:
Finally, we need to set "Run if" conditions for the higher_sequence:
Now we have everythgin ready. If the order picked for a subject is C-B-A, the value of the curent_block the first time (out of 3 cycles) that the higher_sequence runs will be C, then when it runs a second time it will be B, and on the third and last run it will be A.
The "run if" conditions ensure that although we reapet the higher_sequence 3 times, only one block will be run each time.
I attach my example. It should give you the basis you need for your experiment.If you're not familiar with Open Sesame or the basic javascript coding used here, take some time to go through it in order to understand what each bit does and that you understand the logic of the whole method. Then feel free to modify it to suit your needs.
Finally, note that if you are planning to run the experiment online through JATOS and want eual number of subjects for each order of conditions, the only thing that comes to mind would be to create 3 separate versions of your task where the order is fixed, and then distribute the corresponding links among the participants you recruited. That way you'd have some better control over how many subjects actually do each of the orders.
Hope this helps.
Best,
Fabrice.
PS: Please acknowledge reception of this message so that I know you've seen and I can then move this thread to the forum dedicated to OSWeb.