Different stimulus parameters on every repetition #1181
Replies: 1 comment 1 reply
-
Hi @celestialteapot, sorry for the delay. It's hard to understand exactly what you're trying to do and what problems you're having without seeing your code. Would you be able to share it please (even if it doesn't work)? Here's some general information, in case it's helpful. You're right that with a Here's an example of an anonymous function for the stimulus parameter: var feedback = {
type: 'html-keyboard-response',
stimulus: function(){
var last_trial_correct = jsPsych.data.get().last(1).values()[0].correct;
if (last_trial_correct) {
return "<p>Correct!</p>";
} else {
return "<p>Wrong.</p>"
}
}
} And the same thing but with a named function: function generate_stimulus() {
var last_trial_correct = jsPsych.data.get().last(1).values()[0].correct;
if (last_trial_correct) {
return "<p>Correct!</p>";
} else {
return "<p>Wrong.</p>"
}
}
var feedback = {
type: 'html-keyboard-response',
stimulus: generate_stimulus
} And if you want to include information in these functions that comes from the trial information stored in {
type: 'html-keyboard-response',
stimulus: function(){
var html="<img src='"+jsPsych.timelineVariable('face', true)+"'>";
html += "<p>"+jsPsych.timelineVariable('name', true)+"</p>";
return html;
},
choices: jsPsych.NO_KEYS,
trial_duration: 2500
} Sorry if none of this helps with your question... please feel free to post some code/examples and we'll do our best to offer more specific suggestions! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I created an experiment where the stimulus parameters are computed by a function (multiple random samplings involved; three stimuli without interaction, then a test) and I would like to run several of this trial sequence consecutively. Crucially, each repetition should have different parameter values (ie. a new output from the function), but by using the 'repetitions' parameter I get the exact same value set for every rep. I passed the parameter-value-computing function to 'timeline-variables' as 'timeline-variables: my_func()'. Is there a solution for this problem?
As an alternative resolution I tried using the 'call-function' plugin and passing its 'value' to the stimulus trial, but this doesn't work either, since it gives undefined for the 'call-function' trial data. If I understand correctly the timeline is compiled before running (or something like that), so the output of the 'call-function' trial does not exist yet when the stimulus trial would already want to have it?
I guess this topic is similar to (the same as?) the dynamic parameters/timeline variables problem.
Edit [clarification]: my timeline would look like [fixation, regenerate_stimuli, stimulus (x3), fixation, test] repeated multiple times.
Thanks for this awesome library,
Balint
Beta Was this translation helpful? Give feedback.
All reactions