Simple priming experiment issues #1680
-
Hi there, For starters I have minimal coding experience. I want to create a simple priming experiment that does the following:
Here is the errors from the dev tools: jspsych.js:2234 Invalid media_type parameter for jsPsych.pluginAPI.registerPreload. Please check the plugin file. Here is the code: <!doctype html>
<html lang="en">
<head>
<title>Effect of Frame of Reference on Biological Motion [jsPsych]</title>
<meta charset="UTF-8">
<script type="text/javascript" src="jspsych-6.0.0/jspsych.js"></script>
<link href="css/jspsych.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="plugins/jspsych-html-keyboard-response.js"></script>
<script type="text/javascript" src="plugins/jspsych-image-keyboard-response.js"></script>
<script type="text/javascript" src="plugins/jspsych-video-keyboard-response.js"></script>
<script type="text/javascript" src="lib/vendors/jquery-2.2.0.min.js"></script>
<script type="text/javascript" src="lib/jspsych-pavlovia-2020.2.js"></script>
</head>
<body>
<script type='text/javascript'>
/* create timeline */
var timeline = [];
/* init connection with pavlovia.org */
var pavlovia_init = {
type: "pavlovia",
command: "init"
};
timeline.push(pavlovia_init);
/* define welcome message trial */
var welcome = {
type: "html-keyboard-response",
stimulus: "Welcome to the experiment. Press any key to begin."
};
timeline.push(welcome);
/* define instructions trial */
var instructions = {
type: "html-keyboard-response",
stimulus: "<p>In this experiment, a silhouette of the ground " +
"will appear on the top or bottom of the screen</p>" +
"<p>This will be followed by a moving person animated as several moving " +
"dots. This can be upright or inverted</p>" +
"<p>If animation if facing left then press F " +
"as fast as you can.</p>" +
"<p>If animation if facing right then press J " +
"as fast as you can.</p>" +
"<p>Press any key to begin.</p>",
post_trial_gap: 2000
};
timeline.push(instructions);
/* priming stimuli */
var prime_stimuli = [
{ stimulus: "stimuli/Grass_Inverted.jpg", data: { test_part: 'test', correct_response: 'f' } },
{ stimulus: "stimuli/Grass_Upright.jpg", data: { test_part: 'test', correct_response: 'j' } }
];
/* test stimuli */
var test_stimuli = [
{ stimulus: "stimuli/Walk-90L-upright.mp4", data: { test_part: 'test', correct_response: 'f' } },
{ stimulus: "stimuli/Walk-90L-inverted.mp4", data: { test_part: 'test', correct_response: 'f' } },
{ stimulus: "stimuli/Walk-90R-upright.mp4", data: { test_part: 'test', correct_response: 'j' } },
{ stimulus: "stimuli/Walk-90R-inverted.mp4", data: { test_part: 'test', correct_response: 'j' } }
];
// Fixation cross //
var fixation = {
type: 'html-keyboard-response',
stimulus: '<div style="font-size:60px;">+</div>',
choices: jsPsych.NO_KEYS,
trial_duration: 1000,
data: { test_part: 'fixation' }
}
var prime = {
type: "image-keyboard-response",
stimulus: jsPsych.timelineVariable('prime_stimuli'),
choices: jsPsych.NO_KEYS,
data: jsPsych.timelineVariable('data'),
};
var test = {
type: "video-keyboard-response",
stimulus: jsPsych.timelineVariable('test_stimuli'),
choices: ['f', 'j'],
data: jsPsych.timelineVariable('data'),
on_finish: function (data) {
data.correct = data.key_press === jsPsych.pluginAPI.convertKeyCharacterToKeyCode(data.correct_response);
},
};
var prime_procedure = {
timeline: [prime],
timeline_variables: prime_stimuli,
repetitions: 1,
randomize_order: true
}
var test_procedure = {
timeline: [prime_procedure, fixation, test],
timeline_variables: test_stimuli,
repetitions: 2,
randomize_order: true
}
timeline.push(test_procedure);
/* define debrief */
var debrief_block = {
type: "html-keyboard-response",
stimulus: function () {
var trials = jsPsych.data.get().filter({ test_part: 'test' });
var correct_trials = trials.filter({ correct: true });
var accuracy = Math.round(correct_trials.count() / trials.count() * 100);
var rt = Math.round(correct_trials.select('rt').mean());
return "<p>You responded correctly on " + accuracy + "% of the trials.</p>" +
"<p>Your average response time was " + rt + "ms.</p>" +
"<p>Press any key to complete the experiment. Thank you!</p>";
}
};
timeline.push(debrief_block);
/* finish connection with pavlovia.org */
var pavlovia_finish = {
type: "pavlovia",
command: "finish",
participantId: "JSPSYCH-DEMO"
};
timeline.push(pavlovia_finish);
/* start the experiment */
jsPsych.init({
timeline: timeline,
on_finish: function (data) {
jsPsych.data.displayData();
}
});
</script>
</body>
</html> |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The error you're getting is related to jsPsych not finding the stimuli files for your trials. In your I hope that makes sense. You could also have a look at the documentation for timeline variables. |
Beta Was this translation helpful? Give feedback.
The error you're getting is related to jsPsych not finding the stimuli files for your trials. In your
prime
andtest
trials, the values of thestimulus
parameters arejsPsych.timelineVariable('prime_stimuli')
andjsPsych.timelineVariable('test_stimuli')
. However, you need to give thejsPsych.timelineVariable
function the name of the key (property) that contains the stimulus file name inside each of the objects in your timeline_variables arrays (prime_stimuli
andtest_stimuli
). That object key is called "stimulus" in both of your timeline_variables array, so for both yourprime
andtest
trials, you should change thestimulus
parameter tojsPsych.timelineVariable('stimulus')
.I hope that ma…