default_background_color = 0,0,0; default_font_size = 50; active_buttons = 3; response_matching = simple_matching; button_codes = 1, 2, 3; write_codes = true; response_logging = log_active; pulse_width = 700; default_output_port = 1; response_port_output = false; no_logfile = false; ######################## # # # # #this is the SDL section # # # # ######################## begin; #center screen text {caption = " ";}fixtxt; text {caption = " ";}let1txt; text {caption = " ";}let2txt; text {caption = " ";}let3txt; text {caption = " ";}let4txt; text {caption = " ";}let5txt; text {caption = " ";}let6txt; text {caption = " ";}let7txt; text {caption = " ";}let8txt; text {caption = " ";}resptxt; text {caption = " ";}yesnotxt; text {caption = " ";}lefttxt; text {caption = " ";}righttxt; box {height = 3000; width = 100;}leftbox; box {height = 3000; width = 100;}rightbox; #startle only probes trial { trial_type = fixed; trial_duration = stimuli_length; stimulus_event{ picture{}startleonlypic; port_code = 0; }startleonlyevent; }startleonlytrial; #sets ITI trial { trial_type = fixed; trial_duration = stimuli_length; stimulus_event{ picture{}itipic; }itievent; #sets Fixation stimulus_event{ picture{}fixpic; }fixevent; #sets letter1 stimulus_event{ picture{}let1pic; port_code = 0; code = 1; }let1event; #sets letter2 stimulus_event{ picture{}let2pic; port_code = 0; }let2event; #sets letter3 stimulus_event{ picture{}let3pic; port_code = 0; }let3event; #sets letter4 stimulus_event{ picture{}let4pic; port_code = 0; }let4event; #sets letter5 stimulus_event{ picture{}let5pic; port_code = 0; }let5event; #sets letter6 stimulus_event{ picture{}let6pic; port_code = 0; }let6event; #sets letter7 stimulus_event{ picture{}let7pic; port_code = 0; }let7event; #sets letter8 stimulus_event{ picture{}let8pic; port_code = 0; }let8event; #sets maint stimulus_event{ picture{}maint1pic; port_code = 0; code = 2; }maint1event; #sets maint stimulus_event{ picture{}maint2pic; port_code = 0; #startle }maint2event; #sets resp stimulus_event{ picture{}resppic; port_code = 0; code = 3; }respevent; #sets ITIend stimulus_event{ picture{}ITIendpic; port_code = 0; }ITIendevent; #sets shock stimulus_event{ picture{}shockpic; port_code = 0; }shockevent; }wmtrial; ######################## # # # # #this is the PCL section # # # # ######################## begin_pcl; ######################## # # # # #this is where i define all of the variables for the experiment # # # # ######################## #constants######################################################################################################## int width = display_device.width(); int leftside = 0 - (width/2 - 49); int rightside = 0 + (width/2 - 40); int i = 1; array alphabetarray[27] = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", " "}; string fixstr; string let1str; string let2str; string let3str; string let4str; string let5str; string let6str; string let7str; string let8str; string respstr; string yesnostr; int startleonlywaittmint; int rand1int; int rand2int; int rand3int; int rand4int; int rand5int; int rand6int; int rand7int; int rand8int; int respindexmatchint = 0; int respindexmismatchint = 0; int resptargetbuttonint = 0; response_data last = response_manager.last_response_data(); #string subject = "000c1r1"; string subject = logfile.subject(); string subj = subject.substring(1, 3); string filename = subject.substring(1, 5); string CB = subject.substring(5, 1); string run = subject.substring(7, 1); output_file file = new output_file; file.open_append ( filename ); string threatcondstr; string loadstr; string newoldstr; string shockstr; string respbuttonstr; string respcorrstr; string respindexmatchstr; string respindexmismatchstr; int lastresponse; int resprtint; int run1int = 0; int run2int = 0; int run3int = 0; int run4int = 0; int rint = 0; int shocktrialint; string shocktrialstr; string shockstartletmstr; int shocktrialportint; int trialtotal = 26; int expstartint; int let1startint; int maint1startint; int respstartint; output_port parallel1 = output_port_manager.get_port( 1 ); array threatcondarray[trialtotal]; array loadstimarray[trialtotal]; array newoldarray[trialtotal]; array shockonarray[trialtotal]; array encodingdurarray[trialtotal]; array maintdurarray[trialtotal]; array itidurarray[trialtotal]; array startletmarray[trialtotal]; array shocktmarray[trialtotal]; array shocktrialarray[trialtotal]; array shockstartletmarray[trialtotal]; array respalphabetarray[8]; array sortalphabetarray[8]; array mainalphabetarray[8]; array respindexmatcharray[8]; int itieventdel; int itieventdur; int fixeventdel; int fixeventdur; int let1eventdel; int let1eventdur; int let2eventdel; int let2eventdur; int let3eventdel; int let3eventdur; int let4eventdel; int let4eventdur; int let5eventdel; int let5eventdur; int let6eventdel; int let6eventdur; int let7eventdel; int let7eventdur; int let8eventdel; int let8eventdur; int maint1eventdel; int maint1eventdur; int maint2eventdel; int maint2eventdur; int respeventdel; int respeventdur; int ITIendeventdel; int ITIendeventdur; int shockeventdel; int shockeventdur; int threatportint; int safeportint; int lowportint; int highportint; int manipportint; int startleonlyportint = 128; int startleportint; int shockint; int fmristartint; int shockstartleportint; int condportint; int let1portint; int let2portint; int let3portint; int let4portint; int let5portint; int let6portint; int let7portint; int let8portint; int maint1portint; int maint2portint; int respportint; int shockportint; ############################################################################### #counterbalancing######################################################################################################## if CB == "1" then run1int = 1; run2int = 2; run3int = 3; run4int = 4; elseif CB == "2" then run1int = 4; run2int = 3; run3int = 2; run4int = 1; else run1int = 0; run2int = 0; run3int = 0; run4int = 0; end; if run == "1" then rint = run1int; elseif run == "2" then rint = run2int; elseif run == "3" then rint = run3int; elseif run == "4" then rint = run4int; else rint = 0; end; ############################################################################### ######################## # # # # #this section is changed across experiments # # # # ######################## #things to edit######################################################################################################## #trial, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}; if rint == 1 then #trial, 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};, threatcondarray = {1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2}; loadstimarray = {2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2}; newoldarray = {1, 1, 1, 2, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 2, 1, 1, 2, 2, 2, 2, 1, 2, 1, 1, 2}; shockonarray = {1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2}; shockstartletmarray = {12, 12, 10, 12, 10, 10, 12, 12, 12, 10, 12, 10, 10, 12, 10, 12, 10, 10, 10, 12, 10, 10, 10, 12, 12, 12}; itidurarray = {5003, 4854, 4672, 4136, 4930, 5072, 5006, 4988, 4286, 5623, 4640, 4173, 5837, 5210, 5863, 5848, 4921, 5889, 4451, 5537, 4817, 5668, 4789, 4003, 5210, 4684}; encodingdurarray = {2957, 2088, 2499, 2360, 2486, 2257, 2718, 2096, 2586, 2383, 2746, 2263, 2849, 2081, 2333, 2968, 2284, 2143, 2789, 2698, 2055, 2319, 2644, 2168, 2575, 2538}; maintdurarray = {9004, 9974, 8706, 9488, 9087, 8235, 8636, 9010, 9434, 8092, 9878, 9380, 9036, 9050, 8755, 8092, 9579, 9206, 8875, 9895, 8261, 9182, 8463, 9901, 9159, 8303}; shocktmarray = {6036, 6084, 7123, 7016, 6497, 7436, 6640, 6906, 8694, 6902, 5736, 7184, 5278, 6659, 6049, 6092, 6216, 5762, 6885, 4870, 7867, 5831, 7104, 6928, 6056, 7475}; startletmarray = {5581, 4645, 3476, 7101, 3573, 6286, 3704, 5289, 5539, 3796, 6491, 8013, 3381, 7901, 7574, 6243, 3505, 4686, 3418, 3557, 5692, 6909, 5451, 3132, 6887, 6726}; elseif rint == 2 then #trial, 22, 21, 24, 20, 23, 19, 1, 3, 5, 6, 25, 2, 26, 4, 12, 10, 11, 7, 8, 9, 17, 13, 18, 16, 15, 14};, threatcondarray = {2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1}; loadstimarray = {3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}; newoldarray = {1, 2, 2, 1, 1, 2, 2, 1, 2, 2, 1, 2, 1, 2, 2, 1, 1, 2, 1, 2, 2, 2, 1, 1, 1, 1}; shockonarray = {2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1}; shockstartletmarray = {10, 12, 10, 12, 10, 12, 10, 12, 10, 10, 12, 12, 10, 10, 10, 10, 12, 12, 12, 10, 12, 12, 10, 12, 10, 12}; itidurarray = {4479, 4781, 5670, 5750, 5246, 5766, 5340, 4189, 4097, 4307, 5815, 5744, 5775, 4461, 5299, 5916, 5146, 5289, 5775, 4785, 4304, 4949, 5260, 4926, 4279, 4074}; encodingdurarray = {2072, 2966, 2032, 2653, 2410, 2275, 2666, 2635, 2867, 2528, 2749, 2481, 2302, 2952, 2363, 2754, 2159, 2422, 2987, 2084, 2539, 2036, 2284, 2747, 2851, 2094}; maintdurarray = {8975, 8713, 9356, 8715, 9290, 9982, 8129, 8575, 9962, 9859, 8749, 9077, 9788, 9113, 9787, 9589, 8879, 9259, 8625, 9468, 9592, 9243, 9324, 9911, 9946, 8418}; shocktmarray = {7474, 6540, 5942, 5882, 6054, 4977, 6865, 7601, 6074, 6306, 5687, 5698, 7135, 6474, 5551, 4741, 6816, 6030, 5613, 6663, 6565, 6772, 6132, 5416, 5924, 8414}; startletmarray = {6786, 6527, 4184, 3375, 4483, 7799, 4621, 5657, 3132, 3042, 6856, 3130, 6522, 5935, 6629, 4956, 4054, 7153, 6301, 6997, 3326, 6303, 4344, 5593, 5756, 3934}; elseif rint == 3 then #trial, 14, 18, 26, 13, 16, 15, 17, 24, 22, 21, 23, 20, 19, 3, 1, 25, 4, 6, 2, 5, 9, 11, 10, 8, 12, 7};, threatcondarray = {1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2}; loadstimarray = {3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3}; newoldarray = {1, 2, 1, 1, 2, 2, 2, 1, 2, 2, 2, 1, 1, 1, 2, 1, 2, 1, 2, 1, 1, 1, 2, 2, 2, 1}; shockonarray = {2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2}; shockstartletmarray = {12, 10, 12, 10, 10, 12, 10, 12, 10, 12, 10, 10, 12, 12, 12, 10, 12, 12, 10, 10, 10, 10, 12, 12, 10, 12}; itidurarray = {5735, 4944, 5024, 5362, 5921, 5519, 5811, 4285, 5601, 5482, 5455, 4663, 4680, 5552, 4773, 5093, 4768, 5252, 5981, 5616, 4143, 4046, 4698, 4693, 4418, 4489}; encodingdurarray = {2368, 2166, 2861, 2713, 2798, 2406, 2598, 2266, 2172, 2851, 2604, 2996, 2072, 2529, 2934, 2703, 2981, 2639, 2307, 2074, 2848, 2534, 2223, 2441, 2966, 2410}; maintdurarray = {8219, 8114, 8551, 8038, 9023, 8647, 9374, 8743, 8446, 9009, 9958, 9200, 9676, 9617, 8431, 9949, 8696, 9235, 8242, 8230, 8446, 8994, 8899, 9055, 8432, 8963}; shocktmarray = {6678, 7776, 6564, 6887, 5258, 6428, 5217, 7706, 8781, 5658, 4983, 6141, 6572, 5302, 6862, 5255, 6555, 5874, 6470, 7080, 7563, 7426, 7180, 6811, 7184, 7138}; startletmarray = {6506, 5697, 6232, 6360, 5477, 7411, 4008, 5910, 6828, 3739, 4278, 7817, 6522, 4990, 4613, 4112, 5593, 5000, 4872, 6300, 4373, 7109, 4520, 4702, 5963, 3991}; elseif rint == 4 then #trial, 5, 25, 3, 2, 4, 1, 6, 7, 8, 12, 9, 11, 10, 15, 16, 26, 13, 14, 17, 18, 22, 19, 20, 21, 23, 24};, threatcondarray = {2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1}; loadstimarray = {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}; newoldarray = {2, 1, 2, 1, 2, 1, 1, 1, 1, 2, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 1, 2, 2, 2}; shockonarray = {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2}; shockstartletmarray = {12, 10, 10, 12, 10, 12, 10, 12, 10, 10, 12, 12, 12, 10, 12, 10, 12, 10, 12, 10, 10, 12, 12, 10, 10, 12}; itidurarray = {5221, 4443, 4230, 5224, 4240, 4456, 5051, 4380, 5657, 5924, 4558, 4297, 4545, 5701, 5476, 5566, 5523, 4356, 5305, 4620, 4564, 5737, 5159, 5509, 5342, 5423}; encodingdurarray = {2541, 2312, 2993, 2981, 2558, 2135, 2899, 2052, 2500, 2647, 2151, 2173, 2602, 2288, 2014, 2880, 2847, 2261, 2775, 2379, 2200, 2801, 2445, 2186, 2975, 2045}; maintdurarray = {8918, 8005, 8808, 8514, 9948, 9922, 8808, 8994, 8966, 9610, 8940, 8454, 9721, 8311, 8500, 9469, 8038, 9730, 8356, 8848, 9949, 9195, 8323, 9233, 9308, 9806}; shocktmarray = {6320, 8240, 6969, 6281, 6254, 6487, 6242, 7574, 5877, 4819, 7351, 8076, 6132, 6700, 7010, 5085, 6592, 6653, 8564, 7153, 6287, 5267, 7073, 6072, 5375, 5726}; startletmarray = {4561, 3543, 4574, 3079, 7512, 5593, 3119, 4186, 5923, 3730, 4649, 3147, 4702, 6444, 3366, 7962, 4321, 4060, 4718, 3234, 5458, 4888, 5112, 7495, 3847, 6634}; else end; ############################################################################### ######################## # # # # #subroutines to determine the behavior of the exp # # # # ######################## #wait for fMRI trigger######################################################################################################## sub sub_wait_fMRI begin loop until fmristartint == 3 begin if (bool( response_manager.response_count() )) then response_data fmriresp = response_manager.last_response_data(); fmristartint = fmriresp.button(); expstartint = clock.time(); end; end; end; ######################################################################################################### #wait for fMRI trigger######################################################################################################## sub sub_startleonly begin startleonlyevent.set_port_code(startleonlyportint); startleonlywaittmint = clock.time() + random(15000, 17000); loop until clock.time() >= startleonlywaittmint begin end; startleonlytrial.present(); expstartint = clock.time(); end; ######################################################################################################### #timing######################################################################################################## sub sub_determine_timing begin itieventdel = 0; itieventdur = itidurarray[i] - 1000; fixeventdel = itieventdur; fixeventdur = 1000; let1eventdel = fixeventdur; let1eventdur = encodingdurarray[i]/8; let2eventdel = let1eventdur; let2eventdur = encodingdurarray[i]/8; let3eventdel = let2eventdur; let3eventdur = encodingdurarray[i]/8; let4eventdel = let3eventdur; let4eventdur = encodingdurarray[i]/8; let5eventdel = let4eventdur; let5eventdur = encodingdurarray[i]/8; let6eventdel = let5eventdur; let6eventdur = encodingdurarray[i]/8; let7eventdel = let6eventdur; let7eventdur = encodingdurarray[i]/8; let8eventdel = let7eventdur; let8eventdur = encodingdurarray[i]/8; maint1eventdel = let8eventdur; maint1eventdur = startletmarray[i]; maint2eventdel = maint1eventdur; maint2eventdur = maintdurarray[i] - startletmarray[i]; respeventdel = maint2eventdur; respeventdur = 2000; ITIendeventdel = respeventdur; ITIendeventdur = shocktmarray[i] - 2000; shockeventdel = ITIendeventdur; shockeventdur = 2000; threatportint = 4; safeportint = 0; lowportint = 2; highportint = 0; manipportint = 0; shockint = 16; startleportint = 0; condportint = 0; let1portint = 0; let2portint = 0; let3portint = 0; let4portint = 0; let5portint = 0; let6portint = 0; let7portint = 0; let8portint = 0; maint1portint = 0; maint2portint = 32; respportint = 0; shockportint = 64; end; ######################################################################################################### #deterimine load condition######################################################################################################## sub sub_determine_load begin rand1int = random(1,3); rand2int = random(4,6); rand3int = random(7,9); rand4int = random(11,13); rand5int = random(14,16); rand6int = random(17,19); rand7int = random(21,23); rand8int = random(24,26); sortalphabetarray[1] = alphabetarray[rand1int]; sortalphabetarray[2] = alphabetarray[rand2int]; sortalphabetarray[3] = alphabetarray[rand3int]; sortalphabetarray[4] = alphabetarray[rand4int]; sortalphabetarray[5] = alphabetarray[rand5int]; sortalphabetarray[6] = alphabetarray[rand6int]; sortalphabetarray[7] = alphabetarray[rand7int]; sortalphabetarray[8] = alphabetarray[rand8int]; mainalphabetarray[1] = alphabetarray[rand1int]; mainalphabetarray[2] = alphabetarray[rand2int]; mainalphabetarray[3] = alphabetarray[rand3int]; mainalphabetarray[4] = alphabetarray[rand4int]; mainalphabetarray[5] = alphabetarray[rand5int]; mainalphabetarray[6] = alphabetarray[rand6int]; mainalphabetarray[7] = alphabetarray[rand7int]; mainalphabetarray[8] = alphabetarray[rand8int]; respindexmatcharray = {1, 2, 3, 4, 5, 6, 7, 8}; if loadstimarray[i] == 1 then mainalphabetarray.shuffle(1,5); fixstr = "sort"; let1str = mainalphabetarray[1]; let2str = mainalphabetarray[2]; let3str = mainalphabetarray[3]; let4str = mainalphabetarray[4]; let5str = mainalphabetarray[5]; let6str = " "; let7str = " "; let8str = " "; yesnostr = "match or mismatch"; loadstr = "srt"; respalphabetarray = sortalphabetarray; respindexmatcharray.shuffle(1,5); elseif loadstimarray[i] == 2 then mainalphabetarray.shuffle(1,4); fixstr = "+"; let1str = mainalphabetarray[1]; let2str = mainalphabetarray[2]; let3str = mainalphabetarray[3]; let4str = mainalphabetarray[4]; let5str = " "; let6str = " "; let7str = " "; let8str = " "; yesnostr = "match or mismatch"; loadstr = "low"; respalphabetarray = mainalphabetarray; respindexmatcharray.shuffle(1,4); maint2portint = maint2portint + lowportint; shockportint = shockportint + lowportint; else mainalphabetarray.shuffle(1,8); fixstr = "+"; let1str = mainalphabetarray[1]; let2str = mainalphabetarray[2]; let3str = mainalphabetarray[3]; let4str = mainalphabetarray[4]; let5str = mainalphabetarray[5]; let6str = mainalphabetarray[6]; let7str = mainalphabetarray[7]; let8str = mainalphabetarray[8]; yesnostr = "match or mismatch"; loadstr = "hgh"; respalphabetarray = mainalphabetarray; respindexmatcharray.shuffle(1,8); maint2portint = maint2portint + highportint; shockportint = shockportint + highportint; end; respindexmatchint = respindexmatcharray[1]; respindexmismatchint = respindexmatcharray[2]; respindexmatchstr = " - " + string(respindexmatchint); respindexmismatchstr = " - " + string(respindexmismatchint); end; ############################################################################### #determine threat condition######################################################################################################## sub sub_determine_threat begin if threatcondarray[i] == 1 then leftbox.set_color(255,166,64); rightbox.set_color(255,166,64); lefttxt.set_background_color(255,166,64); righttxt.set_background_color(255,166,64); lefttxt.set_font_color(0,0,0); righttxt.set_font_color(0,0,0); lefttxt.set_caption("T\nh\nr\ne\na\nt"); righttxt.set_caption("T\nh\nr\ne\na\nt"); lefttxt.redraw(); righttxt.redraw(); threatcondstr = "thrt"; maint2portint = maint2portint + threatportint; shockportint = shockportint + threatportint; else leftbox.set_color(51,205,199); rightbox.set_color(51,205,199); lefttxt.set_background_color(51,205,199); righttxt.set_background_color(51,205,199); lefttxt.set_font_color(0,0,0); righttxt.set_font_color(0,0,0); lefttxt.set_caption("S\na\nf\ne"); righttxt.set_caption("S\na\nf\ne"); lefttxt.redraw(); righttxt.redraw(); threatcondstr = "safe"; maint2portint = maint2portint + safeportint; shockportint = shockportint + safeportint; end; end; ######################################################################################################### #deterimine newold condition######################################################################################################## sub sub_new_old begin if newoldarray[i] == 1 then respstr = respalphabetarray[respindexmatchint] + respindexmatchstr; resptargetbuttonint = 1; newoldstr = "match"; else respstr = respalphabetarray[respindexmatchint] + respindexmismatchstr; resptargetbuttonint = 2; newoldstr = "mismatch"; end; end; ######################################################################################################### #deterimine shock######################################################################################################## sub sub_shock begin if shockonarray[i] == 1 then shockstr = "shock"; shockstartleportint = shockint; elseif shockonarray[i] == 2 then shockstr = "startle"; shockstartleportint = startleportint; else shockstr = "noshock"; shockstartleportint = 0; end; end; ######################################################################################################### #deterimine shock######################################################################################################## sub sub_shockstartletm begin if shockstartletmarray[i] == 10 then maint2portint = maint2portint + shockstartleportint; shockportint = 0; shockstartletmstr = "maint2"; elseif shockstartletmarray[i] == 12 then shockportint = shockportint + shockstartleportint; maint2portint = 0; shockstartletmstr = "ITI"; else shockstartletmstr = "noshockstartle"; end; end; ######################################################################################################### #set_stimuli######################################################################################################## sub sub_set_stimuli begin #iti############################################ itievent.set_deltat(itieventdel); itievent.set_duration(itieventdur); itipic.add_part(leftbox, leftside, 0); itipic.add_part(rightbox, rightside, 0); itipic.add_part(lefttxt, leftside, 0); itipic.add_part(righttxt, rightside, 0); ################################################ #fix############################################ fixevent.set_deltat(fixeventdel); fixevent.set_duration(fixeventdur); fixtxt.set_caption(fixstr); fixtxt.redraw(); fixpic.add_part(fixtxt, 0, 0); fixpic.add_part(fixtxt, 0, 0); fixpic.add_part(leftbox, leftside, 0); fixpic.add_part(rightbox, rightside, 0); fixpic.add_part(lefttxt, leftside, 0); fixpic.add_part(righttxt, rightside, 0); ################################################ #let1########################################### let1event.set_deltat(let1eventdel); let1event.set_duration(let1eventdur); let1txt.set_caption(let1str); let1txt.redraw(); let1pic.add_part(let1txt, 0, 0); let1pic.add_part(leftbox, leftside, 0); let1pic.add_part(rightbox, rightside, 0); let1pic.add_part(lefttxt, leftside, 0); let1pic.add_part(righttxt, rightside, 0); ################################################ #let2########################################### let2event.set_deltat(let2eventdel); let2event.set_duration(let2eventdur); let2txt.set_caption(let2str); let2txt.redraw(); let2pic.add_part(let2txt, 0, 0); let2pic.add_part(leftbox, leftside, 0); let2pic.add_part(rightbox, rightside, 0); let2pic.add_part(lefttxt, leftside, 0); let2pic.add_part(righttxt, rightside, 0); ################################################ #let3########################################### let3event.set_deltat(let2eventdel); let3event.set_duration(let2eventdur); let3txt.set_caption(let3str); let3txt.redraw(); let3pic.add_part(let3txt, 0, 0); let3pic.add_part(leftbox, leftside, 0); let3pic.add_part(rightbox, rightside, 0); let3pic.add_part(lefttxt, leftside, 0); let3pic.add_part(righttxt, rightside, 0); ################################################ #let4########################################### let4event.set_deltat(let4eventdel); let4event.set_duration(let4eventdur); let4txt.set_caption(let4str); let4txt.redraw(); let4pic.add_part(let4txt, 0, 0); let4pic.add_part(leftbox, leftside, 0); let4pic.add_part(rightbox, rightside, 0); let4pic.add_part(lefttxt, leftside, 0); let4pic.add_part(righttxt, rightside, 0); ################################################ #let5########################################### let5event.set_deltat(let5eventdel); let5event.set_duration(let5eventdur); let5txt.set_caption(let5str); let5txt.redraw(); let5pic.add_part(let5txt, 0, 0); let5pic.add_part(leftbox, leftside, 0); let5pic.add_part(rightbox, rightside, 0); let5pic.add_part(lefttxt, leftside, 0); let5pic.add_part(righttxt, rightside, 0); ################################################ #let6########################################### let6event.set_deltat(let6eventdel); let6event.set_duration(let6eventdur); let6txt.set_caption(let6str); let6txt.redraw(); let6pic.add_part(let6txt, 0, 0); let6pic.add_part(leftbox, leftside, 0); let6pic.add_part(rightbox, rightside, 0); let6pic.add_part(lefttxt, leftside, 0); let6pic.add_part(righttxt, rightside, 0); ################################################ #let7########################################### let7event.set_deltat(let7eventdel); let7event.set_duration(let7eventdur); let7txt.set_caption(let7str); let7txt.redraw(); let7pic.add_part(let7txt, 0, 0); let7pic.add_part(leftbox, leftside, 0); let7pic.add_part(rightbox, rightside, 0); let7pic.add_part(lefttxt, leftside, 0); let7pic.add_part(righttxt, rightside, 0); ################################################ #let8########################################### let8event.set_deltat(let8eventdel); let8event.set_duration(let8eventdur); let8txt.set_caption(let8str); let8txt.redraw(); let8pic.add_part(let8txt, 0, 0); let8pic.add_part(leftbox, leftside, 0); let8pic.add_part(rightbox, rightside, 0); let8pic.add_part(lefttxt, leftside, 0); let8pic.add_part(righttxt, rightside, 0); ################################################ #maint1######################################### maint1event.set_deltat(maint1eventdel); maint1event.set_duration(maint1eventdur); maint1pic.add_part(leftbox, leftside, 0); maint1pic.add_part(rightbox, rightside, 0); maint1pic.add_part(lefttxt, leftside, 0); maint1pic.add_part(righttxt, rightside, 0); ################################################ #maint2######################################### maint2event.set_deltat(maint2eventdel); maint2event.set_duration(maint2eventdur); maint2event.set_port_code(maint2portint); maint2pic.add_part(leftbox, leftside, 0); maint2pic.add_part(rightbox, rightside, 0); maint2pic.add_part(lefttxt, leftside, 0); maint2pic.add_part(righttxt, rightside, 0); ################################################ #resp########################################### respevent.set_deltat(respeventdel); respevent.set_duration(respeventdur); respevent.set_response_active( true ); respevent.set_stimulus_time_in(0); respevent.set_stimulus_time_out(respeventdur*2); respevent.set_target_button(resptargetbuttonint); resptxt.set_caption(respstr); resptxt.redraw(); resppic.add_part(resptxt, 0, 0); yesnotxt.set_caption(yesnostr); yesnotxt.redraw(); resppic.add_part(yesnotxt, 0, -100); resppic.add_part(leftbox, leftside, 0); resppic.add_part(rightbox, rightside, 0); resppic.add_part(lefttxt, leftside, 0); resppic.add_part(righttxt, rightside, 0); ################################################ #shock########################################## ITIendevent.set_deltat(ITIendeventdel); ITIendevent.set_duration(ITIendeventdur); ITIendpic.add_part(leftbox, leftside, 0); ITIendpic.add_part(rightbox, rightside, 0); ITIendpic.add_part(lefttxt, leftside, 0); ITIendpic.add_part(righttxt, rightside, 0); ################################################ #shock########################################## shockevent.set_deltat(shockeventdel); shockevent.set_duration(shockeventdur); shockevent.set_port_code(shockportint); shockpic.add_part(leftbox, leftside, 0); shockpic.add_part(rightbox, rightside, 0); shockpic.add_part(lefttxt, leftside, 0); shockpic.add_part(righttxt, rightside, 0); ################################################ end; ######################################################################################################## #record_stimulus_timings############################################################################## sub sub_record_timing begin if (bool( stimulus_manager.stimulus_count() )) then stimulus_data let1stim = stimulus_manager.get_stimulus_data(i*3-2); stimulus_data maint1stim = stimulus_manager.get_stimulus_data(i*3-1); stimulus_data respstim = stimulus_manager.get_stimulus_data(i*3-0); let1startint = let1stim.time() - expstartint; maint1startint = maint1stim.time() - expstartint; respstartint = respstim.time() - expstartint; end; end; ######################################################################################################## #print data############################################################################## file.print("\n"); file.print("subject"); file.print("\t"); file.print("CB"); file.print("\t"); file.print("run"); file.print("\t"); file.print("trial"); file.print("\t"); file.print("shock"); file.print("\t"); file.print("shockstartletiming"); file.print("\t"); file.print("letter1"); file.print("\t"); file.print("letter2"); file.print("\t"); file.print("letter3"); file.print("\t"); file.print("letter4"); file.print("\t"); file.print("letter5"); file.print("\t"); file.print("letter6"); file.print("\t"); file.print("letter7"); file.print("\t"); file.print("letter8"); file.print("\t"); file.print("responsecue"); file.print("\t"); file.print("neworold"); file.print("\t"); file.print("response"); file.print("\t"); file.print("let1startint"); file.print("\t"); file.print("encodingperiod"); file.print("\t"); file.print("maint1startint"); file.print("\t"); file.print("maintenanceperiod"); file.print("\t"); file.print("respstartint"); file.print("\t"); file.print("threatcondition"); file.print("\t"); file.print("load"); file.print("\t"); file.print("correctorincorrect"); file.print("\t"); file.print("reactiontime"); file.print("\t"); sub sub_print_data begin #prints the data file.print("\n"); file.print(subj); file.print("\t"); file.print(CB); file.print("\t"); file.print(run); file.print("\t"); file.print(i); file.print("\t"); file.print(shockstr); file.print("\t"); file.print(shockstartletmstr); file.print("\t"); file.print(let1str); file.print("\t"); file.print(let2str); file.print("\t"); file.print(let3str); file.print("\t"); file.print(let4str); file.print("\t"); file.print(let5str); file.print("\t"); file.print(let6str); file.print("\t"); file.print(let7str); file.print("\t"); file.print(let8str); file.print("\t"); file.print(respstr); file.print("\t"); file.print(newoldstr); file.print("\t"); file.print(respbuttonstr); file.print("\t"); file.print(let1startint); file.print("\t"); file.print(maint1startint - let1startint); file.print("\t"); file.print(maint1startint); file.print("\t"); file.print(respstartint - maint1startint); file.print("\t"); file.print(respstartint); file.print("\t"); file.print(threatcondstr); file.print("\t"); file.print(loadstr); file.print("\t"); file.print(respcorrstr); file.print("\t"); file.print(resprtint); file.print("\t"); end; ############################################################################### #record responses############################################################################## sub sub_record_responses begin if (bool( stimulus_manager.stimulus_count() )) then stimulus_data laststim = stimulus_manager.last_stimulus_data(); if (laststim.type() == stimulus_hit) then respcorrstr = "correct"; elseif (laststim.type() == stimulus_incorrect) then respcorrstr = "incorrect"; elseif (laststim.type() == stimulus_miss) then respcorrstr = "noresponse"; else respcorrstr = "wtf"; end; if laststim.button() == 1 then respbuttonstr = "match"; elseif laststim.button() == 2 then respbuttonstr = "mismatch"; else respbuttonstr = "noresponse" end; resprtint = laststim.reaction_time(); end; end; ############################################################################### ######################## # # # # #run the trial # # # # ######################## #begin trial loop######################################################################################################## #sub_wait_fMRI(); sub_startleonly(); sub_startleonly(); sub_startleonly(); sub_startleonly(); loop until i > trialtotal begin sub_determine_timing(); sub_determine_load(); sub_determine_threat(); sub_new_old(); sub_shock(); sub_shockstartletm(); sub_set_stimuli(); wmtrial.present(); sub_record_timing(); sub_record_responses(); sub_print_data(); i = i + 1; end; startleonlyportint = 0; sub_startleonly(); file.close(); ###############################################################################