-
Notifications
You must be signed in to change notification settings - Fork 3
/
rd_combineRunsTemporalAttentionAdjust.m
71 lines (59 loc) · 1.94 KB
/
rd_combineRunsTemporalAttentionAdjust.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
% rd_combineRunsTemporalAttentionAdjust.m
%% setup
subject = 'jx_a1_tc100_soa1000-1250';
runs = 3:4;
combinedRun = 29;
nRuns = numel(runs);
saveData = 1;
saveFigs = 1;
expName = 'E3_adjust';
% dataDir = 'data';
% figDir = 'figures';
dataDir = pathToExpt('data');
figDir = pathToExpt('figures');
dataDir = sprintf('%s/%s/%s', dataDir, expName, subject(1:2));
figDir = sprintf('%s/%s/%s', figDir, expName, subject(1:2));
%% initializations
subjectID = sprintf('%s_run%02d', subject, combinedRun);
trials = [];
targetRotations = [];
trialOrder = [];
%% get data from each run
for iRun = 1:nRuns
run = runs(iRun);
dataFile = dir(sprintf('%s/%s_run%02d*', dataDir, subject, run));
data = load(sprintf('%s/%s', dataDir, dataFile.name));
trials = [trials; data.expt.trials];
targetRotations = [targetRotations; data.expt.targetRotations];
trialOrder = [trialOrder; data.expt.trialOrder + size(trialOrder,2)];
trialsPresented(iRun) = data.expt.trialsPresented;
if strcmp(subjectID(1:3),'xx*')
timing = [];
else
timing(iRun) = data.expt.timing;
end
end
%% make the combined expt
expt.subjectID = subjectID;
expt.runs = runs;
expt.p = data.expt.p; % assume all runs identical
expt.timing = timing;
expt.trialOrder = trialOrder;
expt.trials_headers = data.expt.trials_headers; % assume all runs identical
expt.trials = trials;
expt.targetRotations = targetRotations;
expt.trialsPresented = trialsPresented;
%% analyze data
[expt results] = rd_analyzeTemporalAttentionAdjust(expt);
%% save data
% saving data and figs separately in order to save them into the mcq
% directory, and not locally
if saveData
fileName = sprintf('%s/%s_TemporalAttentionAdjust_T1T2all_%s.mat', dataDir, subjectID, datestr(now, 'yyyymmdd'));
save(fileName, 'expt', 'results')
end
%% save figs
if saveFigs
figNames = {'error','acc','rt'};
rd_saveAllFigs([], figNames, [subjectID '_TemporalAttentionAdjust_T1T2all'], figDir)
end