Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Having trouble reliably counterbalancing in JATOS using OSweb

Hi everyone,

I’m trying to build two new experiments in which I want to counterbalance over 2 and 4 conditions respectively using the subject_nr variable. I’ve just completed two pilots that ran simultaneously (with two conditions) and I’ve found that the distribution of the two conditions is very skewed (17 vs 30!). After some digging, I think I understand what went wrong but I’m not sure how to fix it. Some questions that are on my mind:

1. Is it correct that that the formula for determining the subject_nr is: jatos.componentResultId%possible subject number? I’m basing this on the line from the generated jatos.js: ‘subject_nr = possible_subject_nrs[jatos.componentResultId % possible_subject_nrs.length]’. The 'possible subject nrs' variable should then be determined by what I put in the possible subject field in OS’ GUI (i.e. 1,2).

2. If 1 is true, this means that having two studies run simultaneously interfered with the counterbalancing procedure (because the jatos.componentResultId numbers were split among my two pilot studies). I won’t be running anything else besides this future study so that would be solved, but it would be more problematic if these numbers are divided among all users on my university’s server. Does anyone know how allocation of jatos.componentResultId works exactly? In other words: Are the jatos.componentResultId numbers incremented account wide or server wide?  

3. In the case this is all wrong or I have overlooked something obvious: do you have a suggestion on how to implement counterbalancing in a reliable way? I know I could make individual links, but I would like to avoid manual labor. Not sure if this is relevant, but I’m using General multiple links.

Let me know if you need more information! Thanks in advance,



Posts I used: (the example counterbalancing script does not work for me, probably because our server is still running 3.5.4. Second thing I tried was using the jatos.worker.Id but as far as I can see this increments in the same way as jatos.componentResultId)


  • edited March 2022

    Hi Tom,

    Sorry for the delay.

    To answer your question: componentResultID (and in general all IDs) increase serverwide. So it's a bad idea to use that, or even the subjectID, to randomize. I realize this is probably a recommendation from OSWeb, maybe we can raise this issue with them.

    I can't really help much if you want to implement it on OSWeb (in which case it would be better to ask in their forum). Instead, I would really recommend you add another component at the beginning where you randomize your participant assignment with full flexibility.

    You said that you tried the example and it doesn't work on your server, but I doubt it's because of the JATOS version. That study has been around for a while and even if it is something about version incompatibility, it should be easy to fix.

    So, first question:

    If you download, import, and run the example "Randomize tasks between workers" (study), do you get any error messages in the console?

    Second, do you know how to combine two studies (one OSWeb, one not) so that each of them forms a single component of a larger JATOS study?



  • Hi Elisa,

    Thanks for getting back to me! I don’t know where I got the idea that I could use the subject_nr for randomization, but I’ve used it last year for an actual study and it appeared to work perfectly fine then. I now realize I must’ve been lucky to get a good distribution.


    With regard to you first question: I’m getting a 404 error when I click your link, but I think you meant to forward to


    I've downloaded and imported the JATOS study, but it did not work out of the box. I'll outline the steps I tried getting the sortStartingCondition component to work below. I’m no programmer, so apologies if I miss something obvious.

    1. The first problem I encountered was a greyed out ‘Continue’ button. I removed ‘disabled’ from the <button> element in the HTML. That made it clickable again.

    2. The next problem was that it throws an error on line 75 (log from the console). See screenshot. There’s also tons of ‘No open batch channel’ errors but I’m not sure how relevant these are.


    It seems that the function var conditions = jatos.batchSession.get("conditions") results into “conditions” being set to undefined (I’ve put in a console.log(conditions) and it says undefined in the console). Is there more input required from my side?


    Regarding your second question: yes, I’ve worked with multiple component studies before so I’m confident I can stitch them together once I get sortStartingCondition started.




  • Hi Tom,

    Very sorry again for the long (and hopefully unusual) delay. These days are really busy. I should be able to reply quicker from now on.

    I downloaded JATOS v 3.5.4 (you really should convince your admins to update your server). I downloaded the study (thanks for correcting the link) and for me it did actually work out of the box. I tried on both Chrome and Safari, and didn't get any of the errors, greyed out buttons, or warnings you mentioned. Which browser are you using?

    This also makes sense to me: the randomization script is pretty basic, and shouldn't depend on the JATOS version. The batch session, on which this study depends, has also been around for quite a while. Maybe those warnings you get are actually the problem. If you have admin rights, could you check what you see on the JATOS test page: http://[yourdomain]/jatos/test

    In particular could you check the status of Open WebSocket?



  • Hi @elisa

    No worries!

    That is quite strange.. I have tried it in Chrome, Edge and Firefox but the box is grayed out in all of them. Unfortunately I don't have admin rights to our server so that URL doesn't work. I can try to get in touch with the admin and get him to run the command.

    In the meanwhile, is there anything else I can try?



  • Hi, you could try a different study that also relies on the batch session. They're labelled with (basic) tags on our example page, but maybe a good one to try is the batch chat

  • Hi @TIJ

    i was wondering if you managed to figure this out?

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games