Howdy, Stranger!

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

Supported by

A method to randomly select a stimulus list for online experiments (javascript, JATOS compatible)

Hi there,

I was working on an experiment in which I wanted to import stimuli lists by randomly selecting a stimuli file and have been looking for a way around the fact that OSWeb does not currently support the file source method for sequence objects.

The method consists in emulating a list of stimuli file by using memory array within the task itself. There was an error displaying this embed.

I'm sharing the outcome in case this can be of help other users. It's just a workaround method, and there probably are more elegant methods, but it works when running the experiment online with JATOS.

I include below a description of the method below, together with the task and an Excel sheet to help write the javascript to define memory arrays containing the lists of stimuli.

Thanks are due to @lvanderlinden, @eduard and @sebastiaan for helpful hints and suggestions along the way!

Please suggest improvements if you see things that can work more effectively!



OS allows loops to be populated with values imported from a file (whether fixed or randomly selected). This is especially useful when stimuli sequences must follow a very specific order and fulfil conditions that are best set up outside the task itself. However, OSWeb, at present, does not support this file source method.

This task illustrates a way to get around this limitation for experiments running in a browser with OSWeb/Jatos by use of some Javascript.

Note: For a list of features not currently (March 31th 2021) supported in OSWeb see:


This task illustrates a method to select a stimulus set at random from a list of stimulus sets that will work in a browser.

To achieve a similar result in OSWeb, it is necessary to implement Javascript code.

Uploading a csv (or some other file) from the server is not an easy task and security settings may prevent it. Hence, a different method is proposed here.

The method developed here consists in defining arrays to store the stimuli sets in memory. That is, all of the possible stimuli sets are loaded in memory at the onset of the task. The task then joins these arrays in a meta array, from which it'll pick one element at random to constitute the array that will serve as the stimuli list to be used in the test trials of the experiment. No-longer needed arrays are then deleted to free memory.

Writing the code for the arrays can be painful if you use many arrays and if they are large. In that case, one good option is to automate that writing externally and then pasted it in the inline_javascript object. I include with this task an Excel sheet using the CONCAT formula to generate the javascript for the arrays. Other solutions would work well too, such as writing a separate program for that purpose.

To make the writing of the arrays easier, the recommendation is to keep it to the minimum necessary and create additional variables programmatically. In this example, the correct responses are need not be coded into the array but are defined using Javascript code as the task runs.

In this example, this method is applied to the test trials of the task. Practice trials are defined manually in the practice_loop using a table.

In this task, 5 stimuli arrays are loaded in memory, one of which will be used in the task. The arrays for the test trials information contain 48 rows and 3 columns. These correspond to the 48 trials to be presented across 4 blocks of 12 trials each. Hence, the test trials sequence is nested within a loop running 4 times. For that reason, the test_trials loop contains 12 rows (which will be populated from the array as the task runs).

The number of arrays, their dimensions, the number of blocks can be edited as needed. One constrain, however, is that the (number of test trials per block) x (the number of test trial blocks) should be equal or inferior to the number of rows in each array. If it is inferior, some test trials will remain undefined and the task will stop because it cannot find then necessary information in the test_trials loop. If it is equal, then all trials from the selected array will be presented. If it is inferior, some trials defined in the selected array will remain unused.

Based on the tests I carried out, with this method it seems necessary to format the table in the test_trials loop so that it contains the appropriate number of rows and the columns with the appropriate variable names.

More details can be found in the annotations in the inline_javascript objects throughout the task.


In this example, the task simply presents a fixation cross, a tone, followed by an arrow pointing left or right.

The task implements a method to keep the inter-trial interval to a fix value. That is, the target stimulus (arrow) remains on the screen even if a response is detected and the sum duration of the target on screen before response and of the target on screen after response is constant.

Some information appears on the screen and in the console for easy monitoring of what's going on. Also, the arrows alternate from left to right predictably on purpose: to make it easy to purposely produce correct and incorrect responses while checking that the task is scoring everything correctly.


There may well exist alternative and more elegant ways of achieving the same aim. If you use this program or parts of it, please make sure to check your task thoroughly before deploying it to collect actual data. This task is provided "as is". 

Buy Me A Coffee


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