Java Counterbalance Issue
Hi there,
I have an experiment that i'm hoping to run on osweb. Everything seems to be work smoothly except for the the counterbalancing of the conditions.
My experiment has 2 main conditions: an auditory block (that contains 4 different loops) and a visual block (contains 4 different loops). I want to counterbalance the order of which block the participants sees first.
So far i have this java code:
if(vars.subject_parity === "even"){
vars.condition1 = "AuditoryBlock"
vars.condition2 = "VisualBlock"
}else {
vars.condition1 = "VisualBlock"
vars.condition2 = "AuditoryBlock"
}
The code works fine in that I don't get any errors. But when i test the experiment and put the subject number an even number, sometimes the I get visual first and sometimes auditory first. Same thing when i try an odd number; sometimes the counterbalancing is right sometimes it's not. I'm not sure what i'm doing wrong.
In the main experimental loop that contains both blocks and their loops i created a variable called condition and put [condition1] in row 1 and [condition2] in row 2.
In the main sequence I set the loop visualBlock to Run If [condition] = VisualBlock and AuditoryBlock to Run If [condition] = AuditoryBlock.
I hope this all make sense.
Any help is greatly appreciated!
-Gazelle
Comments
Hi @Gazelle_M
Your logic looks right.
The first thing that I am wondering is: how do you set a subject number? If you specify the subject number in the
allowed subject number
field, then osweb randomly samples a number from this field.Furthermore: are you testing this in jatos or with the option to directly run your experiment in the browser? Jatos has its own system for distributing subject numbers, which you can override, but we'll talk about that when it is applicable.
Hi Daniel,
Thank you so much for your reply!
That’s a very good point. When I click on tools —> osweb, the possible subject numbers are set by default as 0,1. Should I change that?
When I run it locally on opensesame (using the double green arrow), if I set the subject number 2 or 4, I get different conditions for each one. Same thing for the web browser option and jatos. When I look at the log the subject parity is odd but the condition is sometimes [condition2] or [condition1]. same thing for even subject parity.
I should also mention that i have texts on several sketchpad that i put the show if : [subject_parity] = ‘odd’ or [subject_parity] = ‘even’
These codes always seem to be working in accordance with the subject number.
I’m attaching my experiment below. I would appreciate it if you could maybe take a look at it and see if you spot an error. I have a feeling that I did something with specifying the conditions in the main experimental loop and sequence.
Thank you so much for your help!
Hi @Gazelle_M ,
I have been dealing with a loooot of counterbalancing issues and your thread captured my attention. I can't be more help than Daniel but I have noticed something that may have a contribution.
You defined your [condition] variables in rows in the experimental loop as [condition1] and [condition2] and in your sequence looks like this:
Shouldn't they be named [condition1] = VisualBlock, [condition2] = AuditoryBlock instead? Since you have the javascript code with condition1 and condition2, maybe you could just try adding the 1 and 2 in the run if statement? But your code also has the "else" statement; so the only thing I can comment is that you defined your variables as condition1 and condition2, and then defined another named condition that includes these two, but I think somehow there is a confusion there.
For a simpler solution maybe; in my experiment (which had no javascript for counterbalancing), I had defined all my variable names as columns. So if my column(thus variable) name was [condition], the rows below them would be VisualBlock and AuditoryBlock, and my run if statement would be as you did in the screenshot.
For JATOS, if you leave the Possible subject number field empty in the Tools, JATOS uses the subject_nr that itself assigns (which, as far as I noticed, is the component result ID in JATOS).
As I said, these are just what I learnt from my own adventure and just wanted to share :)
Best,
H
Hi @hulya
Thank you so much for your response.
unfortunately the problem remains even if i leave the possible subject number blank.
I also tried your other suggestion, but that didn't seem to work either. OpenSesame skipped all conditions and went straight to the end massage saying " You finished the experiment".
I'm also encountering another problem: some of my texts are not showing up in the sketchpad, despite the fact that i set the show if to always.
@Daniel do you have any suggestions?
Best,
G
Hi G.
Regarding the counterbalancing problem: in the counterbalancing inline_javascript, you could add
below your code. This prints these values to the browser console. If you are using Chrome you can open this with
ctrl+shift+i
on non-Macs andCmd+Alt+J
on macs. That way you can check if the correct values are assigned to condition1 and 2 depending on subject_parity. At least we then know if subject_parity is correctly interpreted and the conditions are correctly assigned.Another thing that I noticed (an this is probably it), is that your order is set to
random
in the experimental_loop. You need to set this tosequental
to let the conditions occur in the order that you specify them.Hi @Daniel
You were completely right! The problem was that the experimental loop was set to random.
All issues are resolved now!
Thank you so much!!!
Hi @Gazelle_M
Glad I could help!
I know this question has been resolved, but for anyone else who, like me, has returned to this thread multiple times trying to sort out their counterbalancing issues in OSWeb, I'd like to add my experience. I tried using the
subject_parity
method, but it never worked for me on JATOS, because for some reasonsubject_parity
was always set to `odd`. I also tried leaving the field for possible subject numbers blank, as suggested above, but that didn't work either. What finally did work for me was to slightly modify the suggested counterbalancing script with a function that uses thesubject_nr
variable that JATOS supplies to check for odd/even, like so:For me, this finally got counterbalancing to work when combining OSWeb with JATOS.