Closed rouderj closed 2 years ago
Thank you for using my plugin! I am very sorry for the delay in replying.
I think that the following code is probably close to the program you want.
const nTrials = 20
let trial_num = 1
let current = 90;
const trial = {
type: 'psychophysics',
canvas_height: 500,
prompt: '<p>Press the ArrowUp/ArrowDown key to change the position and tilt of the gabor.</p>',
stimuli: function(){
const gabor_obj = {
obj_type: 'gabor',
startX: current,
startY: 150,
tilt: current,
sf: 0.05,
phase: 90,
width: 150,
sc: 10,
contrast: 0.5,
disableNorm: true
};
return [gabor_obj]
},
response_type: 'key',
choices: [' ', 'ArrowUp', 'ArrowDown'],
}
const loop_node = {
timeline: [trial],
loop_function: function(data){
if (trial_num < nTrials){
trial_num++
if (data.values()[0].response === 'arrowup'){
current += 2
} else { // arrowdown
current -= 2
}
return true
} else {
return false
}
}
}
/* start the experiment */
jsPsych.init({
timeline: [loop_node],
on_finish: function(){jsPsych.data.displayData();}
});
Please see the looping timelines and the dynamic parameters, and note that my plugin is not compatible with jsPsych V7.
Thank you very much! I am going to learn loop_function which is new to me.
The psychophysics plugin is now compatible with jsPsych V7. Sorry to keep you waiting. You can download it from https://github.com/kurokida/jspsych-psychophysics/releases/tag/v3.0.0
Hi, I can change certain gabor parameters with the event handler examples, for startX, but I cannot change others, such as tilt. for example, jsPsych.currentTrial().stim_array[0].startX = 50 changes the position as expected. jsPsych.currentTrial().stim_array[0].tilt=50 does not change the tilt. any thoughts? much thanks.
This example should change both tilt and startX, but it only shifts the gabor and does not change the tilt :(
let current = 90;