-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsensorplot_defineConditions.m
324 lines (265 loc) · 12.2 KB
/
sensorplot_defineConditions.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
function [chans, conditions] = sensorplot_defineConditions(labels, computeContrasts, sj, session)
% make a grand average of all the TFRs across subjects, and find which
% sensors to use for max visual gamma, motor beta suppression and feedback theta
% ==================================================================
% define conditions
% ==================================================================
cnt = 1;
conditions(cnt).name = {'all'};
conditions(cnt).timewin = {[-0.2 0], 1}; % baseline interval
conditions(cnt).freqwin = [2 120];
conditions(cnt).crange = [-10 10];
% all parameters from Siegel et al. 2006 - sensory evidence, occipital gamma
cnt = cnt + 1;
conditions(cnt).name = {'stimstrong', 'stimweak'};
conditions(cnt).timewin = {[0.15 0.75], 2}; % stim interval
conditions(cnt).freqwin = [65 95]; % avoid SSVEP
conditions(cnt).crange = [-2 2];
% There is a very clear relative suppression with a minimum somewhere around 10 Hz
% in the strong - weak difference spectrum. This has escaped my attention so far,
% but it is much in line with what Markus and I found back then and might be a very
% interesting additional canditate for top-down effects. So, all visual cortex analyses
% should be done on this band, as well as on the gamma part above the SSVEP.
% (Note that the spectral profile of this sensory power suppression effect differs
% slightly from the overall task induced response, which I find quite interesting)
% email Tobi 27.06.2017
% cnt = cnt + 1;
% conditions(cnt).name = {'stimstrong', 'stimweak'};
% conditions(cnt).timewin = {[0.15 0.75], 2}; % stim interval
% conditions(cnt).freqwin = [8 12]; % alpha
% conditions(cnt).crange = [-4 4];
% all parameters from Donner et al. 2009 - beta buildup
cnt = cnt + 1;
conditions(cnt).name = {'left', 'right'};
conditions(cnt).timewin = {[-0.25 0], 3}; % resp interval
conditions(cnt).freqwin = [12 36];
conditions(cnt).crange = [-25 25];
% % correct vs error - theta, after feedback
% cnt = cnt + 1;
% conditions(cnt).name = {'error', 'correct'};
% conditions(cnt).timewin = {[0.2 0.7], 4}; %% after response, uncertainty
% conditions(cnt).freqwin = [8 12]; % alpha
% conditions(cnt).crange = [-40 40];
% previous choice leads to higher visual gammma
cnt = cnt + 1;
conditions(cnt).name = {'prev_respstrong', 'prev_respweak'};
conditions(cnt).timewin = {[0 0.75], 1}; % reference interval
conditions(cnt).freqwin = [65 95];
conditions(cnt).crange = [-1 1];
% replicate Pape & Siegel Figure 3A
cnt = cnt + 1;
conditions(cnt).name = {'prev_left', 'prev_right'};
conditions(cnt).timewin = {[-0.25 0], 1}; % reference interval
conditions(cnt).freqwin = [12 36];
conditions(cnt).crange = [-10 10];
%
% % previous choice leads to higher visual alpha
% cnt = cnt + 1;
% conditions(cnt).name = {'alternation', 'repetition'};
% conditions(cnt).timewin = {[-0.1 1], 3}; % reference interval
% conditions(cnt).freqwin = [5 25]; % refine
% conditions(cnt).crange = [-8 8];
% previous choice leads to higher visual gammma
cnt = cnt + 1;
conditions(cnt).name = {'prev_respstrong', 'prev_respweak'};
conditions(cnt).timewin = {[-0.25 1], 1}; % reference interval
conditions(cnt).freqwin = [100 110];
conditions(cnt).crange = [-2 2];
% previous choice leads to higher visual gammma
cnt = cnt + 1;
conditions(cnt).name = {'prev_respstrong', 'prev_respweak'};
conditions(cnt).timewin = {[-0.25 1], 1}; % reference interval
conditions(cnt).freqwin = [60 70];
conditions(cnt).crange = [-2 2];
cnt = cnt + 1;
conditions(cnt).name = {'prev_respstrong', 'prev_respweak'};
conditions(cnt).timewin = {[-0.25 0.25], 1}; % reference interval
conditions(cnt).freqwin = [10 20];
conditions(cnt).crange = [-2 2];
cnt = cnt + 1;
conditions(cnt).name = {'prev_respstrong', 'prev_respweak'};
conditions(cnt).timewin = {[1 1.25], 1}; % reference interval
conditions(cnt).freqwin = [10 20];
conditions(cnt).crange = [-2 2];
% cnt = cnt + 1;
% conditions(cnt).name = {'prev_respstrong', 'prev_respweak'};
% conditions(cnt).timewin = {[-1 1.25], 1}; % reference interval
% conditions(cnt).freqwin = [10 20];
% conditions(cnt).crange = [-2 2];
% ==================================================================
% POz - one EEG channel
% ==================================================================
if nargin == 0,
chans = [];
else
if ~exist('computeContrasts', 'var'); computeContrasts = false; end
if computeContrasts,
% load pre-computed cluster statistics
subjectdata = subjectspecifics('ga');
load(sprintf('%s/%s-S%d_sensorDefinition.mat', ...
subjectdata.statsdir, 'GAclean', -1*(session-1)+2));
end
if ~exist('labels', 'var') || isempty(labels),
subjectdata = subjectspecifics(sj);
load(sprintf('%s/P%02d-S%d_bl_ref.mat', subjectdata.tfrdir, sj, session));
labels = freq.label;
end
cnt = 1;
% ==================================================================
% OCCIPITAL
% ==================================================================
chans(cnt).group = 'occipital';
if computeContrasts,
% from stats
chans(cnt).names = sensorDefinition(1).names;
else
% all occipital chans
chans(cnt).names = labels(find(~cellfun(@isempty, strfind(labels, 'O'))));
end
chans(cnt).sens = findChanIdx(chans(cnt).names, labels);
% ==================================================================
% MOTOR
% ==================================================================
cnt = cnt + 1;
chans(cnt).group = 'motor';
if computeContrasts,
% get sensors that participate in left vs right cluster
rightchans.names = sensorDefinition(2).rightchans;
leftchans.names = sensorDefinition(2).leftchans;
else
rightchans.names = labels(find(~cellfun(@isempty, strfind(labels, 'RC'))));
leftchans.names = labels(find(~cellfun(@isempty, strfind(labels, 'LC'))));
end
rightchans.sens = findChanIdx(rightchans.names, labels);
leftchans.sens = findChanIdx(leftchans.names, labels);
chans(cnt).names = [leftchans.names; rightchans.names];
chans(cnt).sens = findChanIdx(chans(cnt).names, labels);
% ==================================================================
% LATERALISATION, VIRTUAL CHANNEL WILL BE CREATED
% ==================================================================
cnt = cnt + 1;
chans(cnt).group = 'lateralisation';
chans(cnt).names = 'lat';
chans(cnt).sens = length(labels) + 1;
chans(cnt).leftchans = leftchans;
chans(cnt).rightchans = rightchans;
% ==================================================================
% LEFT + RIGHT SEPARATELY
% ==================================================================
cnt = cnt + 1;
chans(cnt).group = 'motorleft';
chans(cnt).names = leftchans.names;
chans(cnt).sens = leftchans.sens;
cnt = cnt + 1;
chans(cnt).group = 'motorright';
chans(cnt).names = rightchans.names;
chans(cnt).sens = rightchans.sens;
% ==================================================================
% PARIETAL
% ==================================================================
cnt = cnt + 1;
chans(cnt).group = 'parietal';
% remove those that are already in the occipital or motor cluster
l = labels(find(~cellfun(@isempty, strfind(labels, 'P'))));
[~, duplicateSensory] = intersect(l, chans(1).names);
[~, duplicateMotor] = intersect(l, chans(2).names);
l(sort([duplicateSensory; duplicateMotor])) = [];
chans(cnt).names = l;
chans(cnt).sens = findChanIdx(chans(cnt).names, labels);
% ==================================================================
% CENTRAL
% ==================================================================
cnt = cnt + 1;
chans(cnt).group = 'central';
% remove those that are already in the occipital or motor cluster
l = labels(find(~cellfun(@isempty, strfind(labels, 'C'))));
[~, duplicateSensory] = intersect(l, chans(1).names);
[~, duplicateMotor] = intersect(l, chans(2).names);
l(sort([duplicateSensory; duplicateMotor])) = [];
chans(cnt).names = l;
chans(cnt).sens = findChanIdx(chans(cnt).names, labels);
% ==================================================================
% FRONTAL
% ==================================================================
cnt = cnt + 1;
chans(cnt).group = 'frontal';
% remove those that are already in the occipital or motor cluster
l = labels(find(~cellfun(@isempty, strfind(labels, 'F'))));
[~, duplicateSensory] = intersect(l, chans(1).names);
[~, duplicateMotor] = intersect(l, chans(2).names);
l(sort([duplicateSensory; duplicateMotor])) = [];
chans(cnt).names = l;
chans(cnt).sens = findChanIdx(chans(cnt).names, labels);
% ==================================================================
% ALL OCCIPITAL
% ==================================================================
cnt = cnt + 1;
chans(cnt).group = 'occipital_all';
% all occipital chans
chans(cnt).names = labels(find(~cellfun(@isempty, strfind(labels, 'O'))));
chans(cnt).sens = findChanIdx(chans(cnt).names, labels);
% ==================================================================
% POz
% ==================================================================
% try
%
% cnt = cnt + 1;
% chans(cnt).group = 'POz';
% chans(cnt).names = labels(find(~cellfun(@isempty, strfind(labels, 'POz'))));
% chans(cnt).sens = findChanIdx(chans(cnt).names, labels);
% assert(~isempty(chans(cnt).sens), 'could not find POz channel');
%
% cnt = cnt + 1;
% % all occipital chans
% chans(cnt).group = 'POz_unfiltered';
% chans(cnt).names = labels(find(~cellfun(@isempty, strfind(labels, 'POz_unfiltered'))));
% chans(cnt).sens = findChanIdx(chans(cnt).names, labels);
% assert(~isempty(chans(cnt).sens), 'could not find POz channel');
% catch
% cnt = cnt - 1; % ignore for TFRs
% end
% ==================================================================
% PLOT TOPOGRAPHY
% ==================================================================
if 0,
load('~/Documents/fieldtrip/template/layout/CTF275_helmet.mat');
lay.outline = lay.outline([1 3:end]); % remove outer bound
clf;
cfg = [];
cfg.marker = 'off';
cfg.layout = lay;
cfg.comment = 'no';
usegroups = find(cellfun(@isempty, (strfind({chans(:).group}, 'lateralisation'))));
cfg.highlightchannel = {chans(usegroups).names};
cfg.highlight = {chans(usegroups).group};
cfg.highlightsymbol = repmat({'.'}, 1, numel(usegroups));
cfg.highlightsize = repmat({20}, 1, numel(usegroups));
% give every changroup its own color
colors = linspecer(numel(usegroups)); highlightcolor = {};
for g = 1:length(usegroups),
highlightcolor = [highlightcolor; {colors(g, :)}];
end
cfg.highlightcolor = highlightcolor;
cfg.renderer = 'painters';
cfg.style = 'blank';
% plot the thing
sj = 2;
subjectdata = subjectspecifics(sj);
load(sprintf('%s/P%02d-S%d_bl_ref_all.mat', subjectdata.tfrdir, sj, session));
ft_topoplotER(cfg, freq);
prettierTopoCTF275;
print(gcf, '-dpdf', sprintf('%s/Figures/sensors_S%d.pdf', subjectdata.path, session));
end
end
end % function
% ==================================================================
% subfunction to get channel name indices
% ==================================================================
function idx = findChanIdx(names, labels)
% finds the numbers of specific channel labels
idx = [];
for n = 1:length(names),
i = find(strcmp(names{n}, labels));
idx = [idx i];
end
end