psychopy icon indicating copy to clipboard operation
psychopy copied to clipboard

ShapeStim not working on PsychoJS

Open Avijit-Chowdhury1 opened this issue 3 years ago • 6 comments

I am including a visual.ShapeStim in my PychoPy which runs well offline (using python) but when I run it online the "lineColor" attribute is not functional - I indicate the color as red but it shows as black when I run it on Pavlovia;

Here is my task code: https://gitlab.pavlovia.org/s9072080E/sit2

The task is named "MarketTask.py"

Can someone help me with debugging, please?

Thanks

Avijit-Chowdhury1 avatar Nov 05 '21 13:11 Avijit-Chowdhury1

@peircej Hi, any help on this, please?

Avijit-Chowdhury1 avatar Nov 10 '21 16:11 Avijit-Chowdhury1

I can't access the experiment file, are you setting its lineColor via a line of code or via the parameter in Builder being Set Each Frame?

TEParsons avatar Jan 06 '22 13:01 TEParsons

I am setting its linecolor via code. Is there a way I can send you the code?

I am using the following code in the Python code window, but the automatic translation of this into Javascript using Psyhopy does not work:

stock= visual.ShapeStim( win=win, closeShape=False, units='height', lineWidth=3, lineColor='red', vertices= XY, pos=(Xaxis.pos[0], Yaxis.pos[1]-displacement), size=(Xaxis.size[0], investment.size[1]*5), autoDraw=True )

Avijit-Chowdhury1 avatar Jan 06 '22 13:01 Avijit-Chowdhury1

I believe GitHub doesn't allow .psyexp files, but if you change the file extension to .txt it should let you (I can then just change it back to open it :P )

TEParsons avatar Jan 06 '22 14:01 TEParsons

I tried syncing it to Github: https://gitlab.pavlovia.org/s9072080E/sit2

The file is MarketTask.psyexp (not MarketTask1 or MarketTask2)

Hopefully this works

Avijit-Chowdhury1 avatar Jan 06 '22 14:01 Avijit-Chowdhury1

Ah I think I see the problem - PsychoJS wants colors to be a util.Color object, while PsychoPy does this in the background.

For your specific experiment, I think you should be able to make that ShapeStim as a Polygon component - just set the shape to be custom polygon... so you can supply the vertices directly. Otherwise, you'll need to change the mode of that code component to be "both" rather than auto translate, and just change it so that on the Python end you've got

lineColor='red',

and on the JS side you've got

"lineColor": new util.Color("red"),

This is a legit bug though; either colors.Color should translate to util.Color or PsychoJS should mirror util.Color in colors.Color, so that the two are synonymous. Will try to get a fix in :)

TEParsons avatar Jan 07 '22 14:01 TEParsons