-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path04_trials.js
135 lines (127 loc) · 4.11 KB
/
04_trials.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
//Rotation of conditions (key press to circle/square)
const key_targets = _.shuffle(['circle', 'square']);
const p_target = key_targets[0];
const q_target = key_targets[1];
console.log("The shape for key P is " + p_target);
// text for general instructions
const instructions_p_is_circle = "<strong>Whenever you see a <b>square</b>, please press the 'q' key </strong> on your keyboard, <strong>whenever you see a <b>cirlce</b>, please press the 'p' key</strong> - regardless of the position of the shape.";
const instructions_p_is_square = "<strong>Whenever you see a <b>circle</b>, please press the 'q' key </strong> on your keyboard, <strong>whenever you see a <b>square</b>, please press the 'p' key</strong> - regardless of the position of the shape.";
const key_press_instruction_message = p_target == 'circle' ?
instructions_p_is_circle :
instructions_p_is_square;
// text for short (recap) instructions
const short_instructions_p_is_circle = "Remember that <strong>'q'</strong> is for <strong>square</strong>, and <strong>'p'</strong> is for <strong>circle</strong>.";
const short_instructions_p_is_square = "Remember that <strong>'q'</strong> is for <strong>circle</strong>, and <strong>'p'</strong> is for <strong>square</strong>.";
const key_press_instruction_message_short = p_target == 'circle' ?
short_instructions_p_is_circle :
short_instructions_p_is_square;
//Error feedback if participants exceeds the time for responding, and hides stimulus
const count_time = function (data, next) {
if (typeof window.timeout === 'undefined') {
window.timeout = [];
}
// add the timeout to the timeoutarray
window.timeout.push(setTimeout(function () {
$(".magpie-view-stimulus")
.addClass("magpie-invisible");
}, 500));
window.timeout.push(setTimeout(function () {
$('#reminder')
.text('Please answer more quickly!');
}, 3000));
next();
};
// all 2x2 major conditions
const conditions = [
{ // target: circle, position: left
key1: 'q',
key2: 'p',
q: q_target,
p: p_target,
target_object: "circle",
target_position: "left",
condition: q_target == "circle" ? 'congruent' : 'incongruent',
canvas: {
focalColor: 'blue',
focalShape: 'circle',
focalNumber: 1,
elemSize: 100,
total: 2,
start_with: 'focal',
otherShape: 'square',
otherColor: 'white',
sort: 'split_grid'
}
},
{ // target: circle, position: right
key1: 'q',
key2: 'p',
q: q_target,
p: p_target,
target_object: "circle",
target_position: "right",
condition: q_target == "circle" ? 'incongruent' : 'congruent',
canvas: {
focalColor: 'blue',
focalShape: 'circle',
focalNumber: 1,
elemSize: 100,
total: 2,
start_with: 'other',
otherShape: 'square',
otherColor: 'white',
sort: 'split_grid'
}
},
{ // target: square, position: left
key1: 'q',
key2: 'p',
q: q_target,
p: p_target,
target_object: "square",
target_position: "left",
condition: q_target == "square" ? 'congruent' : 'incongruent',
canvas: {
focalColor: 'blue',
focalShape: 'square',
focalNumber: 1,
elemSize: 100,
total: 2,
start_with: 'focal',
otherShape: 'circle',
otherColor: 'white',
sort: 'split_grid'
}
},
{ // target: square, position: right
key1: 'q',
key2: 'p',
q: q_target,
p: p_target,
target_object: "square",
target_position: "right",
condition: q_target == "square" ? 'incongruent' : 'congruent',
canvas: {
focalColor: 'blue',
focalShape: 'square',
focalNumber: 1,
elemSize: 100,
total: 2,
start_with: 'other',
otherShape: 'circle',
otherColor: 'white',
sort: 'split_grid'
}
}
];
// const nr_trials_practice = 2;
// const nr_trials_test = 2;
const nr_trials_practice = 20;
const nr_trials_test = 100;
create_n_trials = function (nr_trials) {
return _.map(_.range(nr_trials), function () {
return _.sample(conditions);
});
}
trial_info_practice = create_n_trials(nr_trials_practice);
trial_info_test = create_n_trials(nr_trials_test);