Howdy, Stranger!

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

Supported by

"Uncaught TypeError" when porting gabor experiment to OSWeb

I have a basic category learning experiment that utilizes gabors that runs readily on my computer locally, but when I try to run it in browser, I see this error message:

Two of the initial screens appear, but immediately after the error message prevents any further progress. Any thoughts on how to fix this?

Comments

  • Hi @albertyang ,

    OSWeb supports only a subset of the functionality that OpenSesame supports. You can find an overview of supported functionality here:

    In your case, the problem is that inline_script items are not supported. So you will need to find a way to implement that same functionality with a sketchpad . Looking at your code, I think that should be doable though.

    Cheers!

    Sebastiaan

  • Hi @sebastiaan,

    Thanks for the response! Do you mean that I should swap out the inline_script for inline_javascript, or is there some more functionality with sketchpad that would be sufficient to do the processing I have in mind? If I were using inline_javascript, how could I work around using a Canvas?

    Thanks for all the help!

    Albert

  • Hi @albertyang ,

    Insofar as I can see, you only really need the Python inline_script to determine the properties of the Gabor stimulus:

    c = Canvas()
    c.text(var.category)
    c.gabor(0, 0, -1.98 *(.045 * var.orientation + 1), (var.spatial_freq / 30) + .25, env='circular', size=500,stdev=60)
    

    So what you could do instead is use a simple inline_javascript to determine these properties:

    vars.gabor_ori = -1.98 * (0.45 * vars.orientation + 1)
    vars.gabor_sf = (vars.spatial_freq / 30) + .25
    

    And then you use these variables ([gabor_ori] and [gabor_sf] ) to determine the gabor element of a sketchpad :

    draw gabor bgmode=avg color1=white color2=black env=circular freq=[gabor_sf] orient=[gabor_ori] phase=0 show_if=always size=500 stdev=60 x=0 y=0 z_index=0
    

    Does that make sense?

    Cheers,

    Sebastiaan

  • Hi @sebastiaan,

    Sorry for the basic questions as I am very new to Javascript and OpenSesame. While I understand the switch you made to the inline_javascript, is there a native gabor functionality to Javascript such that the code you attached should be sufficient as is? I edited the code as you showed, with my current rendition below. Whenever I try to run this, I always encounter a SyntaxError: Line 1: Unexpected identifier with the assignment of the Gabor stimulus properties. Do you know what the issue could be with this, or do you have any other guidance? Thanks again for all your help.

    Best,

    Albert Yang

  • edited August 2020

    Hi @albertyang ,

    Just to clarify, this:

    draw gabor bgmode=avg color1=white color2=black env=circular freq=[gabor_sf] orient=[gabor_ori] phase=0 show_if=always size=500 stdev=60 x=0 y=0 z_index=0
    

    Should go in the script of a sketchpad, which you can access by clicking on the View → View Script button at the top-right of the sketchpad controls. So this is not JavaScript!

    See also:

    Cheers,

    Sebastiaan

Sign In or Register to comment.