Howdy, Stranger!

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

Supported by

accessing the file pool with javascript

edited July 2021 in OSWeb


Is there a way to access the file pool with javascript, similar to python e.g :

if (a=1) { 




  • Hi @dsoto ,

    Of sorts, yes, but it's not really intended to be used that way, and I also don't see many scenarios in which this is useful.

    From your question, it looks like you want to know the name of a file in the pool. You can do that as follows:

    vars.distr_img = runner._pool["cat.jpg"].name

    If you open the developer console of the browser, you can also interact with the file pool to see which properties exist etc.. Especially in Chrome this is really nicely implemented.

    You may also be interested in this post, about loading external stimuli into the file pool. It's not directly related to your question, but it also shows how to interact with the file pool programmatically.

    -- Sebastiaan

  • Hi, thanks for the message Sebastian, I think I did not explain well

    I have 30 images of 2 categories in the file pool. Now, using OSWeb I would like to select randomly on every trial one image of each category and display them together.

    My question is whether OSweb allows for this type of functionality



  • Hi David,

    Yes, that is possible. You can use the Javapscript_inline script, which has essentially the same syntax as the python inline_script has.

    See this part of the manual:

    So, you then you need only to randomly select the filename on every trial and can put that one into the code to access the pool. For randomization, this might be useful.


    Buy Me A Coffee

  • Hi,

    I am running into a similar problem. I am designing an online experiment in which participants are presented with triplets of randomly selected images, however I am not able to select images from the pool. How can I access the pool in online experiments??

    My browser gives me the following error:

    This is the code I am using for now, I just want to present one image to see that everything is working

    Prepare tab:

    vars.path = runner._pool['LT1.png'].name
    persistent.img1 = Canvas()
    persistent.img1.image({fname: vars.path, x: 250, y: 0})

    Run tab:

    I thought that this error could be due to the infamous CORS policy, so I try storing the stimulus file on GitHub repo and adding it to the pool. For that I basically insert the following lines of code at the beginning of the prepare tab:

    function addExternalImageToPool(url, name) {
      const img = new Image()
      img.crossOrigin = "anonymous"
      img.src = url
      const item = {
        data: img,
        type: "image",
        name: name

    Then I access the pool as before:

    vars.path = runner._pool['LT1.png'].name
    persistent.img1 = Canvas()
    persistent.img1.image({fname: vars.path, x: 250, y: 0})

    But I get the same error...

    Please help me with this problem!

  • Hi Patxelos,

    I can only guess here, but the way you call the pool (via the runner) is not what the manual suggests. Instead you should use

    var myCanvas = Canvas()
    myCanvas.image({fname: 'LT1.png'})

    See also here

    Good luck,


    Buy Me A Coffee

  • Hi Eduard,

    Thank you for your reply. Unfortunately, I think that my error is not related to the way I call the pool but the CORS policy, because the experiment works well offline. Actually, I am basically using the line of code suggested by @sebastiaan to get the stimuli names from the pool (see above). Have you ever managed to present online stimuli with opensesame? I would appreciate any help with this issue



  • Hi @patxelos ,

    The error that you're seeing in the console is related to the OSWeb logo at the start of the experiment, which doesn't work when testing locally in a browser (indeed due to the CORS policy). But that's harmless, and there's nothing in the console output that indicates a problem with your experiment specifically.

    What exactly are you trying to do with the file pool? And in what sense doesn't it work as you'd like it to?

    — Sebastiaan

  • Hi @sebastiaan,

    Thank you for you reply. I have an offline experiment in which I present randomly selected pairs of images from two different classes and participants have to identify the 'most desirable' one. So, I just want to run this experiment online. Is that possible? I guess that for that I need to access the pool online but I don't know how to do it. I have both tried doing it like in offline experiments and also adding them to the pool from an online raw.githubserver but any of them work.

    Experiment description: I have a two lists of image names, one for each class, that are shuffled at the beginning of the experiment and then I select one image from each list using an indexing variable that it is updated on each trial (ie, tr += 1). Image names are used to obtain image paths from the pool and then these paths are used to prepare the stimuli with the canvas object.

    Many thanks for your attention and time :)



  • Hi @patxelos ,

    Yes, that's absolutely possible. The file pool is simply available also in an online experiment. You don't need to do anything specific for that!

    — Sebastiaan

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