-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
88 lines (82 loc) · 2.88 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<script src="jspsych/jspsych.js"></script>
<script src="jspsych/plugins/jspsych-html-keyboard-response.js"></script>
<link href="jspsych/css/jspsych.css" rel="stylesheet">
</head>
<body></body>
<script>
var timeline = [];
var welcome = {
type: 'html-keyboard-response',
stimulus: '<p>Welcome. When you are ready to begin, press C to continue.</p>',
choices: ['C'],
on_start: function(){
jsPsych.hardware.netstation.connect();
},
on_finish: async function(){
await jsPsych.hardware.netstation.beginSession();
await jsPsych.hardware.netstation.sync();
await jsPsych.hardware.netstation.beginRecording();
}
}
timeline.push(welcome);
var trials = [
{stimulus: '<p style="font-size:28px;">< < < < <</p>', correct_response: 'F', code: 'CONL'},
{stimulus: '<p style="font-size:28px;">> > > > ></p>', correct_response: 'J', code: 'CONR'},
{stimulus: '<p style="font-size:28px;">> > < > ></p>', correct_response: 'F', code: 'INCL'},
{stimulus: '<p style="font-size:28px;">< < > < <</p>', correct_response: 'J', code: 'INCR'}
]
var last_onset = null;
var test_procedure = {
timeline: [
{
type: 'html-keyboard-response',
stimulus: '<p style="font-size:28px;">+</p>',
choices: jsPsych.NO_KEYS,
trial_duration: 500
},
{
type: 'html-keyboard-response',
stimulus: jsPsych.timelineVariable('stimulus'),
data: {
code: jsPsych.timelineVariable('code'),
correct_response: jsPsych.timelineVariable('correct_response')
},
on_load: function(){
last_onset = performance.now();
},
on_finish: function(data){
data.correct = data.key_press == jsPsych.pluginAPI.convertKeyCharacterToKeyCode(data.correct_response);
jsPsych.hardware.netstation.sendEvent({
key: data.code,
timestamp: last_onset,
table: {
correct: data.correct
}
});
}
}
],
timeline_variables: trials,
sample: {
type: 'with-replacement',
size: 4
}
}
timeline.push(test_procedure);
var end = {
type: 'html-keyboard-response',
stimulus: '<p>The end!</p>',
choices: jsPsych.NO_KEYS,
on_start: function(){
console.log(jsPsych.data.get().csv());
}
}
timeline.push(end);
jsPsych.init({
timeline: timeline
})
</script>
</html>