/** * jsPsych plugin for showing scenes that mimic the experiments described in * * Fiser, J., & Aslin, R. N. (2001). Unsupervised statistical learning of * higher-order spatial structures from visual scenes. Psychological science, * 12(6), 499-504. * * Josh de Leeuw * * documentation: docs.jspsych.org * */ jsPsych.plugins['vsl-grid-scene'] = (function() { var plugin = {}; jsPsych.pluginAPI.registerPreload('vsl-grid-scene', 'stimuli', 'image'); plugin.info = { name: 'vsl-grid-scene', description: '', parameters: { stimuli: { type: jsPsych.plugins.parameterType.IMAGE, pretty_name: 'Stimuli', array: true, default: undefined, description: 'An array that defines a grid.' }, image_size: { type: jsPsych.plugins.parameterType.INT, pretty_name: 'Image size', array: true, default: [100,100], description: 'Array specifying the width and height of the images to show.' }, trial_duration: { type: jsPsych.plugins.parameterType.INT, pretty_name: 'Trial duration', default: 2000, description: 'How long to show the stimulus for in milliseconds.' } } } plugin.trial = function(display_element, trial) { display_element.innerHTML = plugin.generate_stimulus(trial.stimuli, trial.image_size); jsPsych.pluginAPI.setTimeout(function() { endTrial(); }, trial.trial_duration); function endTrial() { display_element.innerHTML = ''; var trial_data = { stimulus: trial.stimuli }; jsPsych.finishTrial(trial_data); } }; plugin.generate_stimulus = function(pattern, image_size) { var nrows = pattern.length; var ncols = pattern[0].length; // create blank element to hold code that we generate var html = '
'; // create table html += ''; for (var row = 0; row < nrows; row++) { html += ''; for (var col = 0; col < ncols; col++) { html += ''; } html += ''; } html += '
'+ '
'; if (pattern[row][col] !== 0) { html += ''; } html += '
'; html += '
'; html += '
'; return html; }; return plugin; })();