Skip to content

Commit 78d84b6

Browse files
authored
Merge pull request #578 from jkl071/master
stop signal with gng
2 parents 7e84a42 + 7b24e3d commit 78d84b6

File tree

1 file changed

+28
-25
lines changed

1 file changed

+28
-25
lines changed

stop_signal_with_go_no_go/experiment.js

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -131,22 +131,22 @@ var getCategorizeFeedback = function(){
131131
return '<div class = fb_box><div class = center-text><font size = 20>There was a star + Shape was '+go_no_go_styles[1]+'.</font></div></div>' + prompt_text
132132
}
133133

134-
} else if ((trial_id == 'practice_trial') && (jsPsych.data.getDataByTrialIndex(curr_trial).stop_signal_condition == 'stop')){
134+
} else if ((trial_id == 'practice_trial') && (jsPsych.data.getDataByTrialIndex(curr_trial).stop_signal_condition == 'stop') && (jsPsych.data.getDataByTrialIndex(curr_trial).go_nogo_condition == 'go')){
135135

136136
if (jsPsych.data.getDataByTrialIndex(curr_trial).rt == -1){
137137
return '<div class = fb_box><div class = center-text><font size = 20>Correct!</font></div></div>' + prompt_text
138138
} else if (jsPsych.data.getDataByTrialIndex(curr_trial).rt != -1){
139139
return '<div class = fb_box><div class = center-text><font size = 20>There was a star.</font></div></div>' + prompt_text
140140
}
141141

142-
} else if ((trial_id == 'practice_trial') && (jsPsych.data.getDataByTrialIndex(curr_trial).go_nogo_condition == 'nogo')){
142+
} else if ((trial_id == 'practice_trial') && (jsPsych.data.getDataByTrialIndex(curr_trial).go_nogo_condition == 'nogo') && (jsPsych.data.getDataByTrialIndex(curr_trial).stop_signal_condition == 'go')){
143143

144144
if (jsPsych.data.getDataByTrialIndex(curr_trial).rt == -1){
145145
return '<div class = fb_box><div class = center-text><font size = 20>Correct!</font></div></div>' + prompt_text
146146
} else if (jsPsych.data.getDataByTrialIndex(curr_trial).rt != -1){
147147
return '<div class = fb_box><div class = center-text><font size = 20>Shape was '+go_no_go_styles[1]+'</font></div></div>' + prompt_text
148148
}
149-
} else if ((trial_id == 'practice_trial') && ((jsPsych.data.getDataByTrialIndex(curr_trial).stop_signal_condition == 'go') && (jsPsych.data.getDataByTrialIndex(curr_trial).go_nogo_condition == 'go'))){
149+
} else if ((trial_id == 'practice_trial') && (jsPsych.data.getDataByTrialIndex(curr_trial).stop_signal_condition == 'go') && (jsPsych.data.getDataByTrialIndex(curr_trial).go_nogo_condition == 'go')){
150150

151151
if (jsPsych.data.getDataByTrialIndex(curr_trial).key_press == jsPsych.data.getDataByTrialIndex(curr_trial).correct_response){
152152
return '<div class = fb_box><div class = center-text><font size = 20>Correct!</font></div></div>' + prompt_text
@@ -156,7 +156,9 @@ var getCategorizeFeedback = function(){
156156
return '<div class = fb_box><div class = center-text><font size = 20>Incorrect</font></div></div>' + prompt_text
157157
}
158158

159-
} else if ((trial_id == 'practice_trial') && (jsPsych.data.getDataByTrialIndex(curr_trial).go_nogo_condition == 'go')){
159+
}
160+
/*
161+
else if ((trial_id == 'practice_trial') && (jsPsych.data.getDataByTrialIndex(curr_trial).go_nogo_condition == 'go')){
160162
161163
if (jsPsych.data.getDataByTrialIndex(curr_trial).key_press == jsPsych.data.getDataByTrialIndex(curr_trial).correct_response){
162164
return '<div class = fb_box><div class = center-text><font size = 20>Correct!</font></div></div>' + prompt_text
@@ -177,18 +179,19 @@ var getCategorizeFeedback = function(){
177179
}
178180
179181
}
182+
*/
180183
}
181184

182185
var createTrialTypes = function(numTrialsPerBlock){
183-
var unique_combos = 60
186+
var unique_combos = 30
184187

185188
var stims = []
186189
for (var j = 0; j < totalShapesUsed; j++){
187190
for (var i = 0; i < go_no_go_types.length; i++){
188191
for (var x = 0; x < stop_signal_conditions.length; x++){
189192
stim = {
190-
stim: shapes[j],
191-
correct_response: possible_responses[j][1],
193+
stim: shapes[j][0],
194+
correct_response: possible_responses[j][0][1],
192195
stop_signal_condition: stop_signal_conditions[x],
193196
go_no_go_type: go_no_go_types[i]
194197

@@ -334,9 +337,9 @@ var instructTimeThresh = 0 ///in seconds
334337
var credit_var = 0
335338
var run_attention_checks = true
336339

337-
var practice_len = 15 // 15 must be divisible by 60
338-
var exp_len = 300 //300 must be divisible by 60
339-
var numTrialsPerBlock = 60 // 60, must be divisible by 60
340+
var practice_len = 30 // 30 must be divisible by 30
341+
var exp_len = 300 //300 must be divisible by 30
342+
var numTrialsPerBlock = 60 // 60, must be divisible by 30
340343
var numTestBlocks = exp_len / numTrialsPerBlock
341344
var practice_thresh = 3 // 3 blocks of 16 trials
342345

@@ -361,13 +364,13 @@ var stop_signal_respond_upper_thresh_practice = 1
361364
var stop_signal_conditions = ['go','go','stop']
362365
var go_no_go_types = ['go','go','go','go','nogo']
363366
var go_no_go_styles = ['solid','outlined'] //has dashed as well
364-
var shapes = jsPsych.randomization.repeat(['circle','circle','square','square'],1)
367+
var shapes = jsPsych.randomization.repeat([['circle','circle'],['square','square']],1)
365368
//'hourglass', 'Lshape', 'moon', 'oval', 'rectangle', 'rhombus', 'tear', 'trapezoid'
366369
var color = "black"
367-
var totalShapesUsed = 4
370+
var totalShapesUsed = 2
368371

369372

370-
var possible_responses = [['Z key', 90], ['Z key', 90], ['M key', 77], ['M key', 77]]
373+
var possible_responses = [[['Z key', 90], ['Z key', 90]], [['M key', 77], ['M key', 77]]]
371374

372375

373376
var postFileType = "'></img>"
@@ -390,15 +393,15 @@ jsPsych.pluginAPI.preloadImages(images);
390393

391394

392395
var prompt_text_list = '<ul list-text>'+
393-
'<li>' + shapes[0] + ': ' + possible_responses[0][0] + '</li>' +
394-
'<li>' + shapes[2] + ': ' + possible_responses[2][0] + '</li>' +
396+
'<li>' + shapes[0][0] + ': ' + possible_responses[0][0][0] + '</li>' +
397+
'<li>' + shapes[1][0] + ': ' + possible_responses[1][0][0] + '</li>' +
395398
'<li>Do not respond if a star appears!</li>' +
396399
'<li>Do not respond if the shape is '+go_no_go_styles[1]+'!</li>' +
397400
'</ul>'
398401

399402
var prompt_text = '<div class = prompt_box>'+
400-
'<p class = center-block-text style = "font-size:16px; line-height:80%%;">' + shapes[0] + ': ' + possible_responses[0][0] + '</p>' +
401-
'<p class = center-block-text style = "font-size:16px; line-height:80%%;">' + shapes[2] + ': ' + possible_responses[2][0] + '</p>' +
403+
'<p class = center-block-text style = "font-size:16px; line-height:80%%;">' + shapes[0][0] + ': ' + possible_responses[0][0][0] + '</p>' +
404+
'<p class = center-block-text style = "font-size:16px; line-height:80%%;">' + shapes[1][0] + ': ' + possible_responses[1][0][0] + '</p>' +
402405
'<p class = center-block-text style = "font-size:16px; line-height:80%%;">Do not respond if a star appears!</p>' +
403406
'<p class = center-block-text style = "font-size:16px; line-height:80%%;">Do not respond if the shape is '+go_no_go_styles[1]+'!</p>' +
404407
'</div>'
@@ -488,8 +491,8 @@ var instructions_block = {
488491
'<div class = centerbox>'+
489492
'<p class = block-text>In this task you will see shapes appear on the screen one at a time. </p>' +
490493
'<p class = block-text>Only one response is correct for each shape.</p>'+
491-
'<p class = block-text>If the shape is a '+shapes[0]+', press the '+possible_responses[0][0]+'.</p>'+
492-
'<p class = block-text>If the shape is a '+shapes[2]+', press the '+possible_responses[2][0]+'.</p>'+
494+
'<p class = block-text>If the shape is a '+shapes[0][0]+', press the '+possible_responses[0][0][0]+'.</p>'+
495+
'<p class = block-text>If the shape is a '+shapes[1][0]+', press the '+possible_responses[1][0][0]+'.</p>'+
493496
'<p class = block-text>You should respond as quickly and accurately as possible to each shape.</p>'+
494497
'</div>',
495498

@@ -570,7 +573,7 @@ var prompt_fixation_block = {
570573

571574
var practice_intro = {
572575
type: 'poldrack-single-stim',
573-
stimulus: '<div class = centerbox><p class = block-text>We will now start the practice for the experiment.<br><br>For these trials, you must press the <i>'+possible_responses[0][0]+'</i>, '+ ' or <i>'+possible_responses[2][0]+ ' </i>depending on the shape of the stimulus. Make sure to respond as quickly and accurately as possible to the shape. <br><br> The responses for each shape are as follows: ' +
576+
stimulus: '<div class = centerbox><p class = block-text>We will now start the practice for the experiment.<br><br>For these trials, you must press the <i>'+possible_responses[0][0][0]+'</i>, '+ ' or <i>'+possible_responses[1][0][0]+ ' </i>depending on the shape of the stimulus. Make sure to respond as quickly and accurately as possible to the shape. <br><br> The responses for each shape are as follows: ' +
574577
prompt_text +
575578
'</p><p class = block-text>Remember these rules before you proceed.</p><p class = block-text>Press <i> enter</i> to begin.</p></div>',
576579
is_html: true,
@@ -588,8 +591,8 @@ var test_intro = {
588591
stimulus: '<div class = centerbox>'+
589592
'<p class = block-text>We will now begin the test portion.</p>'+
590593
'<p class = block-text>You will see a shape on every trial. Please respond to each shape as quickly and accurately as possible!</p>'+
591-
'<p class = block-text>If the shape is a '+shapes[0]+' or a '+shapes[1]+', press the '+possible_responses[0][0]+'.</p>'+
592-
'<p class = block-text>If the shape is a '+shapes[2]+' or a '+shapes[3]+', press the '+possible_responses[2][0]+'.</p>'+
594+
'<p class = block-text>If the shape is a '+shapes[0][0]+', press the '+possible_responses[0][0][0]+'.</p>'+
595+
'<p class = block-text>If the shape is a '+shapes[1][0]+', press the '+possible_responses[1][0][0]+'.</p>'+
593596
'<p class = block-text>Do not respond if you see a star</p>'+
594597
'<p class = block-text>Do not respond if the shape is '+go_no_go_styles[1]+'</p>'+
595598
'<p class = block-text>You will no longer receive the rule prompt, so remember the instructions before you continue. Press Enter to begin.</p>'+
@@ -654,7 +657,7 @@ for (i = 0; i < practice_len; i++) {
654657
trial_id: "practice_trial"
655658
},
656659
is_html: true,
657-
choices: [possible_responses[0][1], possible_responses[2][1]],
660+
choices: [possible_responses[0][1][1], possible_responses[1][1][1]],
658661
timing_stim: 1000,
659662
timing_response: 2000, //2000
660663
response_ends_trial: false,
@@ -720,7 +723,7 @@ var practiceStopNode = {
720723
var gng_stop_no_respond = 0
721724

722725
for (i = 0; i < data.length; i++) {
723-
if (data[i].trial_id == "test_trial"){
726+
if (data[i].trial_id == "practice_trial"){
724727
total_trials += 1
725728
if ((data[i].stop_signal_condition == "go") && (data[i].go_nogo_condition == "go")){
726729
SS_gng_go_trials += 1
@@ -838,7 +841,7 @@ for (i = 0; i < numTrialsPerBlock; i++) {
838841
trial_id: "test_trial"
839842
},
840843
is_html: true,
841-
choices: [possible_responses[0][1], possible_responses[2][1]],
844+
choices: [possible_responses[0][1][1], possible_responses[1][1][1]],
842845
timing_stim: 1000,
843846
timing_response: 2000, //2000
844847
response_ends_trial: false,

0 commit comments

Comments
 (0)