Skip to content

Commit 9289e81

Browse files
author
frankafan
committed
Changes.
1 parent 3bb5007 commit 9289e81

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

libraries/utils.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ function ezddm(prop_correct, rt_correct_variance_s, rt_correct_mean_s, n_trials)
137137
return { boundary: a, drift: v, nondecisiontime: ndt };
138138
}
139139

140-
function generate_html(text, color = 'black', size = 20, location = [0, 0], bold = false, border_color = 'white') {
141-
var div = "<p><div style='font-size:" + size + "px;color:" + color + ";transform: translate(" + location[0] + "px," + location[1] + "px);'>" + text + "</div></p>";
140+
function generate_html(text, color = 'black', size = 20, transform = [0, 0], bold = false, border_color = 'white') {
141+
var div = "<p><div style='font-size:" + size + "px;color:" + color + ";transform: translate(" + transform[0] + "px," + transform[1] + "px);'>" + text + "</div></p>";
142142
if (bold) {
143143
return "<b>" + div + "</b>";
144144
} else {

studies/efforttrain/task.js

+12-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ var debug = true;
77
const instruct_fontsize = 21;
88
const rocket_selection_deadline = null; // ms
99
const cue_duration = 1500;
10-
const feedback_duration = 1500;
1110

1211
var rnorm = new Ziggurat(); // rnorm.nextGaussian() * 5 to generate random normal variable with mean 0 sd 5
1312
var itis = iti_exponential(200, 700); // intervals between dot-motion reps
@@ -23,8 +22,9 @@ const num_majority = 300;
2322
var dot_motion_parameters;
2423

2524
// training block parameters
26-
const num_reward_trials = 40;
27-
const num_probe_trials = 20;
25+
const num_reward_trials = 4;
26+
const num_probe_trials = 2;
27+
const feedback_duration = 1500;
2828

2929
// colours used for task, with left and right randomized for each experiment
3030
// TODO orange and red might be too similar?!? (green/blue too??)
@@ -150,7 +150,6 @@ var rocket_chosen = {
150150

151151

152152
var pre_training_rt = [];
153-
var training_rt = [];
154153
var training_points = [];
155154
var is_pre_training;
156155
var is_training;
@@ -188,7 +187,6 @@ var dot_motion = {
188187
console.log('Pre-training rt added:', data.rt);
189188
}
190189
} else if (is_training) {
191-
training_rt.push(data.rt);
192190
training_points.push(calculate_points(data.rt, points));
193191
if (debug) {
194192
console.log('Training rt added:', data.rt);
@@ -198,12 +196,16 @@ var dot_motion = {
198196
console.log('Your answer is correct');
199197
}
200198
} else {
199+
if (is_training) {
200+
training_points.push(0);
201+
}
201202
if (debug) {
202203
console.log('Your answer is incorrect')
203204
}
204205
// TODO push to global variable and save to data 0 points
205206
}
206207
data.congruent = dot_motion_parameters.congruent;
208+
data.points = training_points[training_points.length - 1];
207209
},
208210
post_trial_gap: function () { return random_choice(itis) }
209211
}
@@ -310,11 +312,12 @@ var training_timeline_variables = get_training_timeline_variables(num_reward_tri
310312

311313
var feedback = {
312314
type: "html-keyboard-response",
315+
choices: [],
316+
trial_duration: feedback_duration,
313317
stimulus: function () {
314318
if (training_timeline_variables[training_index].trial_type == 'reward') {
315-
return sum(training_points.slice(training_points.length - 3)).toString()
316-
} else if (training_timeline_variables[training_index].trial_type == 'probe') {
317-
return '0'
319+
let point_scored = mean(training_points.slice(training_points.length - 3)) + rnorm.nextGaussian() * 5;
320+
return generate_html(Math.round(point_scored), font_colour, 89, [0, -200]);
318321
} else {
319322
return ''
320323
}
@@ -326,6 +329,7 @@ var feedback = {
326329
on_finish: function (data) {
327330
document.body.style.backgroundImage = '';
328331
data.cue_type = training_timeline_variables[training_index].trial_type;
332+
data.mean_points = mean(training_points.slice(training_points.length - 3));
329333
training_index++;
330334
},
331335
}

0 commit comments

Comments
 (0)