| Reference | Downloads | Github

Simulus position list via conditions file doesn't convert to javascript (builder)


URL of simple version of experiment that replicates the issue:

Description of the problem:

The experiment linked above replicates a problem I encountered with an experiment in which the positions to present stimuli (e.g., [0, 0]) are specified in a parameter (named ‘textlocation’) in a conditions file. When running the experiment in Builder, simply putting the textlocation parameter name in the position field of the text stimulus works fine (so the above experiment runs fine in Builder). But when running online, it results in the following error with converting the list from a string to a javascript numerical array:

Error: Unfortunately we encountered an error: { “origin” : “util.toNumerical”, “context” : “when converting an object to its numerical form”, “error” : “unable to convert: (0, 0) to a number.”}

The same error occurs if a list or tuple is specified in the conditions file.

PARTIAL SOLUTION: For a list, the problem running online is fixed by specifying the position as: JSON.parse(textlocation). But this breaks the Builder version. So it appears to be a problem with converting from python to javascript for running the experiment online?

Also, the JSON.parse solution didn’t work if the conditions file contains tuples instead of lists.


I think the problem is that the position tuple is loaded as a string from the conditions file, so cannot be interpreted as a number. If you instead have separate columns for x and y, and just add the relevant numbers, you can get around this issue. E.g., you have two cols in your conditions file, posX and posY, and in your shape stim you set the position to update on every repeat, with the following entry: [posX, posY].

Just for info, JavaScript will not read a tuple as a list in the same way Python does. You need to use the array format (square brackets).


Great, thanks. Separating into two numerical columns for X and Y worked.

(I deleted the listerror experiment linked to above.)