multiple parameters in a drawStim like function for the stimuli parameter in keyboard-canvas-response #1956
-
Looking to this page: https://www.jspsych.org/plugins/jspsych-canvas-keyboard-response/ it seems that by default the function passed to the stimuli parameter takes one argument 'c'. However, I am trying to staircase my stimuli (i.e. change the number of dots presented to participants based on previous correct responses), and so I need to change the stimuli that is drawn each time. Is there a way to have the drawStim example function in the link above accept multiple parameters - in this case, just a number of dots? Some example code below, if helpful:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @Max-Lovell! You can find an example of a canvas stimulus function with multiple arguments in the "jspsych-canvas-button-response.html" file in the /examples folder. The trick is to use a function for the stimulus parameter that just takes the canvas argument, but then inside that function, you can call a different function that takes multiple arguments. var circle_1 = {
type: 'canvas-button-response',
stimulus: function(c) {
filledCirc(c, 100, 'blue');
}
} The additional arguments used by the |
Beta Was this translation helpful? Give feedback.
Hi @Max-Lovell! You can find an example of a canvas stimulus function with multiple arguments in the "jspsych-canvas-button-response.html" file in the /examples folder. The trick is to use a function for the stimulus parameter that just takes the canvas argument, but then inside that function, you can call a different function that takes multiple arguments.
The additional arguments used by the
filledCirc
function above could be calculated before this function is called. So to apply that to your task - inside the main stimulus function, you could add some code to check the par…