-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsaveFigureData.m
More file actions
234 lines (211 loc) · 9.11 KB
/
saveFigureData.m
File metadata and controls
234 lines (211 loc) · 9.11 KB
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
function saveFigureData()
%% Figure 1
% Behavioural responses
load(fullfile(DEC_2_setupdir('final','anal_behav_group'),'BEHAV_ANAL_group.mat'));
description = ...
['Data for Figure 1C, Behavioural Responses. ',...
'In each row, the structure field ''wAV'' contains the relative audiovisual ',...
'weight index values observed for each of the thirteen ',...
'participants (field ''participant'', 1-13), auditory (1) or visual (2) ',...
'location reports (field ''taskRelevance''), high (1) or low (2) ',...
'visual reliability (field ''visualReliability''), and high (1) or low (2) ',...
'audiovisual disparity (field ''disparity'').'];
wAV = grWav.data(grWav.data.groupings == 'all',:);
wAV = wAV{:,3:end};
wAV = wAV(:);
nSubj = numel(unique(grWav.data.subID));
participant = repmat((1:nSubj)',8,1);
visualReliability = repmat([1,1,1,1,2,2,2,2],nSubj,1);
visualReliability = visualReliability(:);
disparity = repmat([1,1,2,2,1,1,2,2],nSubj,1);
disparity = disparity(:);
taskRelevance = repmat([1,2,1,2,1,2,1,2],nSubj,1);
taskRelevance = taskRelevance(:);
fig1Data.behav = struct('description',description,'wAV',wAV,...
'participant',participant,...
'visualReliability',visualReliability,...
'disparity',disparity,...
'taskRelevance',taskRelevance);
% Bayesian Causal Inference predictions
load(fullfile(DEC_2_setupdir('final','anal_behav_group'),'bci_simul_wav_BEHAV_group.mat'));
description = ...
['Data for Figure 1C, BCI predictions. ',...
'In each row, the structure field ''wAV'' contains the relative audiovisual ',...
'weight index values predicted by the BCI model for each of the thirteen ',...
'participants (field ''participant'', 1-13), auditory (1) or visual (2) ',...
'location reports (field ''taskRelevance''), high (1) or low (2) ',...
'visual reliability (field ''visualReliability''), and high (1) or low (2) ',...
'audiovisual disparity (field ''disparity'').'];
wAV = grWav.data(grWav.data.model == 'bci',:);
wAV = wAV{:,3:end};
wAV = wAV(:);
fig1Data.bciPred = struct('description',description,'wAV',wAV,...
'participant',participant,...
'visualReliability',visualReliability,...
'disparity',disparity,...
'taskRelevance',taskRelevance);
save(fullfile(DEC_2_setupdir('final','study_root'),'docs','Data_S1_Figure_1C.mat'),'fig1Data');
%% Figure 2
fig2Data = loadCrossmodGen;
fig2Data.description = ...
['The fields ''R_trA_genA'', ''R_trA_genV'', ''R_trV_genA'', ',...
'''R_trV_genV'' contain the across condition and time generalization ',...
'matrices for each participant (1-13) trained on unisensory auditory ',...
'(''trA'') or visual (''trV'') and generalized to unisensory auditory ',...
'(''genA'') or visual conditions (''genV''). Generalization performance ',...
'is expressed as the Fisher-transformed correlation coefficient between ',...
'the true and predicted spatial locations. The dimensionality of these fields is ',...
'Training time x Generalization time x Participant. Training and ',...
'generalization time points (in seconds) are given in the fields',...
'''trTime'' and ''genTime'' respectively'];
save(fullfile(DEC_2_setupdir('final','study_root'),'docs','Data_S1_Figure_2.mat'),'fig2Data');
%% Figure 4
fig4Data.ABCD = loadWav();
fig4Data.ABCD.description = ...
['Data for Figure 4A-D ',...
'Rows of the structure field ''wAV'' contain the relative audiovisual ',...
'weight index values observed for each of the thirteen ',...
'participants (field ''participant'', 1-13), auditory (1) or visual (2) ',...
'location reports (field ''taskRelevance''), high (1) or low (2) ',...
'visual reliability (field ''visualReliability''), and high (1) or low (2) ',...
'audiovisual disparity (field ''disparity''). Columns of the field ''wAV'' ',...
'are the time points (in seconds) as denoted in the field ''time'''];
fig4Data.E = loadWavCorr();
fig4Data.E.description = ...
['Data for Figure 4E ',...
'Rows of the structure field ''corr'' contain the circular-circular ',...
'correlation coefficients between the behavioural and neural ',...
'relative audiovisual weight index values observed for each of the thirteen ',...
'participants (field ''participant'', 1-13). Columns of the field ''corr'' ',...
'are the time points (in seconds) as denoted in the field ''time'''];
fig4Data.F = loadBCI();
fig4Data.F.description = ...
['Data for Figure 4F ',...
'Rows of the structure field ''bic'' contain the ',...
'Bayesian Infromation Criterion values from the Bayesien Modelling analysis ',...
'for each of the five fitted models (field ''models'', 1 - Bayesian ',...
'Causal Inference, 2 - forced fusion, 3 - segregation unisensory auditory, ',...
'4 - segregation unisensory visual, 5 - full audiovisual segregation), ',...
'for each of the thirteen participants (field ''participant'', 1-13). ',...
'Columns of the field ''bic'' are the time points (in seconds) as ',...
'denoted in the field ''time'''];
save(fullfile(DEC_2_setupdir('final','study_root'),'docs','Data_S1_Figure_4.mat'),'fig4Data');
end
function data = loadCrossmodGen()
% Collecting subjects
expStage = 'final';
saveDf = cd(DEC_2_setupdir(expStage,'anal_eeg'));
subjList = cellstr(ls);
subjList = regexp(subjList,'[0-9]{3}','match','once');
subjList = subjList(~ismember(subjList,{''}));
cd(saveDf);
data.R_trA_genA = [];
data.R_trA_genV = [];
data.R_trV_genA = [];
data.R_trV_genV = [];
for iSubj = 1:numel(subjList)
subID = subjList{iSubj};
dir_analysis = fullfile(DEC_2_setupdir(expStage,'anal_eeg_sub_mvpa',subID),...
'sample-wise-sm-avg');
matchStr = 'er_tr-[AV]_stim_-100-5-1000_gen-.*';
saveDf = cd(dir_analysis);
fileList = cellstr(ls('*.mat'));
matchIdx = ~cellfun(@isempty,regexp(fileList,matchStr));
fileList = fileList(matchIdx);
for i = 1:size(fileList,1)
switch i
case 1
condFname = 'R_trA_genA';
case 2
condFname = 'R_trA_genV';
case 3
condFname = 'R_trV_genA';
case 4
condFname = 'R_trV_genV';
end
m = mvpares(fileList{i});
perf = m.getGenPerfEstimates('genTime','tr_x_tr');
trTime = m.getTrTimePoints;
timeMask = trTime >= -0.1 & trTime <= 0.7;
perf = perf.rf_poolFolds(timeMask,timeMask);
data.(condFname) = cat(3,data.(condFname),perf);
end
cd(saveDf);
end
[data.trTime,data.genTime] = deal(trTime(timeMask));
end
function data = loadWav()
dataFname = 'gr_er_tr-AV-c-av_s_gen-AV-ci-av.mat';
m = mvpares(fullfile(DEC_2_setupdir('final','anal_eeg_group_mvpa'),...
'sample-wise-sm-avg',dataFname));
info = m.getInfo;
fileList = info.sourceFiles;
nSubj = numel(fileList);
data.wAV = [];
for i = 1:nSubj
m = mvpares(fileList{i});
w = m.getAVmodelWeights('unit','deg','smooth',true);
fn = fieldnames(w);
idx = ~cellfun(@isempty,regexp(fn,'\w_\w_\w_wav'));
fn = sort(fn(idx));
trTime = m.getTrTimePoints;
timeMask = trTime >= -0.1 & trTime <= 0.7;
temp = [];
for j = 1:numel(fn)
temp = cat(1,temp,w.(fn{j})(timeMask)');
end
data.wAV = cat(1,data.wAV,temp);
end
data.time = trTime(timeMask);
data.participant = repmat(1:nSubj,8,1);
data.participant = data.participant(:);
data.visualReliability = repmat([1,1,1,1,2,2,2,2]',nSubj,1);
data.disparity = repmat([1,1,2,2,1,1,2,2]',nSubj,1);
data.taskRelevance = repmat([1,2,1,2,1,2,1,2]',nSubj,1);
end
function data = loadWavCorr()
dataFname = 'gr_er_tr-AV-c-av_s_gen-AV-ci-av.mat';
m = mvpares(fullfile(DEC_2_setupdir('final','anal_eeg_group_mvpa'),...
'sample-wise-sm-avg',dataFname));
info = m.getInfo;
fileList = info.sourceFiles;
nSubj = numel(fileList);
data.corr = [];
for i = 1:nSubj
m = mvpares(fileList{i});
c = m.getAVmodelCorrelations('behav','smooth',true);
trTime = m.getTrTimePoints;
timeMask = trTime >= -0.1 & trTime <= 0.7;
data.corr = cat(1,data.corr,c.cc_behav(timeMask)');
end
data.time = trTime(timeMask);
data.participant = [1:nSubj]';
end
function data = loadBCI()
% Collecting subjects
expStage = 'final';
saveDf = cd(DEC_2_setupdir(expStage,'anal_eeg'));
subjList = cellstr(ls);
subjList = regexp(subjList,'[0-9]{3}','match','once');
subjList = subjList(~ismember(subjList,{''}));
cd(saveDf);
nSubj = numel(subjList);
data.bic = [];
for iSubj = 1:nSubj
subID = subjList{iSubj};
dir_analysis = fullfile(DEC_2_setupdir(expStage,'anal_eeg_sub_mvpa',subID),...
'sample-wise-sm-avg');
matchStr = ['bci_simul_MVPA_',subID,'_AV-c-av_[0-9]+.mat'];
saveDf = cd(dir_analysis);
fileList = cellstr(ls('*.mat'));
matchIdx = ~cellfun(@isempty,regexp(fileList,matchStr));
dataFname = fileList{matchIdx};
load(dataFname,'bic','timePoints');
data.bic = cat(1,data.bic,cell2mat(bic)');
cd(saveDf);
end
data.participant = repmat(1:nSubj,5,1);
data.participant = data.participant(:);
data.model = repmat([1:5]',nSubj,1);
data.time = timePoints';
end