-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_timedomain_ToposSmallWins_bb_adult_33ms.m
220 lines (207 loc) · 6.62 KB
/
plot_timedomain_ToposSmallWins_bb_adult_33ms.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
% plot topographies
clear;close all;clc;
%% ODDBALL TIME WINDOW TOPOS
clear;close all;clc;
bbpath = ('');
cd(bbpath)
splinefile = 'EGI_128.spl';
conlist = {'Faces','Cars','Corridors','Limbs','Characters'};
plotOdd = 1;
% parsing windows
odds = 1/5;
totallen = 1167;
sampling = 490;
winLenSamp = 14/2; % Temporal window length, in samples; % 33.3ms
allRunData = [];
allTimePoints = [];
load('New3Groups_arrange_clean_finalbldata.mat');
for run = 1:4
if run == 1
newData = groupData1;
subjList_short = idx1;
groupname = 1;
elseif run == 2
newData = groupData2;
subjList_short = idx2;
groupname = 2;
elseif run == 3
newData = groupData3;
subjList_short = idx3;
groupname = 3;
elseif run == 4
newData = groupData4;
subjList_short = idx4;
groupname = 4;
end
mdataIn = cellfun(@(x) x*10^6, newData, 'uni', false);
timewins = [450+33,500];
timewinpts = round(timewins*sampling/totallen,0); %time points
for tt = 1:length(timewinpts)
temp = timewinpts(tt);
tprange = [temp-winLenSamp:temp+winLenSamp];
timepoints(tt,:) = tprange;
end
allTimePoints(run,:,:) = timepoints;
%get group average
timedata = [];
for con = 1:5
tempdata = mdataIn(:,con);
avgtemp = nanmean(cat(3,tempdata{:}),3);
for tt = 1:size(timepoints,1)
temppts = timepoints(tt,:);
timedata(con,tt,:) = nanmean(avgtemp(temppts,:),1);
end
end
allRunData(run,:,:,:) = timedata; %run x con x nwins x chan
end
nwinpt = size(allTimePoints,3);
%% plotting 3D for infants
close all;
for con = 4
figure('position',[300 300 1800 300*4],'color','w')
data = squeeze(allRunData(:,con,:,:));
nwin = size(data,2);
ww = 0;
for run = 1:4
for win = 1:nwin
ww = ww + 1;
subplot_tight(4,nwin,ww,[0.08 0.04])
tdata = squeeze(data(run,win,:));
%plot topo
if run == 1
titlename = sprintf('%s-%s ms',...
num2str(round(allTimePoints(run,win,1)*1167/490,0)),...
num2str(round(allTimePoints(run,win,nwinpt)*1167/490,0)));
headplot([0 0 0 tdata'], splinefile, 'maplimits', [-5 5], 'title', titlename,...
'colormap', jmaColors('coolhotcortex'), 'electrodes', 'on', 'view', [0 30]);
else
headplot([0 0 0 tdata'], splinefile, 'maplimits', [-5 5],...
'colormap', jmaColors('coolhotcortex'), 'electrodes', 'on', 'view', [0 30]);
end
end
end
sgtitle(conlist{con},'fontsize',20)
%save
if plotOdd
figpath = bbpath;
figname = sprintf('3D-timedomain-definedWins-%d-%dms-topos-%s.png',timewins(1),timewins(end),conlist{con});
end
saveas(gcf,fullfile(figpath,figname))
close
end
%% plotting 3D for adults
for con = 1:5
figure('position',[300 300 1800 300],'color','w')
data = squeeze(allRunData(:,con,:,:));
nwin = size(data,2);
ww = 0;
for run = 5
for win = 1:nwin
ww = ww + 1;
subplot_tight(1,nwin,ww,[0.08 0.04])
tdata = squeeze(data(run,win,:));
%plot topo
titlename = sprintf('%s-%s ms',...
num2str(round(allTimePoints(run,win,1)*1167/490,0)),...
num2str(round(allTimePoints(run,win,nwinpt)*1167/490,0)));
headplot([0 0 0 tdata'], splinefile, 'maplimits', [-1 1], 'title', titlename,...
'colormap', jmaColors('coolhotcortex'), 'electrodes', 'off', 'view', [0 30]);
end
end
sgtitle(conlist{con},'fontsize',20)
%save
if plotOdd
figname = sprintf('3D-timedomain-definedWins-topos-%s-bbtrials.png',conlist{con});
figpath = adpath;
end
saveas(gcf,fullfile(figpath,figname))
close
end
%% INFANTS - CARRIERS
clear;close all;clc;
bbpath = ('');
cd(bbpath)
splinefile = 'EGI_128.spl';
plotOdd = 1;
% parsing windows
odds = 1/5;
totallen = 1167;
sampling = 490;
winLenSamp = 14/2; % Temporal window length, in samples; % 33.3ms
allRunData = [];
allTimePoints = [];
timepoints = [];
load('New3Groups_arrange_no_concat_carrier.mat');
for run = 1:4
if run == 1
newData = groupData1;
subjList_short = idx1;
groupname = 1;
elseif run == 2
newData = groupData2;
subjList_short = idx2;
groupname = 2;
elseif run == 3
newData = groupData3;
subjList_short = idx3;
groupname = 3;
elseif run == 4
newData = groupData4;
subjList_short = idx4;
groupname = 4;
end
mdataIn = cellfun(@(x) x*10^6, newData, 'uni', false);
meanData = cellfun(@(x) nanmean(x,3),mdataIn,'uni',false);
comDataIn = combineCells(meanData,2,1);
% time window and merging windows are different from oddball
% use small windows
timewins = [135,157,176,198];
timewinpts = round(timewins*sampling/totallen,0); %time points
for tt = 1:length(timewinpts)
temp = timewinpts(tt);
tprange = [temp-winLenSamp/7:temp+winLenSamp/7];
timepoints(tt,:) = tprange;
end
allTimePoints(run,:,:) = timepoints;
%get group average
timedata = [];
tempdata = comDataIn;
avgtemp = nanmean(cat(3,tempdata{:}),3);
for tt = 1:size(timepoints,1)
temppts = round(timepoints(tt,:),0);
timedata(tt,:) = nanmean(avgtemp(temppts,:),1);
end
allRunData(run,:,:) = timedata; %run x con x nwins x chan
end
nwinpt = size(allTimePoints,3);
%plot 3D topos
figure('position',[300 300 1800 300*4],'color','w')
data = allRunData;
nwin = size(data,2);
ww = 0;
for run = 1:4
for win = 1:nwin
ww = ww + 1;
subplot_tight(4,nwin,ww,[0.08 0.04])
tdata = squeeze(data(run,win,:));
thresh = 2;
%plot topo
if run == 1
titlename = sprintf('%s-%s ms',...
num2str(round(allTimePoints(run,win,1)*1167/490,0)),...
num2str(round(allTimePoints(run,win,nwinpt)*1167/490,0)));
headplot([0 0 0 tdata'], splinefile, 'maplimits', [-thresh thresh], 'title', titlename,...
'colormap', jmaColors('coolhotcortex'), 'electrodes', 'on', 'view', [0 30]);
else
headplot([0 0 0 tdata'], splinefile, 'maplimits', [-thresh thresh],...
'colormap', jmaColors('coolhotcortex'), 'electrodes', 'on', 'view', [0 30]);
end
end
end
%save
if plotOdd
figpath = bbpath;
figname = sprintf('3D-timedomain-definedWins-%d-%dms-topos-%s-scale%d.png',timewins(1),timewins(end),'carrier',thresh);
end
saveas(gcf,fullfile(figpath,figname))
% close