forked from jspsych/jsPsych
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlexical-decision.html
145 lines (130 loc) · 5.88 KB
/
lexical-decision.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<!DOCTYPE html>
<html>
<head>
<script src="../jspsych.js"></script>
<script src="../plugins/jspsych-html-keyboard-response.js"></script>
<link rel="stylesheet" href="../css/jspsych.css"></link>
<style>
.stimulus { font-size: 32px; }
</style>
</head>
<script>
var timeline = [];
var instructions = {
type: 'html-keyboard-response',
stimulus: '<p>Each screen will show either an English word or letters that do not form a word.</p>'+
'<p>Press Y if the letters form a valid word.</p><p>Press N if the letters do not form a valid word.</p>'+
'<p>When you are ready to begin, press Y or N.</p>',
choices: ['y','n']
}
timeline.push(instructions);
var stimuli = [
{word: 'woman', word_validity: 'valid', word_frequency: 'high'},
{word: 'title', word_validity: 'valid', word_frequency: 'high'},
{word: 'speed', word_validity: 'valid', word_frequency: 'high'},
{word: 'movie', word_validity: 'valid', word_frequency: 'high'},
{word: 'night', word_validity: 'valid', word_frequency: 'high'},
{word: 'house', word_validity: 'valid', word_frequency: 'high'},
{word: 'child', word_validity: 'valid', word_frequency: 'high'},
{word: 'apple', word_validity: 'valid', word_frequency: 'high'},
{word: 'books', word_validity: 'valid', word_frequency: 'high'},
{word: 'color', word_validity: 'valid', word_frequency: 'high'},
{word: 'whigs', word_validity: 'valid', word_frequency: 'low'},
{word: 'pecan', word_validity: 'valid', word_frequency: 'low'},
{word: 'hanky', word_validity: 'valid', word_frequency: 'low'},
{word: 'femur', word_validity: 'valid', word_frequency: 'low'},
{word: 'tusks', word_validity: 'valid', word_frequency: 'low'},
{word: 'tongs', word_validity: 'valid', word_frequency: 'low'},
{word: 'petal', word_validity: 'valid', word_frequency: 'low'},
{word: 'dunce', word_validity: 'valid', word_frequency: 'low'},
{word: 'friar', word_validity: 'valid', word_frequency: 'low'},
{word: 'gable', word_validity: 'valid', word_frequency: 'low'},
{word: 'womfn', word_validity: 'invalid', word_frequency: undefined},
{word: 'tgtle', word_validity: 'invalid', word_frequency: undefined},
{word: 'speqd', word_validity: 'invalid', word_frequency: undefined},
{word: 'movje', word_validity: 'invalid', word_frequency: undefined},
{word: 'npght', word_validity: 'invalid', word_frequency: undefined},
{word: 'hoxse', word_validity: 'invalid', word_frequency: undefined},
{word: 'chrld', word_validity: 'invalid', word_frequency: undefined},
{word: 'wpple', word_validity: 'invalid', word_frequency: undefined},
{word: 'boxks', word_validity: 'invalid', word_frequency: undefined},
{word: 'colwr', word_validity: 'invalid', word_frequency: undefined},
{word: 'whzgs', word_validity: 'invalid', word_frequency: undefined},
{word: 'pecjn', word_validity: 'invalid', word_frequency: undefined},
{word: 'hankk', word_validity: 'invalid', word_frequency: undefined},
{word: 'fembr', word_validity: 'invalid', word_frequency: undefined},
{word: 'tmsks', word_validity: 'invalid', word_frequency: undefined},
{word: 'tvngs', word_validity: 'invalid', word_frequency: undefined},
{word: 'pettl', word_validity: 'invalid', word_frequency: undefined},
{word: 'duncr', word_validity: 'invalid', word_frequency: undefined},
{word: 'friwr', word_validity: 'invalid', word_frequency: undefined},
{word: 'gabls', word_validity: 'invalid', word_frequency: undefined}
];
var trials = {
timeline_variables: stimuli,
randomize_order: true,
timeline: [
{
type: 'html-keyboard-response',
stimulus: '<p class="stimulus">+</p>',
choices: jsPsych.NO_KEYS,
trial_duration: 500,
post_trial_gap: 0
},
{
type: 'html-keyboard-response',
stimulus: function(){ return "<p class='stimulus'>"+jsPsych.timelineVariable('word', true)+"</p>"; },
choices: ['y','n'],
post_trial_gap: 500,
data: function(){
return {
word_validity: jsPsych.timelineVariable('word_validity'),
word_frequency: jsPsych.timelineVariable('word_frequency')
}
},
on_finish: function(data){
if(data.word_validity == 'valid'){
var correct = data.key_press == jsPsych.pluginAPI.convertKeyCharacterToKeyCode('y');
} else {
var correct = data.key_press == jsPsych.pluginAPI.convertKeyCharacterToKeyCode('n');
}
jsPsych.data.addDataToLastTrial({correct: correct});
}
}
]
}
timeline.push(trials);
var debrief = {
type: 'html-keyboard-response',
stimulus: function(){
var high_frequency = jsPsych.data.get({word_frequency: 'high', correct: true});
var low_frequency = jsPsych.data.get({word_frequency: 'low', correct: true});
var high_rt = 0;
for(var i=0; i<high_frequency.length; i++){
high_rt += high_frequency[i].rt;
}
high_rt = Math.round(high_rt / high_frequency.length);
var low_rt = 0;
for(var i=0; i<low_frequency.length; i++){
low_rt += low_frequency[i].rt;
}
low_rt = Math.round(low_rt / low_frequency.length);
var message = "<p>All done!</p>"+
"<p>Your average correct response time for high frequency English words was "+high_rt+"</p>"+
"<p>Your average correct response time for low frequency English words was "+low_rt+"</p>"+
"<p>The typical pattern of results is that people are faster to respond to high frequency (common) "+
"word than low frequency (uncommon) words.</p>"+
"<p>Press C to see the entire set of data generated by this experiment.</p>";
return message;
}
}
timeline.push(debrief);
jsPsych.init({
timeline: timeline,
on_finish: function() {
jsPsych.data.displayData();
},
default_iti: 250
});
</script>
</html>