Skip to content

Commit 1113f6a

Browse files
committed
Merge pull request #421 from IanEisenberg/util_rewrite
changed experiments beginning with a, s, t, v, and w so they work wit…
2 parents bd2ed14 + b2063de commit 1113f6a

File tree

42 files changed

+136
-398
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+136
-398
lines changed

adaptive_n_back/config.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"static/js/jspsych/poldrack_plugins/jspsych-poldrack-single-stim.js",
1414
"static/js/jspsych/plugins/jspsych-survey-text.js",
1515
"static/js/jspsych/plugins/jspsych-call-function.js",
16+
"static/js/utils/poldrack_utils.js",
1617
"experiment.js",
1718
"static/css/jspsych.css",
1819
"static/css/default_style.css",
@@ -38,7 +39,7 @@
3839
"deployment_variables":{"jspsych_init":
3940
{"fullscreen": true,
4041
"display_element": "getDisplayElement",
41-
"on_trial_finish": "addID()"}
42+
"on_trial_finish": "addID('adaptive_n_back')"}
4243
}
4344
}
4445
]

adaptive_n_back/experiment.js

+2-12
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
/* ************************************ */
22
/* Define helper functions */
33
/* ************************************ */
4-
function getDisplayElement() {
5-
$('<div class = display_stage_background></div>').appendTo('body')
6-
return $('<div class = display_stage></div>').appendTo('body')
7-
}
8-
94
function evalAttentionChecks() {
105
var check_percent = 1
116
if (run_attention_checks) {
@@ -21,12 +16,6 @@ function evalAttentionChecks() {
2116
return check_percent
2217
}
2318

24-
function addID() {
25-
jsPsych.data.addDataToLastTrial({
26-
'exp_id': 'adaptive_n_back'
27-
})
28-
}
29-
3019
function assessPerformance() {
3120
/* Function to calculate the "credit_var", which is a boolean used to
3221
credit individual experiments in expfactory. */
@@ -265,7 +254,8 @@ var end_block = {
265254
text: '<div class = "centerbox"><p class = "center-block-text">Thanks for completing this task!</p><p class = center-block-text>Press <strong>enter</strong> to begin.</p></div>',
266255
cont_key: [13],
267256
data: {
268-
trial_id: "text"
257+
trial_id: "text",
258+
exp_id: 'adaptive_n_back'
269259
},
270260
timing_response: 180000,
271261
timing_post_trial: 0,

angling_risk_task/config.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"static/js/jspsych/plugins/jspsych-call-function.js",
1313
"static/js/jspsych/plugins/jspsych-survey-text.js",
1414
"static/js/jspsych/poldrack_plugins/jspsych-single-stim-button.js",
15+
"static/js/utils/poldrack_utils.js",
1516
"experiment.js",
1617
"static/css/jspsych.css",
1718
"static/css/default_style.css",
@@ -44,7 +45,7 @@
4445
"deployment_variables":{"jspsych_init":
4546
{"fullscreen": true,
4647
"display_element": "getDisplayElement",
47-
"on_trial_finish": "addID()"}
48+
"on_trial_finish": "addID('angling_risk_task')"}
4849
}
4950

5051
}

angling_risk_task/experiment.js

+19-38
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
/* ************************************ */
55
/* Define helper functions */
66
/* ************************************ */
7-
function getDisplayElement() {
8-
$('<div class = display_stage_background></div>').appendTo('body')
9-
return $('<div class = display_stage></div>').appendTo('body')
10-
}
11-
127
function evalAttentionChecks() {
138
var check_percent = 1
149
if (run_attention_checks) {
@@ -24,12 +19,6 @@ function evalAttentionChecks() {
2419
return check_percent
2520
}
2621

27-
function addID() {
28-
jsPsych.data.addDataToLastTrial({
29-
exp_id: 'angling_risk_task'
30-
})
31-
}
32-
3322
function assessPerformance() {
3423
var experiment_data = jsPsych.data.getTrialsOfType('single-stim-button')
3524
var missed_count = 0
@@ -324,29 +313,6 @@ function place_fish() {
324313
}
325314
}
326315

327-
var changeData = function() {
328-
data = jsPsych.data.getTrialsOfType('poldrack-text')
329-
practiceDataCount = 0
330-
testDataCount = 0
331-
for (i = 0; i < data.length; i++) {
332-
if (data[i].trial_id == 'practice_intro') {
333-
practiceDataCount = practiceDataCount + 1
334-
} else if (data[i].trial_id == 'test_intro') {
335-
testDataCount = testDataCount + 1
336-
}
337-
}
338-
if (practiceDataCount >= 1 && testDataCount === 0) {
339-
//temp_id = data[i].trial_id
340-
jsPsych.data.addDataToLastTrial({
341-
exp_stage: "practice"
342-
})
343-
} else if (practiceDataCount >= 1 && testDataCount >= 1) {
344-
//temp_id = data[i].trial_id
345-
jsPsych.data.addDataToLastTrial({
346-
exp_stage: "test"
347-
})
348-
}
349-
}
350316

351317
/* ************************************ */
352318
/* Define experimental variables */
@@ -382,6 +348,7 @@ var blocks = [{
382348
weather: "Cloudy",
383349
release: "Keep"
384350
}]
351+
var exp_stage = 'practice'
385352
var practiceblocks = jsPsych.randomization.shuffle(blocks)
386353
var blocks = jsPsych.randomization.shuffle(blocks)
387354
var pay = 1 //payment for one red fish
@@ -517,7 +484,8 @@ var end_block = {
517484
text: '<div class = centerbox><p class = center-block-text>Thanks for completing this task!</p><p class = center-block-text>Press <strong>enter</strong> to begin.</p></div>',
518485
cont_key: [13],
519486
data: {
520-
trial_id: "end_block"
487+
trial_id: "end_block",
488+
exp_id: 'angling_risk_task'
521489
},
522490
timing_response: 180000,
523491
timing_post_trial: 0,
@@ -533,12 +501,20 @@ var round_over_block = {
533501
trial_id: "round_over"
534502
},
535503
timing_post_trial: 0,
536-
on_finish: changeData,
504+
on_finish: function() {
505+
jsPsych.data.addDataToLastTrial({
506+
exp_stage: exp_stage
507+
})
508+
},
537509
};
538510

539511
var ask_fish_block = {
540512
type: 'survey-text',
541-
on_finish: changeData,
513+
on_finish: function() {
514+
jsPsych.data.addDataToLastTrial({
515+
exp_stage: exp_stage
516+
})
517+
},
542518
data: {
543519
trial_id: "ask fish"
544520
},
@@ -551,7 +527,11 @@ var ask_fish_block = {
551527

552528
var set_fish_block = {
553529
type: 'call-function',
554-
on_finish: changeData,
530+
on_finish: function() {
531+
jsPsych.data.addDataToLastTrial({
532+
exp_stage: exp_stage
533+
})
534+
},
555535
data: {
556536
trial_id: "set_fish"
557537
},
@@ -626,6 +606,7 @@ var start_test_block = {
626606
timing_post_trial: 1000,
627607
on_finish: function() {
628608
tournament_bank = 0
609+
exp_stage = 'test'
629610
}
630611
};
631612

angling_risk_task_always_sunny/config.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"static/js/jspsych/plugins/jspsych-call-function.js",
1313
"static/js/jspsych/plugins/jspsych-survey-text.js",
1414
"static/js/jspsych/poldrack_plugins/jspsych-single-stim-button.js",
15+
"static/js/utils/poldrack_utils.js",
1516
"experiment.js",
1617
"static/css/jspsych.css",
1718
"static/css/default_style.css",
@@ -44,7 +45,7 @@
4445
"deployment_variables":{"jspsych_init":
4546
{"fullscreen": true,
4647
"display_element": "getDisplayElement",
47-
"on_trial_finish": "addID()"}
48+
"on_trial_finish": "addID('angling_risk_task_always_sunny')"}
4849
}
4950

5051
}

angling_risk_task_always_sunny/experiment.js

+19-38
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
/* ************************************ */
55
/* Define helper functions */
66
/* ************************************ */
7-
function getDisplayElement() {
8-
$('<div class = display_stage_background></div>').appendTo('body')
9-
return $('<div class = display_stage></div>').appendTo('body')
10-
}
11-
127
function evalAttentionChecks() {
138
var check_percent = 1
149
if (run_attention_checks) {
@@ -24,12 +19,6 @@ function evalAttentionChecks() {
2419
return check_percent
2520
}
2621

27-
function addID() {
28-
jsPsych.data.addDataToLastTrial({
29-
exp_id: 'angling_risk_task_always_sunny'
30-
})
31-
}
32-
3322
function assessPerformance() {
3423
var experiment_data = jsPsych.data.getTrialsOfType('single-stim-button')
3524
var missed_count = 0
@@ -324,29 +313,6 @@ function place_fish() {
324313
}
325314
}
326315

327-
var changeData = function() {
328-
data = jsPsych.data.getTrialsOfType('poldrack-text')
329-
practiceDataCount = 0
330-
testDataCount = 0
331-
for (i = 0; i < data.length; i++) {
332-
if (data[i].trial_id == 'practice_intro') {
333-
practiceDataCount = practiceDataCount + 1
334-
} else if (data[i].trial_id == 'test_intro') {
335-
testDataCount = testDataCount + 1
336-
}
337-
}
338-
if (practiceDataCount >= 1 && testDataCount === 0) {
339-
//temp_id = data[i].trial_id
340-
jsPsych.data.addDataToLastTrial({
341-
exp_stage: "practice"
342-
})
343-
} else if (practiceDataCount >= 1 && testDataCount >= 1) {
344-
//temp_id = data[i].trial_id
345-
jsPsych.data.addDataToLastTrial({
346-
exp_stage: "test"
347-
})
348-
}
349-
}
350316

351317
/* ************************************ */
352318
/* Define experimental variables */
@@ -360,6 +326,7 @@ var credit_var = true
360326
var performance_var = 0
361327

362328
// task specific variables
329+
var exp_stage = 'practice'
363330
var num_practice_rounds = 2
364331
var num_rounds = 20
365332
var red_fish_num = 0
@@ -511,7 +478,8 @@ var end_block = {
511478
text: '<div class = centerbox><p class = center-block-text>Thanks for completing this task!</p><p class = center-block-text>Press <strong>enter</strong> to begin.</p></div>',
512479
cont_key: [13],
513480
data: {
514-
trial_id: "end_block"
481+
trial_id: "end_block",
482+
exp_id: 'angling_risk_task_always_sunny'
515483
},
516484
timing_response: 180000,
517485
timing_post_trial: 0,
@@ -527,12 +495,20 @@ var round_over_block = {
527495
trial_id: "round_over"
528496
},
529497
timing_post_trial: 0,
530-
on_finish: changeData,
498+
on_finish: function() {
499+
jsPsych.data.addDataToLastTrial({
500+
exp_stage: exp_stage
501+
})
502+
}
531503
};
532504

533505
var ask_fish_block = {
534506
type: 'survey-text',
535-
on_finish: changeData,
507+
on_finish: function() {
508+
jsPsych.data.addDataToLastTrial({
509+
exp_stage: exp_stage
510+
})
511+
},
536512
data: {
537513
trial_id: "ask fish"
538514
},
@@ -545,7 +521,11 @@ var ask_fish_block = {
545521

546522
var set_fish_block = {
547523
type: 'call-function',
548-
on_finish: changeData,
524+
on_finish: function() {
525+
jsPsych.data.addDataToLastTrial({
526+
exp_stage: exp_stage
527+
})
528+
},
549529
data: {
550530
trial_id: "set_fish"
551531
},
@@ -620,6 +600,7 @@ var start_test_block = {
620600
timing_post_trial: 1000,
621601
on_finish: function() {
622602
tournament_bank = 0
603+
exp_stage = 'test'
623604
}
624605
};
625606

antisaccade/config.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"static/js/jspsych/poldrack_plugins/jspsych-attention-check.js",
1111
"static/js/jspsych/poldrack_plugins/jspsych-poldrack-single-stim.js",
1212
"static/js/jspsych/plugins/jspsych-survey-text.js",
13+
"static/js/utils/poldrack_utils.js",
1314
"experiment.js",
1415
"static/css/jspsych.css",
1516
"static/css/default_style.css",
@@ -31,7 +32,7 @@
3132
"deployment_variables":{"jspsych_init":
3233
{"fullscreen": true,
3334
"display_element": "getDisplayElement",
34-
"on_trial_finish": "addID()"}
35+
"on_trial_finish": "addID('antisaccade')"}
3536
}
3637
}
3738
]

antisaccade/experiment.js

+2-12
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
/* ************************************ */
22
/* Define helper functions */
33
/* ************************************ */
4-
function getDisplayElement() {
5-
$('<div class = display_stage_background></div>').appendTo('body')
6-
return $('<div class = display_stage></div>').appendTo('body')
7-
}
8-
94
function evalAttentionChecks() {
105
var check_percent = 1
116
if (run_attention_checks) {
@@ -21,12 +16,6 @@ function evalAttentionChecks() {
2116
return check_percent
2217
}
2318

24-
function addID() {
25-
jsPsych.data.addDataToLastTrial({
26-
'exp_id': 'antisaccade'
27-
})
28-
}
29-
3019
var getInstructFeedback = function() {
3120
return '<div class = centerbox><p class = center-block-text>' + feedback_instruct_text +
3221
'</p></div>'
@@ -142,7 +131,8 @@ var post_task_block = {
142131
var end_block = {
143132
type: 'poldrack-text',
144133
data: {
145-
trial_id: "end"
134+
trial_id: "end",
135+
exp_id: 'antisaccade'
146136
},
147137
text: '<div class = centerbox><p class = center-block-text>Thanks for completing this task!</p><p class = center-block-text>Press <strong>enter</strong> to continue.</p></div>',
148138
cont_key: [13],

attention_network_task/config.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"static/js/jspsych/poldrack_plugins/jspsych-poldrack-single-stim.js",
1313
"static/js/jspsych/poldrack_plugins/jspsych-poldrack-categorize.js",
1414
"static/js/jspsych/plugins/jspsych-survey-text.js",
15+
"static/js/utils/poldrack_utils.js",
1516
"experiment.js",
1617
"static/css/jspsych.css",
1718
"static/css/default_style.css",
@@ -38,7 +39,7 @@
3839
"deployment_variables":{"jspsych_init":
3940
{"fullscreen": true,
4041
"display_element": "getDisplayElement",
41-
"on_trial_finish": "addID()"}
42+
"on_trial_finish": "addID('attention_network_task')"}
4243
}
4344
}
4445
]

0 commit comments

Comments
 (0)