This repository has been archived by the owner on Apr 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmental-nav-session.mwel
431 lines (334 loc) · 11 KB
/
mental-nav-session.mwel
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
%include 'mental-nav-variables'
%include 'eye'
%include 'keyboard'
%include 'mental-nav-stim'
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////// Parameter update methods
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
%define update_trial_params_from_meta ()
run_python_string (get_trial_metaparameters())
trial_meta_id = py_trial_meta_id
start_stim_index = py_start_stim_index
end_stim_index = py_end_stim_index
options_bin = py_options_bin
options_pos = py_options_pos
trial_id = py_trial_id
stim_drift_direction = py_stim_drift_direction
option_0 = py_option_0
option_1 = py_option_1
%end
%define update_sequence_params_from_meta ()
run_python_string(get_seq_metaparameters())
n_stims = py_n_stims
stim_pos = py_stim_pos
stim_bin = py_stim_bin
stim_dist_cum = py_stim_dist_cum
n_conditions = n_stims * n_stims * 2
%end
var break_start_time = 0
%define show_message ()
break_start_time = next_frame_time ()
live_queue_stimulus (break_prompt)
update_display ()
%end
%define hide_message()
dequeue_stimulus(break_prompt)
update_display()
%end
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////// Transition macros
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
%define inc_seq_index ()
seq_index = seq_index + 1
%end
%define inc_trial_index ()
accept_selections (trial_index)
%end
%define inc_block_index ()
accept_selections (block_index)
%end
%define inc_n_trials ()
n_trials = n_trials + 1
n_trials_in_block = n_trials_in_block + 1
%end
//////////////////////////////////////////////////////////////
%define reset_trials ()
reset_selection (trial_index)
%end
%define reset_blocks ()
reset_selection (block_index)
%end
%define set_vars_new_seq ()
nsuccess = 0
nfailure = 0
nignore = 0
reset_blocks ()
update_sequence_params_from_meta ()
set_vars_new_block ()
%end
%define set_vars_new_block ()
reset_trials ()
n_trials_in_block = 0
%end
%define set_vars_new_trial ()
update_trial_params_from_meta ()
stim_drift_fixed = 0
selected = -1
choice = 0
feedback = 0
failure = 0
success = 0
ignore = 0
selected_0 = 0
selected_1 = 0
%end
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////// Boolean macros
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
% define block_complete = n_trials_in_block == n_conditions
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////// Selection variables
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
selection trial_index (
values = 0:1000
selection = sequential_ascending
advance_on_accept = YES
autoreset = YES
)
selection block_index (
values = 0:10
selection = sequential_ascending
advance_on_accept = YES
autoreset = YES
)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
protocol '1. Set subject ID = 1' {
subject_id = 1
}
protocol '2. Load sequence index' {
run_python_file('mental-nav_utils.py')
run_python_string(get_seq_index())
seq_index = py_seq_index
}
protocol '4. Save sequence index' {
run_python_string(set_seq_index())
}
protocol '3. Begin experiment' {
report ('***********BEGIN EXPERIMENT***********')
set_vars_new_seq ()
start_io_device (keyboard)
start_io_device (eye_tracker)
live_queue_stimulus (center_indicator)
live_queue_stimulus (center_indicator_fill)
for_each_stim {
list {
live_queue_stimulus (img_stims[stim_index])
live_queue_stimulus (mask_stims[stim_index])
}
}
for_each_seq_len {
list {
live_queue_stimulus (seq_len_stims[seq_len])
}
}
live_queue_stimulus (window_mask_left)
live_queue_stimulus (window_mask_right)
trial (nsamples = 1000) {
sync = 0
end_trial = 0
set_vars_new_trial ()
report ('***********BEGIN TRIAL id. $trial_id, no. $trial_index, BLOCK $block_index***********')
for_each_option_stim {
list {
live_queue_stimulus(option_stims[option_stim_index])
}
}
display_option_selectors()
task {
state 'Begin fixation' {
report ('*********BEGIN FIXATION**********')
fixation = 1
queue_stimulus (fixation_point)
update_display ()
wait (1s)
simulate_fixation ()
goto (
target = 'Pre drift'
when = eye_in_window and (not saccade)
)
}
state 'Pre drift' {
fixation = 0
pre_drift = 1
sync = 1
dequeue_stimulus (fixation_point)
update_display ()
wait (pre_drift_dur)
goto (
target = 'Begin drift'
)
}
state 'Begin drift' {
report ("*********BEGIN DRIFT**********")
pre_drift = 0
drift = 1
sync = 2
goto ('Drift transition')
}
state 'Drift transition' {
report ("***********DRIFT TRANSITION***********")
drift_pause = 0
drift_transition = 1
sync = 3
stim_drift_start_time = next_frame_time()
goto (
target = 'Drift pause'
when = abs(stim_drift_transition) >= (stim_drift_transition_end - margin)
)
}
state 'Drift pause' {
report ("***********DRIFT PAUSE***********")
stim_drift_fixed = stim_drift_fixed + stim_drift_transition
drift_transition = 0
drift_pause = 1
sync = 4
/*
if (rand_drift_pause_dur) {
drift_pause_dur = rand(0, 0.5) + 0.5
}
*/
wait (drift_pause_dur)
goto (
target = 'Post drift'
when = abs(stim_drift_fixed) >= (stim_drift_end - margin)
)
goto (
target = 'Drift transition'
)
}
state 'Post drift' {
report ("*********POST DRIFT**********")
alpha_multiplier_fixed = alpha_multiplier_drift
drift = 0
post_drift = 1
sync = 3
wait (post_drift_dur)
goto ('Pre choice')
}
state 'Pre choice' {
report ("*********PRE CHOICE**********")
post_drift = 0
pre_choice = 1
sync = 4
wait (pre_choice_dur)
goto ('Choice')
}
state 'Choice' {
report ("*********CHOICE**********")
pre_choice = 0
choice = 1
sync = 5
start_timer (
timer = choice_timer
duration = choice_dur
)
goto (
target = 'Selected 0'
when = (l_pressed)
)
goto (
target = 'Selected 1'
when = (a_pressed)
)
goto (
target = 'Ignore'
when = timer_expired(choice_timer)
)
}
state 'Selected 0' {
report ("************SELECTED 0************")
selected = stim_pos[option_0]
selected_1 = 0
selected_0 = 1
goto (
target = 'Success'
when = end_stim_index == selected
)
goto (
target = 'Failure'
when = end_stim_index != selected
)
}
state 'Selected 1' {
report ("************SELECTED 1************")
selected = stim_pos[option_1]
selected_1 = 1
selected_0 = 0
goto (
target = 'Success'
when = end_stim_index == selected
)
goto (
target = 'Failure'
when = end_stim_index != selected
)
}
state 'Success' {
report ("*********SUCCESS**********")
nsuccess = nsuccess + 1
nconsecsuccess = nconsecsuccess + 1
success = 1
choice = 0
feedback = 1
sync = 6
wait (feedback_dur)
goto ('End trial')
}
state 'Failure' {
report ("*********FAILURE**********")
failure = 1
nfailure = nfailure + 1
nconsecsuccess = 0
choice = 0
feedback = 1
sync = 6
wait (feedback_dur)
goto ('End trial')
}
state 'Ignore' {
ignore = 1
nignore = nignore + 1
nconsecsuccess = 0
choice = 0
feedback = 1
sync = 6
wait (feedback_dur)
goto ('End trial')
}
state 'End trial' {
report ('***********END TRIAL***********')
sync = 7
feedback = 0
end_trial = 1
inc_n_trials ()
inc_trial_index ()
if (block_complete) {
if ((nsuccess / n_conditions) < criterion) {
report ('remaining in sequence')
inc_block_index ()
set_vars_new_block ()
}
if ((nsuccess / n_conditions) >= criterion) {
report ('moving on to next sequence')
inc_seq_index ()
set_vars_new_seq ()
show_message ()
wait (break_dur)
hide_message ()
}
}
yield ()
}
}
}
}