Skip to content

Commit f7ffa80

Browse files
author
Thanh Tung Bui
committed
Two major changes: 1) Commendably well-earned fixes to all go_no-go tasks to ensure an exact 6go:1no-go ratio; 2) CTI to start at 350 for shape_matching_with_cued_task_switch.
1 parent 152837c commit f7ffa80

File tree

9 files changed

+145
-100
lines changed

9 files changed

+145
-100
lines changed

go_nogo_single_task_network/experiment.js

Lines changed: 67 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,14 @@ var appendData = function(data) {
107107
trial_num: current_trial,
108108
})
109109

110-
current_trial = current_trial + 1
110+
current_trial +=1
111111
}
112112

113113
var getFeedback = function() {
114114
if (stim.key_answer == -1) {
115115
return '<div class = centerbox><div class = center-text>Correct!</div></div>' + prompt_text_list
116116
} else {
117-
return '<div class = centerbox><div class = center-text>Incorrect</div></p></div>' + prompt_text_list
117+
return '<div class = centerbox><div class = center-text>The shape was outlined</div></p></div>' + prompt_text_list
118118
}
119119
}
120120

@@ -166,23 +166,64 @@ var correct_responses = [
166166
var stims = [["solid", "stim1"],["outlined","stim2"]] //solid and outlined squares used as stimuli for this task are not png files as in some others, but they are defined in style.css
167167
var gap = 0
168168
var current_trial = 0
169-
var practice_stimuli = [{ //each {} consists of stimulus, data, and key_answer
170-
stimulus: '<div class = bigbox><div class = centerbox><div class = gng_number><div class = cue-text><div id = ' + stims[0][1] + '></div></div></div></div></div>',
171-
data: {
172-
correct_response: correct_responses[0][1],
173-
go_nogo_condition: correct_responses[0][0],
174-
trial_id: 'practice_trial'
175-
},
176-
key_answer: correct_responses[0][1]
177-
}, {
169+
var practice_stimuli = [{ //To change go:nogo ratio, add or remove one or more sub-dictionaries within practice_stimuli and test_stimuli_block
178170
stimulus: '<div class = bigbox><div class = centerbox><div class = gng_number><div class = cue-text><div id = ' + stims[1][1] + '></div></div></div></div></div>',
179171
data: {
180172
correct_response: correct_responses[1][1],
181173
go_nogo_condition: correct_responses[1][0],
182174
trial_id: 'practice_trial'
183175
},
184176
key_answer: correct_responses[1][1]
185-
}];
177+
}, {
178+
stimulus: '<div class = bigbox><div class = centerbox><div class = gng_number><div class = cue-text><div id = ' + stims[0][1] + '></div></div></div></div></div>',
179+
data: {
180+
correct_response: correct_responses[0][1],
181+
go_nogo_condition: correct_responses[0][0],
182+
trial_id: 'practice_trial'
183+
},
184+
key_answer: correct_responses[0][1]
185+
}, {
186+
stimulus: '<div class = bigbox><div class = centerbox><div class = gng_number><div class = cue-text><div id = ' + stims[0][1] + '></div></div></div></div></div>',
187+
data: {
188+
correct_response: correct_responses[0][1],
189+
go_nogo_condition: correct_responses[0][0],
190+
trial_id: 'practice_trial'
191+
},
192+
key_answer: correct_responses[0][1]
193+
}, {
194+
stimulus: '<div class = bigbox><div class = centerbox><div class = gng_number><div class = cue-text><div id = ' + stims[0][1] + '></div></div></div></div></div>',
195+
data: {
196+
correct_response: correct_responses[0][1],
197+
go_nogo_condition: correct_responses[0][0],
198+
trial_id: 'practice_trial'
199+
},
200+
key_answer: correct_responses[0][1]
201+
}, {
202+
stimulus: '<div class = bigbox><div class = centerbox><div class = gng_number><div class = cue-text><div id = ' + stims[0][1] + '></div></div></div></div></div>',
203+
data: {
204+
correct_response: correct_responses[0][1],
205+
go_nogo_condition: correct_responses[0][0],
206+
trial_id: 'practice_trial'
207+
},
208+
key_answer: correct_responses[0][1]
209+
}, {
210+
stimulus: '<div class = bigbox><div class = centerbox><div class = gng_number><div class = cue-text><div id = ' + stims[0][1] + '></div></div></div></div></div>',
211+
data: {
212+
correct_response: correct_responses[0][1],
213+
go_nogo_condition: correct_responses[0][0],
214+
trial_id: 'practice_trial'
215+
},
216+
key_answer: correct_responses[0][1]
217+
}, {
218+
stimulus: '<div class = bigbox><div class = centerbox><div class = gng_number><div class = cue-text><div id = ' + stims[0][1] + '></div></div></div></div></div>',
219+
data: {
220+
correct_response: correct_responses[0][1],
221+
go_nogo_condition: correct_responses[0][0],
222+
trial_id: 'practice_trial'
223+
},
224+
key_answer: correct_responses[0][1]
225+
}
226+
];
186227

187228

188229
//set up block stim. test_stim_responses indexed by [block][stim][type]
@@ -242,14 +283,14 @@ var accuracy_thresh = 0.75
242283
var rt_thresh = 1000
243284
var missed_thresh = 0.10
244285

245-
var practice_length = 14
246-
var practice_thresh = 3 // 3 blocks of 10 trials
286+
var practice_len = 28
287+
var practice_thresh = 3
247288

248-
var test_length = 245 //keeping # of no_go trials at 50 -> new ratio 6:1 makes total of 350 trials
249-
var numTrialsPerBlock = 49 // must be divisible by 5 (7/31: new ratio go:nogo is 6:1 -> divisible by 7)
250-
var numTestBlocks = test_length / numTrialsPerBlock
289+
var exp_len = 245 //multiple of numTrialsPerBlock
290+
var numTrialsPerBlock = 49 // multiple of 7 (6go:1nogo)
291+
var numTestBlocks = exp_len / numTrialsPerBlock
251292

252-
var block_stims = jsPsych.randomization.repeat(practice_stimuli, practice_length / 2);
293+
var block_stims = jsPsych.randomization.repeat(practice_stimuli, practice_len / practice_stimuli.length);
253294

254295

255296

@@ -438,7 +479,7 @@ var prompt_fixation_block = {
438479
var practiceTrials = []
439480
practiceTrials.push(feedback_block)
440481
practiceTrials.push(instructions_block)
441-
for (var i = 0; i < practice_length; i ++){
482+
for (var i = 0; i < practice_len; i ++){
442483

443484
var practice_block = {
444485
type: 'poldrack-categorize',
@@ -447,7 +488,7 @@ for (var i = 0; i < practice_length; i ++){
447488
data: getData,
448489
key_answer: getCorrectResponse,
449490
correct_text: '<div class = centerbox><div class = center-text>Correct!</div></div>',
450-
incorrect_text: '<div class = centerbox><div class = center-text>Incorrect</div></div>',
491+
incorrect_text: '<div class = centerbox><div class = center-text>The shape was outlined</div></div>',
451492
timeout_message: getFeedback,
452493
choices: [32],
453494
timing_response: 2000, //2000
@@ -468,8 +509,8 @@ var practiceNode = {
468509
timeline: practiceTrials,
469510
loop_function: function(data){
470511
practiceCount += 1
471-
practice_index = 0
472-
block_stims = jsPsych.randomization.repeat(practice_stimuli, practice_length / 2);
512+
current_trial = 0
513+
block_stims = jsPsych.randomization.repeat(practice_stimuli, practice_len / practice_stimuli.length);
473514

474515
var sum_rt = 0
475516
var sum_responses = 0
@@ -510,7 +551,7 @@ var practiceNode = {
510551
if (accuracy > accuracy_thresh){
511552
feedback_text +=
512553
'</p><p class = block-text>Done with this practice. Press Enter to continue.'
513-
block_stims = jsPsych.randomization.repeat(test_stimuli_block, numTrialsPerBlock / 7);
554+
block_stims = jsPsych.randomization.repeat(test_stimuli_block, numTrialsPerBlock / test_stimuli_block.length);
514555
return false
515556

516557
} else if (accuracy < accuracy_thresh){
@@ -530,7 +571,7 @@ var practiceNode = {
530571
if (practiceCount == practice_thresh){
531572
feedback_text +=
532573
'</p><p class = block-text>Done with this practice.'
533-
block_stims = jsPsych.randomization.repeat(test_stimuli_block, numTrialsPerBlock / 7);
574+
block_stims = jsPsych.randomization.repeat(test_stimuli_block, numTrialsPerBlock / test_stimuli_block.length);
534575
return false
535576
}
536577

@@ -573,7 +614,7 @@ var testNode = {
573614
timeline: testTrials,
574615
loop_function: function(data){
575616
testCount += 1
576-
test_index = 0
617+
current_trial = 0
577618

578619
var sum_rt = 0
579620
var sum_responses = 0
@@ -637,7 +678,7 @@ var testNode = {
637678

638679
feedback_text +=
639680
'</p><p class = block-text>Press Enter to continue.'
640-
block_stims = jsPsych.randomization.repeat(test_stimuli_block, numTrialsPerBlock / 7);
681+
block_stims = jsPsych.randomization.repeat(test_stimuli_block, numTrialsPerBlock / test_stimuli_block.length);
641682
return true
642683

643684
}

go_nogo_with_cued_task_switching/experiment.js

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -351,15 +351,14 @@ var accuracy_thresh = 0.75
351351
var rt_thresh = 1000
352352
var missed_thresh = 0.10
353353
var practice_thresh = 3
354-
var lowestNumCond = 20
355354

356355
// task specific variables
357356
var response_keys = {key: [77,90], key_name: ["M","Z"]}
358357
var choices = response_keys.key
359-
var practice_length = 28
360-
var test_length = 560 /*a multiple of 77*/
358+
var practice_len = 56
359+
var exp_len = 560 /*a multiple of 77*/
361360
var numTrialsPerBlock = 112 /*7/31: So that it'll be a multiple of the new 6:1 ratio of go:nogo trials*/
362-
var numTestBlocks = test_length / numTrialsPerBlock
361+
var numTestBlocks = exp_len / numTrialsPerBlock
363362
var CTI = 150
364363

365364
var go_no_go_styles = ['solid','outlined']
@@ -398,12 +397,18 @@ for (var t = 0; t < task_switch_types.length; t++) {
398397
}
399398
}
400399
}
401-
var task_switches = jsPsych.randomization.repeat(task_switches_arr, practice_length / lowestNumCond)
402-
task_switches.unshift({task_switch: 'na', cue_switch: 'na', go_no_go_type: jsPsych.randomization.repeat(["go","go","go","go","go","go","nogo"],1).pop()})
403-
var practiceStims = genStims(practice_length + 1)
404-
var testStims = genStims(numTrialsPerBlock + 1)
405-
var stims = practiceStims
406-
var curr_task = randomDraw(getKeys(tasks))
400+
var task_switches = jsPsych.randomization.repeat(task_switches_arr, practice_len / (task_switch_types.length*cue_switch_types.length*go_no_go_types.length))
401+
task_switches.unshift( //.unshift(): add to the beginning of an array
402+
{
403+
task_switch: 'na',
404+
cue_switch: 'na',
405+
go_no_go_type: jsPsych.randomization.repeat(["go","go","go","go","go","go","nogo"],1).pop() //.pop() removes the last element of an array, and returns that element. Note: This method changes the length of an array.
406+
}
407+
)
408+
var practiceStims = genStims(practice_len +1)
409+
var testStims = genStims(numTrialsPerBlock +1)
410+
var stims = practiceStims //genStims returns stims, so stims = practiceStims makes some sense.
411+
var curr_task = randomDraw(getKeys(tasks)) //tasks is in line 368, a dict containing 2 dicts, which are two tasks each containing 2 cues.
407412
var last_task = 'na' //object that holds the last task, set by setStims()
408413
var curr_cue = 'na' //object that holds the current cue, set by setStims()
409414
var cue_i = randomDraw([0, 1]) //index for one of two cues of the current task
@@ -427,8 +432,8 @@ var pathSource = "/static/experiments/go_nogo_with_cued_task_switching/images/"
427432
var numbersPreload = ['1','2','3','4','5','6','7','8','9','10']
428433
var images = []
429434

430-
for(i=0;i<numbersPreload.length;i++){
431-
for(x=0;x<go_no_go_styles.length;x++){
435+
for(var i=0;i<numbersPreload.length;i++){
436+
for(var x=0;x<go_no_go_styles.length;x++){ //go_no_go_styles is solid or outlined
432437
images.push(pathSource + go_no_go_styles[x] + '_' + numbersPreload[i] + '.png')
433438
}
434439
}
@@ -573,7 +578,7 @@ var start_test_block = {
573578
on_finish: function() {
574579
current_trial = 0
575580
stims = testStims
576-
task_switches = jsPsych.randomization.repeat(task_switches_arr, numTrialsPerBlock / lowestNumCond)
581+
task_switches = jsPsych.randomization.repeat(task_switches_arr, numTrialsPerBlock / (task_switch_types.length*cue_switch_types.length*go_no_go_types.length))
577582
task_switches.unshift({task_switch: 'na', cue_switch: 'na', go_no_go_type: jsPsych.randomization.repeat(["go","go","go","go","go","go","nogo"],1).pop()})
578583
feedback_text = 'Starting a test block. Press enter to continue.'
579584
},
@@ -663,7 +668,7 @@ var test_block = {
663668
var practiceTrials = []
664669
practiceTrials.push(feedback_block)
665670
practiceTrials.push(instructions_block)
666-
for (var i = 0; i < practice_length + 1; i++) {
671+
for (var i = 0; i < practice_len + 1; i++) {
667672
var practice_fixation_block = {
668673
type: 'poldrack-single-stim',
669674
stimulus: '<div class = upperbox><div class = fixation>+</div></div>'+
@@ -714,9 +719,9 @@ var practiceNode = {
714719
timeline: practiceTrials,
715720
loop_function: function(data) {
716721
practiceCount += 1
717-
task_switches = jsPsych.randomization.repeat(task_switches_arr, practice_length / lowestNumCond)
722+
task_switches = jsPsych.randomization.repeat(task_switches_arr, practice_len / (task_switch_types.length*cue_switch_types.length*go_no_go_types.length))
718723
task_switches.unshift({task_switch: 'na', cue_switch: 'na', go_no_go_type: jsPsych.randomization.repeat(["go","go","go","go","go","go","nogo"],1).pop()})
719-
practiceStims = genStims(practice_length + 1)
724+
practiceStims = genStims(practice_len + 1)
720725
current_trial = 0
721726

722727
var sum_rt = 0
@@ -761,7 +766,7 @@ var practiceNode = {
761766
feedback_text +=
762767
'</p><p class = block-text>Done with this practice. Press Enter to continue.'
763768
testStims = genStims(numTrialsPerBlock + 1)
764-
task_switches = jsPsych.randomization.repeat(task_switches_arr, numTrialsPerBlock /lowestNumCond)
769+
task_switches = jsPsych.randomization.repeat(task_switches_arr, numTrialsPerBlock /(task_switch_types.length*cue_switch_types.length*go_no_go_types.length))
765770
task_switches.unshift({task_switch: 'na', cue_switch: 'na', go_no_go_type: jsPsych.randomization.repeat(["go","go","go","go","go","go","nogo"],1).pop()})
766771
return false
767772

@@ -781,7 +786,7 @@ var practiceNode = {
781786
feedback_text +=
782787
'</p><p class = block-text>Done with this practice.'
783788
testStims = genStims(numTrialsPerBlock + 1)
784-
task_switches = jsPsych.randomization.repeat(task_switches_arr, numTrialsPerBlock /lowestNumCond)
789+
task_switches = jsPsych.randomization.repeat(task_switches_arr, numTrialsPerBlock /(task_switch_types.length*cue_switch_types.length*go_no_go_types.length))
785790
task_switches.unshift({task_switch: 'na', cue_switch: 'na', go_no_go_type: jsPsych.randomization.repeat(["go","go","go","go","go","go","nogo"],1).pop()})
786791
return false
787792
}
@@ -799,7 +804,7 @@ var practiceNode = {
799804
var testTrials = []
800805
testTrials.push(feedback_block)
801806
testTrials.push(attention_node)
802-
for (var i = 0; i < numTrialsPerBlock + 1; i++) {
807+
for (var i = 0; i < numTrialsPerBlock; i++) {
803808
var fixation_block = {
804809
type: 'poldrack-single-stim',
805810
stimulus: '<div class = upperbox><div class = fixation>+</div></div>'+
@@ -848,9 +853,9 @@ var testNode = {
848853
timeline: testTrials,
849854
loop_function: function(data) {
850855
testCount += 1
851-
task_switches = jsPsych.randomization.repeat(task_switches_arr, numTrialsPerBlock / lowestNumCond)
856+
task_switches = jsPsych.randomization.repeat(task_switches_arr, numTrialsPerBlock / (task_switch_types.length*cue_switch_types.length*go_no_go_types.length))
852857
task_switches.unshift({task_switch: 'na', cue_switch: 'na', go_no_go_type: jsPsych.randomization.repeat(["go","go","go","go","go","go","nogo"],1).pop()})
853-
testStims = genStims(numTrialsPerBlock + 1)
858+
testStims = genStims(numTrialsPerBlock)
854859
current_trial = 0
855860

856861
var sum_rt = 0

go_nogo_with_directed_forgetting/experiment.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ var randomDraw = function(lst) {
161161
var createTrialTypes = function(numTrialsPerBlock){
162162

163163
var stims = []
164-
for(var numIterations = 0; numIterations < numTrialsPerBlock/20; numIterations++){
164+
for(var numIterations = 0; numIterations < numTrialsPerBlock/(go_nogo_conditions.length*directed_cond_array.length); numIterations++){
165165
for (var numDirectedConds = 0; numDirectedConds < directed_cond_array.length; numDirectedConds++){
166166
for (var numgo_nogoConds = 0; numgo_nogoConds < go_nogo_conditions.length; numgo_nogoConds++){
167167

@@ -299,8 +299,8 @@ var getResponse = function() {
299299

300300

301301
var appendData = function(){
302-
curr_trial = jsPsych.progress().current_trial_global
303-
trial_id = jsPsych.data.getDataByTrialIndex(curr_trial).trial_id
302+
var curr_trial = jsPsych.progress().current_trial_global
303+
var trial_id = jsPsych.data.getDataByTrialIndex(curr_trial).trial_id
304304

305305
if (trial_id == 'practice_trial'){
306306
current_block = practiceCount
@@ -312,7 +312,7 @@ var appendData = function(){
312312

313313
var lastSet_top = letters.slice(0,numLetters/2)
314314
var lastSet_bottom = letters.slice(numLetters/2)
315-
315+
316316
jsPsych.data.addDataToLastTrial({
317317
go_nogo_condition: go_nogo_condition,
318318
directed_forgetting_condition: directed_condition,
@@ -324,7 +324,6 @@ var appendData = function(){
324324
current_block: current_block,
325325
top_stim: lastSet_top,
326326
bottom_stim: lastSet_bottom
327-
328327
})
329328

330329
if (jsPsych.data.getDataByTrialIndex(curr_trial).key_press == correct_response){
@@ -399,7 +398,7 @@ var numLetters = 4
399398

400399
var directed_cond_array = ['pos', 'pos', 'neg', 'con']
401400
var directed_cue_array = ['TOP','BOT']
402-
var go_nogo_conditions = ['go','go','go','go','go','go','nogo']
401+
var go_nogo_conditions = ['go','go','go','go','go','go','nogo'] //To change go:nogo ratio, modify this AND also the denominator in numIterations < numTrialsPerBlock/... within var createTrialTypes = function(numTrialsPerBlock)
403402
var go_no_go_styles = ['solid','outlined'] //has dashed as well
404403
var fileTypePNG = ".png"
405404
var preFileType = "<img class = center src='"

go_nogo_with_flanker/experiment.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ var randomDraw = function(lst) {
128128
var createTrialTypes = function(numTrialsPerBlock){
129129

130130
var stims = []
131-
for(var numIterations = 0; numIterations < numTrialsPerBlock/20; numIterations++){
131+
for(var numIterations = 0; numIterations < numTrialsPerBlock/(go_nogo_trial_types.length*flanker_trial_types.length); numIterations++){ // 28 = 7 go_nogo_trial_types * 4 flanker_trial_types
132132
for (var numFlankerConds = 0; numFlankerConds < flanker_trial_types.length; numFlankerConds++){
133133
for (var numgo_nogoConds = 0; numgo_nogoConds < go_nogo_trial_types.length; numgo_nogoConds++){
134134

@@ -273,7 +273,7 @@ var missed_thresh = 0.10
273273
var practice_thresh = 3 // 3 blocks of 20 trials
274274

275275
var possible_responses = [['F key', 70],['H key', 72]]
276-
var go_nogo_trial_types = ['go','go','go','go','go','go','nogo']
276+
var go_nogo_trial_types = ['go','go','go','go','go','go','nogo'] //To change go:nogo ratio, modify this
277277
var flanker_trial_types = ['H_congruent','H_incongruent','F_congruent','F_incongruent']
278278
var go_no_go_styles = ['solid','outlined'] //has dashed as well
279279

0 commit comments

Comments
 (0)