ReferenceErrorr: colors is not defined

URL of experiment:

Description of the problem:
unfortunately we encountered the following error:
referenceError: colors is not defined
try to run the experiment again. if error persists, contact the experiment designer

Hi community member. I’m a new member, trying to run an experiment designed by my friend on Psychopy . The experiment was designed on previous versions of Psychopy, and I have adapted it in Psychopy-2022.1.2 by changing the time length and adjusting the resource file (excel file). It runs fine on Psychopy, but when I try to run it on pavlovia, I get this error. What should I do?

Color error

I appreciate your help in advance.

Cheers

Hello Michael

where and how do you define the variable colors? Do you mind showing us the relevant code?

Best wishes Jens

Hi Jens,

Thanks for your prompt reply. The experiment was created in Psychopy where the screen background was set as black. This is the code in javascript on gitlab.

// open window:
psychoJS.openWindow({
fullscr: true,
color: new util.Color([(- 1.0), (- 1.0), (- 1.0)]),
units: ‘height’,
waitBlanking: true
});

The same code in Psychopy javascript looks like this:

// open window:
psychoJS.openWindow({
fullscr: true,
color: new util.Color((-1.0000, -1.0000, -1.0000)),
units: ‘height’,
waitBlanking: true
});

I’m not sure if I addressed your questions.

Hello Michael

I am not good in reading JS. Do you mind posting the relevant code-component, make a screenshot or post the Python and JS-code here. If you surround the code by triple ` it will be properly formatted. See

print("var1: ", var)

vs.

print("var1: ", var1)

Best wishes Jens

Hi Jens,

I’m also not good at reading codes. I’m sending you the Psychopy and the resources files. I hope you can open it in psychopy and see if it works when you send it to pavlovia.

WMC_DRAFT.xlsx (12.9 KB)
WMCT.psyexp (85.2 KB)

Hello Michael,

you define the variable colours in the code-component, Begin experiment tab, “code_11” in the Type-routine. I have no idea what you are using it for?

colours = 0

You define the marker-colour of your slider with “$colors.Color((-1.0000, -1.0000, -1.0000), space=‘rgb’)”. If I set the marker-colour via the menu it ends up as “1.0000, 1.0000, 1.0000”. Any reason why to set it up this way? Given that the error message reads “colors is not defined” I suspect that this the cause of the error and not the colours-definition above which you don’t seem to be using, anyway

Just a side note: You don’t define Start-times and durations for the components in your Type-routine. You use multiple instance of the same routine differentiating them by using different names, e.g. O1 to O5 and L1 to L5. This makes maintaining the experiment difficult. It is better to use the same routine repeatedly. You can achieve that by using two loops, one which runs over O1/L1 to O5/L5 and an outer loop that runs over the trials.If you place the practice trials outside these loops you save the conditional:

if Practice == 'blank':
    continueRoutine= False

You could use the same routine for the practice trials and the experimental trials. So, your experiment would boil down quite a bit.

Best wishes Jens