cognition.run external json stimuli #1227
-
Hi all, I'm working on a SART and an implementation onto cognition.run. Here the sample code about the stimuli files and timeline I used in cognition.run: var test_stimuli ="test_stimuli_cognition_short.json"
var number = {
type: 'html-keyboard-response',
stimulus: function() {
// this is how you can combine different variables from your timeline_variables array
return '<p style="font-size: '+jsPsych.timelineVariable('fontsize', true)+'px;">'+jsPsych.timelineVariable('number', true)+'</p>';
},
choices: ['space'],
trial_duration: 250,
data: {
condition: jsPsych.timelineVariable('condition'),
},
on_finish: function(data){
if(data.condition == 'Go'){
data.correct = jsPsych.pluginAPI.compareKeys(data.key_press, 'space');
} else {
data.correct = jsPsych.pluginAPI.compareKeys(data.key_press, '');
}
}
};
var test = {
timeline: [number, mask],
timeline_variables: test_stimuli,mask,
data: {
'test_part': 'test'
}
} My json file is like this: [
{
"number": 9,
"condition": "Go",
"fontsize": 120
},
{
"number": 6,
"condition": "Go",
"fontsize": 94
},
{
"number": 1,
"condition": "Go",
"fontsize": 100
},
{
"number": 4,
"condition": "Go",
"fontsize": 94
},
] Thanks! Alex |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 6 replies
-
Hi Alex, It looks like there might be a typo here:
The Also, checkout this video about how to integrate JSON into an experiment. I recommend defining a variable name in the JSON file (making it a |
Beta Was this translation helpful? Give feedback.
-
My bad, I though that your video concerned the loading of external stimuli in cognition.run. the undefined events are coded this ways:
and the trial is run through:
Moreover, the run stopped after 1 trial. Alex |
Beta Was this translation helpful? Give feedback.
-
Edit:
My file stimuli.j looks like this:
|
Beta Was this translation helpful? Give feedback.
Hi Alex,
It looks like there might be a typo here:
The
mask
variable is probably a mistake?Also, checkout this video about how to integrate JSON into an experiment. I recommend defining a variable name in the JSON file (making it a
.js
file) and then accessing that through the main experiment.