-
Notifications
You must be signed in to change notification settings - Fork 6
/
Subj_BehavResults.m
executable file
·489 lines (389 loc) · 22.5 KB
/
Subj_BehavResults.m
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
function Subj_BehavResults(subjNum,exptNum)
%function Subj_BehavResults(subjNum,exptNum)
%
%this function calculates behavioral results for a single subject from the
%real-time Attention training behavioral expt at UT Austin and saves these
%behavioral results to a directory for later analysis across-subjects
%
%INPUTS:
% - subjNum = subject number identifier (e.g. 1)
% - exptNum = 2 or 3 or 4
%
% MdB, 3/2012
%% check inputs
assert(isnumeric(subjNum),'subjNum should be a number');
assert((exptNum==2)||(exptNum==3)||(exptNum==4),'exptNum needs to be either 2, 3, or 4')
%% boilerplate
%print out info
fprintf('== Analyzing behavioral data for subject: %s == \n',num2str(subjNum))
%% subject ID
if subjNum <10
subjStr = ['00' num2str(subjNum)];
elseif subjNum <100
subjStr = ['0' num2str(subjNum)];
else
subjStr = num2str(subjNum);
end
%% filepaths
%these may need to be changed based on the paths
%experiment directory
expt_dir = '/Volumes/LabGroup/Faculty-Labs/BeeversLAB/Projects/rtAT/';
assert(logical(exist(expt_dir,'dir')),sprintf('experiment directory does not exist, %s\n',expt_dir));
%project directory
if exptNum==2
projName = '1_Behavioral/1_Old_Protocol';
elseif exptNum==3
projName = '1_Behavioral/2_New_Protocol';
elseif exptNum==4
projName = '2_Behavioral-Scan-Behavioral';
end
proj_dir = [expt_dir '/' projName];
assert(logical(exist(proj_dir,'dir')),sprintf('project directory does not exist: %s\n',proj_dir))
%subject directory
subj_dir = [proj_dir '/2_Data/2_MatLab/' subjStr];
assert(logical(exist(subj_dir,'dir')),sprintf('subject directory does not exist: %s\n',subj_dir));
%script directory
script_dir = [proj_dir '/2_Data/2_MatLab/scripts'];
assert(logical(exist(script_dir,'dir')),sprintf('script directory does not exist: %s\n',script_dir));
addpath(script_dir);
%directory where output should be saved
save_dir = [proj_dir '/2_Data/2_MatLab/results/'];
assert(logical(exist(save_dir,'dir')),sprintf('directory where output should be saved does not exist; %s\n',save_dir));
%% plotting options
plotSize=[1 1 1000 550]; %default plot size
%% find all run numbers
cd(subj_dir)
[runnums,blockdatafilenames] = GrabFileInfo(subj_dir,'blockdata'); %obtain list of output filenames
nruns = runnums(end); %total number of runs
fprintf('subject has %d runs\n',nruns)
nblocks = 8;
%pre-allocate
block = nan(nruns,nblocks);
type = nan(nruns,nblocks);
attCateg = nan(nruns,nblocks);
inattCateg = nan(nruns,nblocks);
trialsPerBlock = nan(nruns,nblocks);
trial = cell(nruns,nblocks);
trialLabel = cell(nruns,nblocks);
trialCount = cell(nruns,nblocks);
corrresps = cell(nruns,nblocks);
rts = cell(nruns,nblocks);
resps = cell(nruns,nblocks);
accs = cell(nruns,nblocks);
pulses = cell(nruns,nblocks);
classOutputFileLoad = cell(nruns,nblocks);
classOutputFile = cell(nruns,nblocks);
categsep = cell(nruns,nblocks);
attImgProp = cell(nruns,nblocks);
smoothAttImgProp = cell(nruns,nblocks);
categs = cell(nruns,nblocks);
images = cell(nruns,nblocks);
files = cell(nruns,nblocks);
%load files & assemble matrices
for iRun = 1:nruns
fprintf('loading file: %s\n',blockdatafilenames{iRun});
load(blockdatafilenames{iRun});
block(iRun,:) = [blockData.block];
type(iRun,:) = [blockData.type];
attCateg(iRun,:) = [blockData.attCateg];
inattCateg(iRun,:) = [blockData.inattCateg];
trialsPerBlock(iRun,:) = [blockData.trialsPerBlock];
trial(iRun,:) = {blockData.trial};
trialLabel(iRun,:) = {blockData.trialLabel};
trialCount(iRun,:) = {blockData.trialCount};
corrresps(iRun,:) = {blockData.corrresps};
rts(iRun,:) = {blockData.rts};
resps(iRun,:) = {blockData.resps};
accs(iRun,:) = {blockData.accs};
pulses(iRun,:) = {blockData.pulses};
classOutputFileLoad(iRun,:) = {blockData.classOutputFileLoad};
classOutputFile(iRun,:) = {blockData.classOutputFile};
categsep(iRun,:) = {blockData.categsep};
attImgProp(iRun,:) = {blockData.attImgProp};
smoothAttImgProp(iRun,:) = {blockData.smoothAttImgProp};
categs(iRun,:) = {blockData.categs};
images(iRun,:) = {blockData.images};
files(iRun,:) = {blockData.files};
end
%remove last block data file
clearvars blockData
%% clean up the data
%convert RTs to ms
rtsMsec = cellfun(@(x) x*1000, rts,'UniformOutput',false);
%find lure trial locations
lureTrials = cellfun(@(x) isnan(x),corrresps,'UniformOutput',false);
%find target trial locations
targTrials = cellfun(@(x) ~isnan(x),corrresps,'UniformOutput',false);
attnF_distS.blocks = intersect(find(attCateg==2),find(cell2mat(cellfun(@(x) any(x{2}<=4),categs,'UniformOutput',false))));
attsdF_distS.blocks = intersect(find(attCateg==2),find(cell2mat(cellfun(@(x) any(x{2}>4),categs,'UniformOutput',false))));
attS_distnF.blocks = intersect(find(attCateg==1),find(cell2mat(cellfun(@(x) any(x{2}<=4),categs,'UniformOutput',false))));
attS_distsdF.blocks = intersect(find(attCateg==1),find(cell2mat(cellfun(@(x) any(x{2}>4),categs,'UniformOutput',false))));
%find the RTs for the stable and emotional distractors
attnF_distS.RTs = [rtsMsec{attnF_distS.blocks}];
attsdF_distS.RTs = [rtsMsec{attsdF_distS.blocks}];
attS_distnF.RTs = [rtsMsec{attS_distnF.blocks}];
attS_distsdF.RTs = [rtsMsec{attS_distsdF.blocks}];
%temporary accuracy of all trials
attnF_distS.accs = [accs{attnF_distS.blocks}];
attsdF_distS.accs = [accs{attsdF_distS.blocks}];
attS_distnF.accs = [accs{attS_distnF.blocks}];
attS_distsdF.accs = [accs{attS_distsdF.blocks}];
%% rts trend
%trials before and after lure
rtWindow = 6;
for iRun = runnums;
for iBlock = 1:nblocks;
%lureAccs{iRun,iBlock} = accs{iRun,iBlock}(lureTrials{iRun,iBlock})~=0; %#ok<NASGU>
lureRTs{iRun,iBlock} = rtsMsec{iRun,iBlock}(lureTrials{iRun,iBlock}); %#ok<AGROW>
%targetRTs{iRun,iBlock} = rtsMsec{iRun,iBlock}(targTrials{iRun,iBlock});
lureTrialNums{iRun,iBlock} = find(lureTrials{iRun,iBlock}); %#ok<AGROW>
rts_afterLures{iRun,iBlock} = NaN(rtWindow,numel(lureTrialNums{iRun,iBlock})); %#ok<AGROW>
accs_afterLures{iRun,iBlock} = NaN(rtWindow,numel(lureTrialNums{iRun,iBlock})); %#ok<AGROW>
for iLure = 1:numel(lureTrialNums{iRun,iBlock})
trialNums_beforeLures{iRun,iBlock}(:,iLure) = lureTrialNums{iRun,iBlock}(iLure)-(6:-1:1); %#ok<AGROW>
rts_beforeLures{iRun,iBlock}(:,iLure) = rtsMsec{iRun,iBlock}(trialNums_beforeLures{iRun,iBlock}(:,iLure)); %#ok<AGROW>
%accs_beforeLures{iRun,iBlock}(:,iLure) = accs{iRun,iBlock}(trialNums_beforeLures{iRun,iBlock}(:,iLure))~=0;
trialNums_afterLures{iRun,iBlock}(:,iLure) = lureTrialNums{iRun,iBlock}(iLure)+(1:6); %#ok<AGROW>
for i = 1:rtWindow
if (trialNums_afterLures{iRun,iBlock}(i,iLure)<=50)
rts_afterLures{iRun,iBlock}(i,iLure) = rtsMsec{iRun,iBlock}(trialNums_afterLures{iRun,iBlock}(i,iLure)); %#ok<AGROW>
accs_afterLures{iRun,iBlock}(i,iLure) = accs{iRun,iBlock}(trialNums_afterLures{iRun,iBlock}(i,iLure))~=0; %#ok<AGROW>
else
rts_afterLures{iRun,iBlock}(i,iLure) = NaN; %#ok<AGROW>
accs_afterLures{iRun,iBlock}(i,iLure) = NaN; %#ok<AGROW>
end
end
end
end
end
%% block stats
blockBehav.nTarg = cell2mat(cellfun(@(x) sum(x),targTrials,'UniformOutput',false)); %number of targets per block
blockBehav.nTargCor = cell2mat(cellfun(@(x) sum(x==1),accs,'UniformOutput',false)); %correct reject per block
blockBehav.nTargErr = blockBehav.nTarg - blockBehav.nTargCor; %false alarm per block
blockBehav.nLure = cell2mat(cellfun(@(x) sum(x),lureTrials,'UniformOutput',false)); %number of lures per block
blockBehav.nLureCor = cell2mat(cellfun(@(x) sum(x==2),accs,'UniformOutput',false)); %correct reject per block
blockBehav.nLureErr = blockBehav.nLure - blockBehav.nLureCor; %false alarm per block
blockBehav.hitRate = blockBehav.nTargCor./blockBehav.nTarg;
blockBehav.missRate = 1-blockBehav.hitRate;
blockBehav.corrrejRate = blockBehav.nLureCor./blockBehav.nLure;
blockBehav.falsealarmRate = 1-blockBehav.corrrejRate;
%% run stats
%collapsing across conditions
runBehav.nTarg = sum(blockBehav.nTarg,2);
runBehav.nTargCor = sum(blockBehav.nTargCor,2);
runBehav.nTargErr = runBehav.nTarg - runBehav.nTargCor;
runBehav.nLure = sum(blockBehav.nLure,2);
runBehav.nLureCor = sum(blockBehav.nLureCor,2);
runBehav.nLureErr = runBehav.nLure - runBehav.nLureCor;
runBehav.hitrate = runBehav.nTargCor./runBehav.nTarg;
runBehav.missrate = 1-runBehav.hitrate;
runBehav.corrrejrate = runBehav.nLureCor./runBehav.nLure;
runBehav.falsealarmrate = 1-runBehav.corrrejrate; %#ok<STRNU>
%% rt trend
attnF_distS.allRTsbeforeLures = [rts_beforeLures{attnF_distS.blocks}];
attsdF_distS.allRTsbeforeLures = [rts_beforeLures{attsdF_distS.blocks}];
attS_distnF.allRTsbeforeLures = [rts_beforeLures{attS_distnF.blocks}];
attS_distsdF.allRTsbeforeLures = [rts_beforeLures{attS_distsdF.blocks}];
attnF_distS.allRTsLure = [lureRTs{attnF_distS.blocks}];
attsdF_distS.allRTsLure = [lureRTs{attnF_distS.blocks}];
attS_distnF.allRTsLure = [lureRTs{attS_distnF.blocks}];
attS_distsdF.allRTsLure = [lureRTs{attS_distsdF.blocks}];
attnF_distS.allRTsafterLures = [rts_afterLures{attnF_distS.blocks}];
attsdF_distS.allRTsafterLures = [rts_afterLures{attnF_distS.blocks}];
attS_distnF.allRTsafterLures = [rts_afterLures{attS_distnF.blocks}];
attS_distsdF.allRTsafterLures = [rts_afterLures{attS_distsdF.blocks}];
%% subject stats
%collapsing across all condition
subBehav.nTarg = sum(sum(blockBehav.nTarg));
subBehav.nTargCor = sum(sum(blockBehav.nTargCor));
subBehav.nTargErr = subBehav.nTarg-subBehav.nTargCor;
subBehav.nLure = sum(sum(blockBehav.nLure));
subBehav.nLureCor = sum(sum(blockBehav.nLureCor));
subBehav.nLureErr = subBehav.nLure-subBehav.nLureCor;
subBehav.hitRate = subBehav.nTargCor/subBehav.nTarg;
subBehav.missRate = 1-subBehav.hitRate;
subBehav.corrrejRate = subBehav.nLureCor/subBehav.nLure;
subBehav.falsealarmRate = 1-subBehav.corrrejRate;
%splitting into different conditions
attnF_distS.nTarg = sum(blockBehav.nTarg(attnF_distS.blocks));
attnF_distS.nTargCor = sum(blockBehav.nTargCor(attnF_distS.blocks));
attnF_distS.nTargErr = attnF_distS.nTarg - attnF_distS.nTargCor;
attnF_distS.nLure = sum(blockBehav.nLure(attnF_distS.blocks));
attnF_distS.nLureCor = sum(blockBehav.nLureCor(attnF_distS.blocks));
attnF_distS.nLureErr = attnF_distS.nLure - attnF_distS.nLureCor;
attnF_distS.hitRate = attnF_distS.nTargCor/attnF_distS.nTarg;
attnF_distS.missRate = 1-attnF_distS.hitRate;
attnF_distS.corrrejRate = attnF_distS.nLureCor/attnF_distS.nLure;
attnF_distS.falsealarmRate = 1-attnF_distS.corrrejRate;
attsdF_distS.nTarg = sum(blockBehav.nTarg(attsdF_distS.blocks));
attsdF_distS.nTargCor = sum(blockBehav.nTargCor(attsdF_distS.blocks));
attsdF_distS.nTargErr = attsdF_distS.nTarg - attsdF_distS.nTargCor;
attsdF_distS.nLure = sum(blockBehav.nLure(attsdF_distS.blocks));
attsdF_distS.nLureCor = sum(blockBehav.nLureCor(attsdF_distS.blocks));
attsdF_distS.nLureErr = attsdF_distS.nLure - attsdF_distS.nLureCor;
attsdF_distS.hitRate = attsdF_distS.nTargCor/attsdF_distS.nTarg;
attsdF_distS.missRate = 1-attsdF_distS.hitRate;
attsdF_distS.corrrejRate = attsdF_distS.nLureCor/attsdF_distS.nLure;
attsdF_distS.falsealarmRate = 1-attsdF_distS.corrrejRate;
attS_distnF.nTarg = sum(blockBehav.nTarg(attS_distnF.blocks));
attS_distnF.nTargCor = sum(blockBehav.nTargCor(attS_distnF.blocks));
attS_distnF.nTargErr = attS_distnF.nTarg - attS_distnF.nTargCor;
attS_distnF.nLure = sum(blockBehav.nLure(attS_distnF.blocks));
attS_distnF.nLureCor = sum(blockBehav.nLureCor(attS_distnF.blocks));
attS_distnF.nLureErr = attS_distnF.nLure - attS_distnF.nLureCor;
attS_distnF.hitRate = attS_distnF.nTargCor/attS_distnF.nTarg;
attS_distnF.missRate = 1-attS_distnF.hitRate;
attS_distnF.corrrejRate = attS_distnF.nLureCor/attS_distnF.nLure;
attS_distnF.falsealarmRate = 1-attS_distnF.corrrejRate;
attS_distsdF.nTarg = sum(blockBehav.nTarg(attS_distsdF.blocks));
attS_distsdF.nTargCor = sum(blockBehav.nTargCor(attS_distsdF.blocks));
attS_distsdF.nTargErr = attS_distsdF.nTarg - attS_distsdF.nTargCor;
attS_distsdF.nLure = sum(blockBehav.nLure(attS_distsdF.blocks));
attS_distsdF.nLureCor = sum(blockBehav.nLureCor(attS_distsdF.blocks));
attS_distsdF.nLureErr = attS_distsdF.nLure - attS_distsdF.nLureCor;
attS_distsdF.hitRate = attS_distsdF.nTargCor/attS_distsdF.nTarg;
attS_distsdF.missRate = 1-attS_distsdF.hitRate;
attS_distsdF.corrrejRate = attS_distsdF.nLureCor/attS_distsdF.nLure;
attS_distsdF.falsealarmRate = 1-attS_distsdF.corrrejRate;
%% behavioral information
fprintf('Percent Lure Trials Correct: %.3f\n',subBehav.corrrejRate*100);
fprintf('Percent Target Trials Correct: %.3f\n',subBehav.hitRate*100);
[subBehav.dPrime,subBehav.beta,subBehav.C] = dprime(subBehav.hitRate,subBehav.falsealarmRate,subBehav.nTarg,subBehav.nLure);
[attnF_distS.dPrime,attnF_distS.beta,attnF_distS.C] = dprime(attnF_distS.hitRate,attnF_distS.falsealarmRate,attnF_distS.nTarg,attnF_distS.nLure);
[attsdF_distS.dPrime,attsdF_distS.beta,attsdF_distS.C] = dprime(attsdF_distS.hitRate,attsdF_distS.falsealarmRate,attsdF_distS.nTarg,attsdF_distS.nLure);
[attS_distnF.dPrime,attS_distnF.beta,attS_distnF.C] = dprime(attS_distnF.hitRate,attS_distnF.falsealarmRate,attS_distnF.nTarg,attS_distnF.nLure);
[attS_distsdF.dPrime,attS_distsdF.beta,attS_distsdF.C] = dprime(attS_distsdF.hitRate,attS_distsdF.falsealarmRate,attS_distsdF.nTarg,attS_distsdF.nLure);
fprintf('\n')
fprintf('dprime = %.3f\n',subBehav.dPrime);
fprintf('beta = %.3f\n',subBehav.beta);
fprintf('C = %.3f\n',subBehav.C);
subBehav.aPrime = .5 + ((subBehav.hitRate-subBehav.falsealarmRate)*(1+subBehav.hitRate-subBehav.falsealarmRate))/(4*subBehav.hitRate*(1-subBehav.falsealarmRate));
subBehav.B_D = ((1-subBehav.hitRate)*(1-subBehav.falsealarmRate)-(subBehav.hitRate*subBehav.falsealarmRate))/((1-subBehav.hitRate)*(1-subBehav.falsealarmRate)+(subBehav.hitRate*subBehav.falsealarmRate));
attnF_distS.aPrime = .5 + ((attnF_distS.hitRate-attnF_distS.falsealarmRate)*(1+attnF_distS.hitRate-attnF_distS.falsealarmRate))/(4*attnF_distS.hitRate*(1-attnF_distS.falsealarmRate));
attnF_distS.B_D = ((1-attnF_distS.hitRate)*(1-attnF_distS.falsealarmRate)-(attnF_distS.hitRate*attnF_distS.falsealarmRate))/((1-attnF_distS.hitRate)*(1-attnF_distS.falsealarmRate)+(attnF_distS.hitRate*attnF_distS.falsealarmRate));
attsdF_distS.aPrime = .5 + ((attsdF_distS.hitRate-attsdF_distS.falsealarmRate)*(1+attsdF_distS.hitRate-attsdF_distS.falsealarmRate))/(4*attsdF_distS.hitRate*(1-attsdF_distS.falsealarmRate));
attsdF_distS.B_D = ((1-attsdF_distS.hitRate)*(1-attsdF_distS.falsealarmRate)-(attsdF_distS.hitRate*attsdF_distS.falsealarmRate))/((1-attsdF_distS.hitRate)*(1-attsdF_distS.falsealarmRate)+(attsdF_distS.hitRate*attsdF_distS.falsealarmRate));
attS_distnF.aPrime = .5 + ((attS_distnF.hitRate-attS_distnF.falsealarmRate)*(1+attS_distnF.hitRate-attS_distnF.falsealarmRate))/(4*attS_distnF.hitRate*(1-attS_distnF.falsealarmRate));
attS_distnF.B_D = ((1-attS_distnF.hitRate)*(1-attS_distnF.falsealarmRate)-(attS_distnF.hitRate*attS_distnF.falsealarmRate))/((1-attS_distnF.hitRate)*(1-attS_distnF.falsealarmRate)+(attS_distnF.hitRate*attS_distnF.falsealarmRate));
attS_distsdF.aPrime = .5 + ((attS_distsdF.hitRate-attS_distsdF.falsealarmRate)*(1+attS_distsdF.hitRate-attS_distsdF.falsealarmRate))/(4*attS_distsdF.hitRate*(1-attS_distsdF.falsealarmRate));
attS_distsdF.B_D = ((1-attS_distsdF.hitRate)*(1-attS_distsdF.falsealarmRate)-(attS_distsdF.hitRate*attS_distsdF.falsealarmRate))/((1-attS_distsdF.hitRate)*(1-attS_distsdF.falsealarmRate)+(attS_distsdF.hitRate*attS_distsdF.falsealarmRate));
%%
fprintf('Printing A'' information for various conditions\n');
fprintf('Mat ID\tnF S\tsdF S\tS nF\tS sdF\tmean A''\tA'' diff distn-distsd\n')
fprintf('%d\t%.3f\t%.3f\t%.3f\t%.3f\t%.3f\t%.3f\n',subjNum,attnF_distS.aPrime,attsdF_distS.aPrime,attS_distnF.aPrime,attS_distsdF.aPrime,...
mean([attnF_distS.aPrime,attsdF_distS.aPrime,attS_distnF.aPrime,attS_distsdF.aPrime]),attS_distnF.aPrime-attS_distsdF.aPrime);
fprintf('\n');
%% plot overall behavioral information
figure('Position',plotSize,'DefaultLineLineWidth',2,'DefaultAxesFontSize',16,'DefaultTextFontSize',16);
subplot(1,3,1);
hold on;
bar(1,subBehav.hitRate);
bar(2,subBehav.falsealarmRate);
title(['Behavior Subj ' num2str(subjNum)]);
set(gca,'ylim',[0 1],'xlim',[0 3],'xtick',[1 2],'xticklabel',{'Hit rate','FA rate'})
subplot(1,3,2);
hold on;
bar(1,subBehav.dPrime);
bar(2,subBehav.beta);
title(['Param measures Subj' num2str(subjNum)]);
set(gca,'xlim',[0 3],'xtick',[1 2],'xticklabel',{'d''','beta'})
subplot(1,3,3);
hold on;
bar(1,subBehav.aPrime);
bar(2,subBehav.B_D);
title(['Non-param measures Subj ' num2str(subjNum)]);
set(gca,'ylim',[-1 1],'xlim',[0 3],'xtick',[1 2],'xticklabel',{'a''','B_D'})
%save figure
figname = [num2str(subjNum) '_behav_meas'];
printfig2(fullfile(save_dir,figname),'filetype','eps');
%% plot condition behavioral information
figure('Position',plotSize,'DefaultLineLineWidth',2,'DefaultAxesFontSize',16,'DefaultTextFontSize',16);
subplot(2,2,1);
hold on;
bar(1,attnF_distS.falsealarmRate);
bar(2,attnF_distS.aPrime);
title('att n F dist S');
set(gca,'ylim',[0 1]','xlim',[0 3],'xtick',[1 2],'xticklabel',{'FA rate','a'''})
subplot(2,2,2);
hold on;
bar(1,attsdF_distS.falsealarmRate);
bar(2,attsdF_distS.aPrime);
title('att sd F dist S');
set(gca,'ylim',[0 1],'xlim',[0 3],'xtick',[1 2],'xticklabel',{'FA rate','a'''})
subplot(2,2,3);
hold on;
bar(1,attS_distnF.falsealarmRate);
bar(2,attS_distnF.aPrime);
title('att S dist n F');
set(gca,'ylim',[0 1],'xlim',[0 3],'xtick',[1 2],'xticklabel',{'FA rate','a'''})
subplot(2,2,4);
hold on;
bar(1,attS_distnF.falsealarmRate);
bar(2,attS_distnF.aPrime);
title('att S dist sd F');
set(gca,'ylim',[0 1],'xlim',[0 3],'xtick',[1 2],'xticklabel',{'FA rate','a'''})
%save figure
figname = [num2str(subjNum) '_cond_behav_meas'];
printfig2(fullfile(save_dir,figname),'filetype','eps');
%%
figure('Position',plotSize,'DefaultLineLineWidth',2,'DefaultAxesFontSize',16,'DefaultTextFontSize',16);
ylim = [300 650];
xlim = [-7 7];
xtick = ((-1*rtWindow):2:rtWindow);
subplot(2,2,1);
hold on;
h1=errorbar(-1*(rtWindow:-1:1),nanmean(attnF_distS.allRTsbeforeLures(:,isnan(attnF_distS.allRTsLure)),2),...
nanstd(attnF_distS.allRTsbeforeLures(:,isnan(attnF_distS.allRTsLure)),[],2)./sqrt(sum(isnan(attnF_distS.allRTsLure))),'g','linewidth',2);
errorbar((1:rtWindow),nanmean(attnF_distS.allRTsafterLures(:,isnan(attnF_distS.allRTsLure)),2),...
nanstd(attnF_distS.allRTsafterLures(:,isnan(attnF_distS.allRTsLure)),[],2)./sqrt(sum(isnan(attnF_distS.allRTsLure))),'g');
h3=errorbar(-1*rtWindow:rtWindow,...
[nanmean(attnF_distS.allRTsbeforeLures(:,~isnan(attnF_distS.allRTsLure)),2);nanmean(attnF_distS.allRTsLure);nanmean(attnF_distS.allRTsafterLures(:,~isnan(attnF_distS.allRTsLure)),2)],...
[nanstd(attnF_distS.allRTsbeforeLures(:,isnan(attnF_distS.allRTsLure)),[],2);nanstd(attnF_distS.allRTsLure);nanstd(attnF_distS.allRTsafterLures(:,~isnan(attnF_distS.allRTsLure)),[],2)]./sqrt(sum(isnan(attnF_distS.allRTsLure))),'r','linewidth',2);
set(gca,'ylim',ylim,'xlim',xlim,'xtick',xtick);
title('att neut F dist S');
xlabel('Trials from lure');
legend([h1 h3],{'CR','FA'},'Location','SouthEast');
ylabel('RTs (ms)');
subplot(2,2,2);
hold on;
errorbar(-1*(rtWindow:-1:1),nanmean(attsdF_distS.allRTsbeforeLures(:,isnan(attsdF_distS.allRTsLure)),2),...
nanstd(attsdF_distS.allRTsbeforeLures(:,isnan(attsdF_distS.allRTsLure)),[],2)./sqrt(sum(isnan(attsdF_distS.allRTsLure))),'g','linewidth',2);
errorbar((1:rtWindow),nanmean(attsdF_distS.allRTsafterLures(:,isnan(attsdF_distS.allRTsLure)),2),...
nanstd(attsdF_distS.allRTsafterLures(:,isnan(attsdF_distS.allRTsLure)),[],2)./sqrt(sum(isnan(attsdF_distS.allRTsLure))),'g');
errorbar(-1*rtWindow:rtWindow,...
[nanmean(attsdF_distS.allRTsbeforeLures(:,~isnan(attsdF_distS.allRTsLure)),2);nanmean(attsdF_distS.allRTsLure);nanmean(attsdF_distS.allRTsafterLures(:,~isnan(attsdF_distS.allRTsLure)),2)],...
[nanstd(attsdF_distS.allRTsbeforeLures(:,isnan(attsdF_distS.allRTsLure)),[],2);nanstd(attsdF_distS.allRTsLure);nanstd(attsdF_distS.allRTsafterLures(:,~isnan(attsdF_distS.allRTsLure)),[],2)]./sqrt(sum(isnan(attsdF_distS.allRTsLure))),'r','linewidth',2);
set(gca,'ylim',ylim,'xlim',xlim,'xtick',xtick);
title('att sad F dist S');
xlabel('Trials from lure');
ylabel('RTs (ms)');
subplot(2,2,3);
hold on;
errorbar(-1*(rtWindow:-1:1),nanmean(attS_distnF.allRTsbeforeLures(:,isnan(attS_distnF.allRTsLure)),2),...
nanstd(attS_distnF.allRTsbeforeLures(:,isnan(attS_distnF.allRTsLure)),[],2)./sqrt(sum(isnan(attS_distnF.allRTsLure))),'g');
errorbar((1:rtWindow),nanmean(attS_distnF.allRTsafterLures(:,isnan(attS_distnF.allRTsLure)),2),...
nanstd(attS_distnF.allRTsafterLures(:,isnan(attS_distnF.allRTsLure)),[],2)./sqrt(sum(isnan(attS_distnF.allRTsLure))),'g');
errorbar(-1*rtWindow:rtWindow,...
[nanmean(attS_distnF.allRTsbeforeLures(:,~isnan(attS_distnF.allRTsLure)),2);nanmean(attS_distnF.allRTsLure);nanmean(attS_distnF.allRTsafterLures(:,~isnan(attS_distnF.allRTsLure)),2)],...
[nanstd(attS_distnF.allRTsbeforeLures(:,isnan(attS_distnF.allRTsLure)),[],2);nanstd(attS_distnF.allRTsLure);nanstd(attS_distnF.allRTsafterLures(:,~isnan(attS_distnF.allRTsLure)),[],2)]./sqrt(sum(isnan(attS_distnF.allRTsLure))),'r');
set(gca,'ylim',ylim,'xlim',xlim,'xtick',xtick);
title('att S dist neut F');
xlabel('Trials from lure');
subplot(2,2,4);
hold on;
errorbar(-1*(rtWindow:-1:1),nanmean(attS_distsdF.allRTsbeforeLures(:,isnan(attS_distsdF.allRTsLure)),2),...
nanstd(attS_distsdF.allRTsbeforeLures(:,isnan(attS_distsdF.allRTsLure)),[],2)./sqrt(sum(isnan(attS_distsdF.allRTsLure))),'g');
errorbar((1:rtWindow),nanmean(attS_distsdF.allRTsafterLures(:,isnan(attS_distsdF.allRTsLure)),2),...
nanstd(attS_distsdF.allRTsafterLures(:,isnan(attS_distsdF.allRTsLure)),[],2)./sqrt(sum(isnan(attS_distsdF.allRTsLure))),'g');
errorbar(-1*rtWindow:rtWindow,...
[nanmean(attS_distsdF.allRTsbeforeLures(:,~isnan(attS_distsdF.allRTsLure)),2);nanmean(attS_distsdF.allRTsLure);nanmean(attS_distsdF.allRTsafterLures(:,~isnan(attS_distsdF.allRTsLure)),2)],...
[nanstd(attS_distsdF.allRTsbeforeLures(:,isnan(attS_distsdF.allRTsLure)),[],2);nanstd(attS_distsdF.allRTsLure);nanstd(attS_distsdF.allRTsafterLures(:,~isnan(attS_distsdF.allRTsLure)),[],2)]./sqrt(sum(isnan(attS_distsdF.allRTsLure))),'r');
set(gca,'ylim',ylim,'xlim',xlim,'xtick',xtick);
title('att S dist sad F');
xlabel('Trials from lure');
%save figure
figname = [num2str(subjNum) '_rtsaroundlures'];
printfig2(fullfile(save_dir,figname),'filetype','eps');
%%
filename = [num2str(subjNum) '_behavResults'];
save(fullfile(save_dir,filename),'blockBehav','runBehav','subBehav','attnF_distS','attsdF_distS','attS_distnF','attS_distsdF');