How to link loop parameter to slider without 'syntax error'

Hello, I am currently learning both Python and this toolbox, so this might be an easy newbie question, regardless, thank you in advance for your time and help.

OS : Windows 10
PsychoPy version : 3.2.4
Standard Standalone? (y/n) : Yes

I am building an experiment in which I display a question and try to set the sliders response ‘ticks’ and ‘labels’ on every repeat. The loop received my conditions files and seems to recognize the individual parameters without a problem.

When applying the $Question to the text section it does display the question properly, but when I use the same approach for ticks: $AnswerTicks and labels: $AnswerLabels (both set to ‘Set every repeat’) I receive a ‘syntax error’.

To check the format for these two field I have copied the first row of parameters out of the excel file into the ticks/labels box under properties, this works fine. In case it matters, appearance has been set to ‘rating’. I have included screenshots below for reference.

I would love to know where I made a mistake and how to fix it. Thanks again for your support and knowledge!

My current set up, which produces the error:

Conditions file added to loop

with the two excel parameters shown:

Hi @Leonie_Forsman, this is not actually supported with the Slider by default, so you have to add some code where you recreate the slider on each routine, with the new ticks and labels. See the example attached. For this to work, you need to reformat your conditions file to match.

slid.psyexp (7.0 KB)
cond.xlsx (8.2 KB)

1 Like

Hi @dvbridges, thank you so much! I managed to implement it, this works like a charm. Thanks again!

Hey,

I tried to implement it in the way you suggested and in the experiment you provided it works perfectly, but as soon as I implement it in my existing experiment it does not work.
I have included 4 images (3 clickable stimuli), 1 mouse component, the code component and a loop around 3 routines: A (what I just described) → B → C -----> back to A and my slider in routine A never shows up on top of the image stimuli.
When I tried to do it in your provided experiment it worked to show the slider on top of the image, but in my experiment it doesn’t show up.

It should look somehow like this (of course the slider is not positioned correctly):

Do you have any idea what needs to be changed as soon as the loop runs over several components? Or do you think it interferes maybe with the mouse component, or what else could be the problem?

I am clueless…

Best,
Carina

Hi @dvbridges, I’ve got this working in psychopy (thanks to your example!), and I’m trying to implement this in pavlovia. I have been trying to edit the javascript code, but I keep getting the error “ratings.map is not a function”.

Pyschopy 2020.1.3, windows10, firefox

So far I have tried many slight variations of this:
slider_bugv2

Conditions file looks like this:
csvVis

I’m trying to combine what you did here to refresh a variable from the Conditions file for both the slider labels and ticks. This javascript code above is a combination of trying to rewrite your psychopy code into javascript, combined with the “slider in javascript” code written here: Problems converting manually set sliders to psychoJS - #7 by awong26

Would you mind explaining what the first two lines in psychopy are doing here, so I can more explicitly figure out what to do in javascript? Or if you have direct javascript translation of course that would be fantastic!

Thanks in advance!

Hi there, this has now been solved in another thread Problems converting manually set sliders to psychoJS and this follow-up question can be disregarded. Thanks!