-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_task.js
204 lines (189 loc) · 5.98 KB
/
main_task.js
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
/**
*
* trial for implementing repeated masked suppression
*
* Rapidly presenting mondrian rectangles as image either appears
* on left or right with increasingly levels of opacity. Fixation cross at the center.
*
*
* Built off of bRMS paradigm developed (Abir & Hassin, 2020).
*
* https://github.com/yanivabir/measuring_prioritization_experiment_code
* https://github.com/ConsciousLab/jsPsychRmsPlugin
*
**/
// Parameters
var ITI = 1000,
time_limit = 60 * (60 * 1000),
stimAlphas = [0.3, 0.9, 6],
unitSize = 8, //controls display size
repetitions = 20,
trialLength = 0, // 0 is no limit
fade_in_time = 1,
fade_out_time = 15,
fade_out_length = 5;
var images = ['/static/images/social1.png',
'/static/images/social2.png',
'/static/images/social3.png',
'/static/images/social4.png',
'/static/images/social5.jpg',
'/static/images/social6.jpg'
];
//Enter fullscreen//
var fullscreen = {
type: 'fullscreen',
fullscreen_mode: true,
message: '<p>This study runs in fullscreen. To switch to full screen mode,\
press the button below.</p>'
}
//** bRMS instructions *** https://git.io/JeFfi.//
var instruction_text = [{
stimulus: ["<p>We will now continue to the main task.</p>\
<p align='center'><i>Press the space bar to continue.</i></p>"],
choices: [32]
},
{
stimulus: ["<div class = 'center'><p>You will be presented with rapidly \
changing patterns of rectangles. Through these rectangles, scenes of \
social scenarios will appear. Your task will be to indicate the location of \
the scenes, or any part of them, as soon as they appear.</p >\
<p align='center'><i>Press the space bar to continue.</i></p></div > "],
choices: [32]
},
{
stimulus: ["<div class = 'center'><p>If the scene appeared in the right half \
of the screen, press the right key. If the scene appeared in the left half \
of the screen, press the left key.</p>\
<p align='center'><i>Press the space bar to continue.</i></p></div>"],
choices: [32]
},
{
stimulus: ["<div class = 'center'><p>Please perform this task as accurately \
and quickly as you can.</p>\
<p align='center'><i>Press the space bar to continue.</i></p></div>"],
choices: [32]
},
{
stimulus: ["<div class = 'center'><p>During the task, please focus your gaze at\
the plus sign in the middle.<br>Even though the scenes appear to the left\
and right of the plus sign, it is important that you look at the plus \
sign at all times.</p>\
<p align='center'></i>Press the space bar to continue.</i></p></div>"],
choices: [32]
},
{
stimulus: ["<div class='center'><p>Place your fingers on the 'D' and 'K' keys, \
and press either one of these keys to continue.</p></div>"],
choices: [68, 75]
}
];
var instructions = {
type: 'html-keyboard-response',
timeline: instruction_text,
timing_post_trial: 200
};
// Main block instructions//
var mainBlockText = [
{
stimulus: ["<div class = 'center'><p>During the task, please focus your gaze at\
the plus sign in the middle.<br>Even though the scenes appear to the left\
and right of the plus sign, it is important that you look at the plus \
sign at all times.</p>\
<p>Press either the 'D' or the 'K' keys to continue.</p></div>"],
choices: [68, 75]
}
]
var mainBlockIns = {
type: 'html-keyboard-response',
timeline: mainBlockText,
timing_post_trial: 200
}
//bRMS block//
// Make stimuli for bRMS https://git.io/JeFfi.
var stimuli = [];
for (a = Math.log10(stimAlphas[0]); a <= Math.log10(stimAlphas[1]); a += (Math.log10(stimAlphas[1]) - Math.log10(stimAlphas[0])) / (stimAlphas[2] - 1)) {
for (i = 1; i <= repetitions - 1; i++) {
stimuli.push({
type: "bRMS",
stimulus: '../static/images/social' + i + '.png',
data: {
stimulus: 'social' + i,
stimulus_type: 'normal',
timing_response: trialLength,
stimulus_alpha: Math.pow(10, a),
timing_post_trial: 100,
within_ITI: ITI - 100,
fade_in_time: fade_in_time,
fade_out_time: fade_out_time,
fade_out_length: fade_out_length
},
stimulus_alpha: Math.pow(10, a),
timing_post_trial: 100,
within_ITI: ITI - 100,
timing_response: trialLength,
fade_in_time: fade_in_time,
fade_out_time: fade_out_time,
fade_out_length: fade_out_length
});
stimuli.push({
type: "bRMS",
stimulus: '../static/images/social' + i + '.png',
data: {
stimulus: "social" + i,
stimulus_type: 'normal',
timing_response: trialLength,
stimulus_alpha: Math.pow(10, a),
timing_post_trial: 100,
within_ITI: ITI - 100,
fade_in_time: fade_in_time,
fade_out_time: fade_out_time,
fade_out_length: fade_out_length
},
stimulus_alpha: Math.pow(10, a),
timing_post_trial: 100,
within_ITI: ITI - 100,
timing_response: trialLength,
fade_in_time: fade_in_time,
fade_out_time: fade_out_time,
fade_out_length: fade_out_length
});
}
}
//shuffle order of stimuli//
var stimuli = jsPsych.randomization.shuffle(stimuli);
//define BRMS experiment block//
var bRMS_block = {
timeline: stimuli,
visUnit: function () {
return unitSize
},
on_finish: function () {
var current_date = new Date();
if ((current_date.getTime() - exp_start_time) > time_limit) {
jsPsych.endCurrentTimeline();
}
}
};
// Organize blocks in timeline
var experiment_blocks = [];
experiment_blocks.push(fullscreen);
experiment_blocks.push(instructions);
experiment_blocks.push(mainBlockIns);
experiment_blocks.push(bRMS_block);
// Initiate experiment
var exp_start_time = 0;
var current_date = new Date();
jsPsych.init({
timeline: experiment_blocks,
fullscreen: true,
on_finish: function () {
jsPsych.data.getInteractionData().json();
},
preload_images: images,
on_trial_start: function () {
// Record start time of bRMS block
if (exp_start_time == 0 && jsPsych.currentTrial().type == 'bRMS') {
exp_start_time = current_date.getTime();
}
}
});