Use jsPsych.timelineVariable not as parameter but in a function. Possible? #1755
-
Hello all! I am very stuck and much obliged to anyone that can help. I've defined a full-factorial design, and i want to use the values in there in my stimulus displays. Normally, you'd use something like 'stimulus: jsPsych.timelineVariable('stimulus')'. However, my stimulus is a rather complex function, it needs to draw specific shapes on specific points and all that, so that function is defined beforehand (called drawStim). The factorial design:
Now my question is, is it possible to use the values from within the factorial design in that function? Since in the 'normal' way, timelineVariable is called as a parameter, and it is not a plain value like a number. I tried putting a definition in the function, like this: (lines 5 and 6)
But that doesn't work, it can't recognize the timelineVariable, i guess because it isn't a number. When i display the object eccent for example, it shows 'function() { return timeline.timelineVariable(varname); }. Can anyone help me out to properly use those values from the design in my function? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @DanielBruijn, I think you need to add the second eccent = jsPsych.timelineVariable('eccentricity', true); This |
Beta Was this translation helpful? Give feedback.
Hi @DanielBruijn, I think you need to add the second
true
argument tojsPsych.timelineVariable
, which tells jsPsych to return the value immediately, rather than returning a function that returns the value. For example, inside yourdrawStim
function you should be able to access the current value of timeline variables like this:This
true
argument shouldn't be necessary if you're using jsPsych 6.3.0+.