-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathspDist_plotGAT1.m
More file actions
179 lines (115 loc) · 5.39 KB
/
spDist_plotGAT1.m
File metadata and controls
179 lines (115 loc) · 5.39 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
% spDist_plotGAT1.m
%
% for plotting cross-validated WM GAT matrices (via IEM) on distractor trials,
% computed using spDist_channelRespAmp_GATdist.m
% 9/21/2020 UPDATED: COLORMAP, ROIs, GCF POS - geh
root = spDist_loadRoot;
root = '/share/data/spDist/';
subj = {'AY','CC','EK','KD','MR','XL','SF'};
sess = {{'spDist1','spDist2'},{'spDist1','spDist2'},{'spDist1','spDist2'},{'spDist1','spDist2'},{'spDist1','spDist2'},{'spDist1','spDist2'},{'spDist1','spDist2'}};
ROIs = {'V1V2V3','V3AB','hV4','LO1','IPS0IPS1','IPS2IPS3','sPCS'};
func_suffix = 'surf';
nchan = 8;
which_vox = 0.1;
if which_vox < 1
vox_str = sprintf('_VE%03.f',100*which_vox);
else
vox_str = sprintf('_%ivox',which_vox);
end
GAT_str = {'Target','Distractor'};
myTR = 0.75;
%% load data
startidx = 1;
for ss = 1:length(subj)
for vv = 1:length(ROIs)
% just one file to load
fn = sprintf('%sspDist_reconstructions/%s_%s_%s_%s_%ichan%s_GATdist_gh.mat',root,subj{ss},horzcat(sess{ss}{:}),ROIs{vv},func_suffix,nchan,vox_str);
fprintf('loading %s...\n',fn);
data = load(fn);
if vv == 1 && ss == 1
% initialize variables...
nblankt = length(ROIs)*size(data.recons,1);
%all_recons = nan(nblankt,size(data.recons,2),size(data.recons,3));
all_conds = nan(nblankt,size(data.c_all,2));
% each stimulus type (target/distractor)
all_fidelity{1} = nan(size(data.recons,1),size(data.recons,2),nblankt); % timecoruse of fidelity
all_fidelity{2} = nan(size(data.recons,1),size(data.recons,2),nblankt); % timecoruse of fidelity
all_subj = nan(nblankt,1);
all_ROIs = nan(nblankt,1);
all_sess = nan(nblankt,1);
angs = data.angs;
tpts = data.delay_tpts;
% ugh have to do this in a multi-D array...
%all_r2 = nan(length(ROIs),length(tpts),length(subj));
end
thisidx_all = startidx:(startidx+size(data.c_all,1)-1);
this_fidelity = cellfun(@(x) squeeze(mean(cosd(angs) .* x,2)),data.recons,'UniformOutput',false);
for tt1 = 1:size(this_fidelity,1)
for tt2 = 1:size(this_fidelity,2)
all_fidelity{1}(tt1,tt2,thisidx_all) = this_fidelity{tt1,tt2,1};
all_fidelity{2}(tt1,tt2,thisidx_all) = this_fidelity{tt1,tt2,2};
end
end
%all_recons(thisidx_map,:,:) = data.recons;
%all_fidelity(thisidx_map,:) = squeeze(mean(cosd(angs) .* data.recons,2));
%all_r2(vv,:,ss) = squeeze(mean(mean(data.r2_all,1),2)); % average over folds (dim1) and vox (dim 2)
all_conds(thisidx_all,:) = data.c_all;
all_subj(thisidx_all) = ss;
all_ROIs(thisidx_all) = vv;
all_sess(thisidx_all) = data.sess_all;
startidx = thisidx_all(end)+1;
clear data;
end
end
%% plot (average over subj)
% 1x n_rois
figure;
for aa = 1:length(all_fidelity)
for vv = 1:length(ROIs)
subplot(length(all_fidelity),length(ROIs),vv+(aa-1)*length(ROIs));hold on;
thisd = nan(size(all_fidelity{aa},1), size(all_fidelity{aa},2), length(subj));
for ss = 1:length(subj)
thisidx = all_subj==ss & all_ROIs==vv & all_conds(:,1)==2;
thisd(:,:,ss) = squeeze(mean(all_fidelity{aa}(:,:,thisidx),3));
end
imagesc(tpts*myTR,tpts*myTR,mean(thisd,3));
colormap magma
title(ROIs{vv});
axis tight square
set(gca,'XTick',0:4:24,'YTick',0:4:24,'TickDir','out');
if vv == 1
xlabel('Test time (s)');
ylabel('Train time (s)');
else
set(gca,'XTickLabel',[],'YTickLabel',[]);
end
end
end
%set(gcf,'Position',[32 778 1910 122]);
set(gcf,'position', [ 23 245 2386 453])
match_clim(get(gcf,'Children'));
cbh = colorbar('h','location','eastoutside')
set(cbh,'XTick',[-.26:.1:.38])
%% plot (individual subj as rows)
% NOTE: for now, only matched clim within figure...
for aa = 1:length(all_fidelity)
figure;
for vv = 1:length(ROIs)
for ss = 1:length(subj)
subplot(length(subj),length(ROIs),vv+(ss-1)*length(ROIs));hold on;
thisidx = all_subj==ss & all_ROIs==vv & all_conds(:,1)==2;
thisd = squeeze(mean(all_fidelity{aa}(:,:,thisidx),3));
imagesc(tpts*myTR,tpts*myTR,thisd);
if ss == 1
title(ROIs{vv});
end
axis tight square
if vv == 1
xlabel('Test time (s)');
ylabel(sprintf('%s - Train time (s)',subj{ss}));
end
end
end
set(gcf,'Name',GAT_str{aa},'NumberTitle','off');
match_clim(get(gcf,'Children'));
end