<script src="jspsych/jspsych.js"></script>
<script src="jspsych/plugins/jspsych-html-keyboard-response.js"></script>
<link rel="stylesheet" href="jspsych/css/jspsych.css">
.fixation { border: 2px solid black; height: 100px; width: 200px; font-size: 24px; position: relative; margin: auto; }
.fixation p { width: 100%; position: absolute; margin: 0.25em;}
.fixation p.top { top: 0px; }
.fixation p.bottom { bottom: 0px; }
.correct { border-color: green;}
.incorrect { border-color: red; }
type: 'html-keyboard-response',
stimulus: '<p>Welcome to the experiment. Please press C to continue.</p>',
type: 'html-keyboard-response',
stimulus: '<p>You will see two sets of letters displayed in a box, like this:</p>'+
'<div class="fixation"><p class="top">HELLO</p><p class="bottom">WORLD</p></div>'+
'<p>Press Y if both sets are valid English words. Press N if one or both is not a word.</p>'+
'<p>Press Y to continue.</p>',
timeline.push(instructions);
type: 'html-keyboard-response',
stimulus: '<p>In this case you would press N</p>'+
'<div class="fixation"><p class="top">FOOB</p><p class="bottom">ARTIST</p></div>'+
'<p>Press N to continue to the start of the experiment.</p>',
timeline.push(instructions_2);
{word_1: 'SOCKS', word_2: 'SHOE', both_words: true, related: true},
{word_1: 'SLOW', word_2: 'FAST', both_words: true, related: true},
{word_1: 'QUEEN', word_2: 'KING', both_words: true, related: true},
{word_1: 'LEAF', word_2: 'TREE', both_words: true, related: true},
{word_1: 'SOCKS', word_2: 'TREE', both_words: true, related: false},
{word_1: 'SLOW', word_2: 'SHOE', both_words: true, related: false},
{word_1: 'QUEEN', word_2: 'FAST', both_words: true, related: false},
{word_1: 'LEAF', word_2: 'KING', both_words: true, related: false},
{word_1: 'AGAIN', word_2: 'PLAW', both_words: false, related: false},
{word_1: 'BOARD', word_2: 'TRUDE', both_words: false, related: false},
{word_1: 'LIBE', word_2: 'HAIR', both_words: false, related: false},
{word_1: 'MOCKET', word_2: 'MEET', both_words: false, related: false},
{word_1: 'FLAFF', word_2: 'PLAW', both_words: false, related: false},
{word_1: 'BALT', word_2: 'TRUDE', both_words: false, related: false},
{word_1: 'LIBE', word_2: 'NUNE', both_words: false, related: false},
{word_1: 'MOCKET', word_2: 'FULLOW', both_words: false, related: false}
var lexical_decision_procedure = {
type: 'html-keyboard-response',
stimulus: '<div class="fixation"></div>',
choices: jsPsych.NO_KEYS,
type: 'html-keyboard-response',
return '<div class="fixation"><p class="top">'+jsPsych.timelineVariable('word_1', true)+'</p><p class="bottom">'+jsPsych.timelineVariable('word_2', true)+'</p></div>';
both_words: jsPsych.timelineVariable('both_words'),
related: jsPsych.timelineVariable('related')
on_finish: function(data){
var char_resp = jsPsych.pluginAPI.convertKeyCodeToKeyCharacter(data.key_press);
data.correct = char_resp == 'y';
data.correct = char_resp == 'n';
type: 'html-keyboard-response',
var last_correct = jsPsych.data.get().last(1).values()[0].correct;
return '<div class="fixation correct"></div>';
return '<div class="fixation incorrect"></div>';
choices: jsPsych.NO_KEYS,
timeline_variables: trials,
timeline.push(lexical_decision_procedure);
type: 'html-keyboard-response',
var mean_rt_related = jsPsych.data.get().filter({related:true, both_words:true, correct: true}).select('rt').mean();
var mean_rt_unrelated = jsPsych.data.get().filter({related:false, both_words:true, correct: true}).select('rt').mean();
return '<p>Average response time for related words: '+Math.round(mean_rt_related)+'ms</p>'+
'<p>Average response time for unrelated words: '+Math.round(mean_rt_unrelated)+'ms</p>'
timeline.push(data_summary);