11
11
% 'sourcemodel' - [string] source model file
12
12
%
13
13
% Optional inputs:
14
- % 'measure' - ['psd'|'roipsd'|'trgc'|'crossspecimag'|'crossspecpow'|'mic'|'mim']
15
- % 'psd' : Source power spectrum
16
- % 'psdroi': ROI based power spectrum
17
- % 'trgc' : Time-reversed granger causality
18
- % 'crossspecimag': Imaginary part of coherence from cross-spectrum
19
- % 'crossspecpow' : Average cross-spectrum power for each ROI
20
- % 'mic' : Maximized Imaginary Coherency for each ROI
21
- % 'mim' : Multivariate Interaction Measure for each ROI
22
- % 'freqrange' - [min max] frequency range in Hz. Default is to plot
23
- % broadband power.
24
- % 'smooth' - [float] smoothing factor for cortex surface plotting
25
- % 'plotcortex' - ['on'|'off'] plot results on smooth cortex. Default is 'on'
26
- % 'plotmatrix' - ['on'|'off'] plot results on smooth cortex. Default is 'off'
27
- % 'plotpsd' - ['on'|'off'] plot PSD (for 'crossspecpow' only). Default is 'off'
14
+ % 'measure' - ['psd'|'roipsd'|'trgc'|'crossspecimag'|'crossspecpow'|'mic'|'mim']
15
+ % 'psd' : Source power spectrum
16
+ % 'psdroi': ROI based power spectrum
17
+ % 'trgc' : Time-reversed granger causality
18
+ % 'gc' : Granger causality
19
+ % 'crossspecimag': Imaginary part of coherence from cross-spectrum
20
+ % 'crossspecpow' : Average cross-spectrum power for each ROI
21
+ % 'mic' : Maximized Imaginary Coherency for each ROI
22
+ % 'mim' : Multivariate Interaction Measure for each ROI
23
+ % 'freqrange' - [min max] frequency range in Hz. Default is to plot broadband power.
24
+ % 'smooth' - [float] smoothing factor for cortex surface plotting
25
+ % 'plotcortex' - ['on'|'off'] plot results on smooth cortex. Default is 'on'
26
+ % 'plotcortexparams' - [cell] ...
27
+ % 'plotcortexseedregion' - [string] plot seed voxel on cortex. Takes name of seed region as input.
28
+ % 'plot3d' - ['on'|'off'] ... Default is 'off'
29
+ % 'plot3dparams' - [cell] ...
30
+ % 'plotmatrix' - ['on'|'off'] plot results as ROI to ROI matrix. Default is 'off'
31
+ % 'plotbarplot' - ['on'|'off'] plot ROI based power spectrum as barplot. Default is 'off'
32
+ % 'hemisphere' - ['all'|'left'|'right'] hemisphere options for ROI to ROI matrix. Default is 'all'
33
+ % 'region' - ['all'|'cingulate'|'prefrontal'|'frontal'|'temporal'|'parietal'|'central'|'occipital'] region selection for ROI to ROI matrix. Default is 'all'
34
+ % 'largeplot' - ['on'|'off'] plot MIM, TRGC and Power in a single large plot. Default is 'off'
35
+ % 'plotpsd' - ['on'|'off'] plot PSD (for 'crossspecpow' only). Default is 'off'
28
36
%
29
37
% Author: Stefan Haufe and Arnaud Delorme, 2019
30
38
%
179
187
splot(end ).matrix = - 1 ;
180
188
splot(end ).psd = 0 ;
181
189
end
190
+
182
191
183
192
if nargin < 2
184
193
195
204
' end;' ...
196
205
' end;' ...
197
206
' clear iField fieldTmp usrdat;' ];
198
-
207
+
208
+ fcregions = {' all' , ' cingulate' , ' prefrontal' , ' frontal' , ' temporal' , ' parietal' , ' central' , ' occipital' };
199
209
plotrow = [1 1 ];
200
- uigeom = { [1 1 ] [1 1 ] 1 [1 1 ] plotrow plotrow plotrow plotrow };
210
+ uigeom = { [1 1 ] [1 1 ] 1 [1 1 ] plotrow [ 5 3 2 ] [ 3.5 1.5 1 1 ] plotrow };
201
211
uilist = {{ ' style' ' text' ' string' ' Select a measure to plot' ' fontweight' ' bold' } ...
202
212
{ ' style' ' popupmenu' ' string' {splot .label } ' callback' cb_select ' value' 4 ' tag' ' selection' } ...
203
213
{ ' style' ' text' ' string' ' Frequency range in Hz [min max]:' } ...
210
220
{ ' style' ' edit' ' string' ' '' thresholdper'' , 0.8' ' tag' ' plot3dparams' } ...
211
221
...
212
222
{ ' style' ' checkbox' ' string' ' Connectivity of each area' ' tag' ' cortex' ' value' 1 } ...
213
- { ' style' ' text' ' string' ' ' ' tag' ' cortexparams' } ...
223
+ { ' style' ' text' ' string' ' Index of seed region:' ' fontweight' ' bold' } ...
224
+ { ' style' ' edit' ' string' ' ' ' tag' ' seed_region' } ...
214
225
...
215
- { ' style' ' checkbox' ' string' ' Matrix representation' ' tag' ' matrix' ' enable' ' off' } {} ...
226
+ { ' style' ' checkbox' ' string' ' Matrix representation' ' tag' ' matrix' ' enable' ' off' } ...
227
+ { ' style' ' popupmenu' ' string' fcregions ' callback' cb_select ' value' 3 ' tag' ' region' } ....
228
+ { ' style' ' checkbox' ' string' ' left' ' tag' ' hemisphere_left' ' value' 1 } ...
229
+ { ' style' ' checkbox' ' string' ' right' ' tag' ' hemisphere_right' ' value' 1 } ...
216
230
...
217
231
{ ' style' ' checkbox' ' string' ' Power spectral density' ' tag' ' psd' ' enable' ' off' } {} ...
218
232
};
226
240
options = { options{: } ' freqrange' eval( [ ' [' result{2 } ' ]' ] ) };
227
241
options = { options{: } ' plotcortex' fastif(outs .cortex , ' on' , ' off' ) };
228
242
options = { options{: } ' plotcortexparams' {} };
243
+ options = { options{: } ' plotcortexseedregion' str2num(result{6 }) };
229
244
options = { options{: } ' plotmatrix' fastif(outs .matrix , ' on' , ' off' ) };
230
245
options = { options{: } ' plotpsd' fastif(outs .psd , ' on' , ' off' ) };
231
246
options = { options{: } ' plot3d' fastif(outs .plot3d , ' on' , ' off' ) };
232
247
options = { options{: } ' plot3dparams' eval( [ ' {' outs .plot3dparams ' }' ] ) };
248
+ options = { options{: } ' region' fcregions{result{8 }} };
249
+ % choose which hemisphere to plot
250
+ if outs .hemisphere_left == 1 && outs .hemisphere_right == 0
251
+ options = { options{: } ' hemisphere' ' left' };
252
+ elseif outs .hemisphere_left == 0 && outs .hemisphere_right == 1
253
+ options = { options{: } ' hemisphere' ' right' };
254
+ else
255
+ options = { options{: } ' hemisphere' ' all' };
256
+ end
233
257
else
234
258
options = varargin ;
235
259
end
236
260
237
261
% decode input parameters
238
262
% -----------------------
239
263
g = finputcheck(options , { ' measure' ' string' {splot .acronym } ' ' ;
240
- ' freqrange' ' real' { } [];
241
- ' smooth' ' real' { } 0.35 ;
242
- ' plotcortex' ' string' { ' on' ' off' } ' on' ;
243
- ' plotcortexparams' ' cell' { } {};
244
- ' plot3d' ' string' { ' on' ' off' } ' off' ;
245
- ' plot3dparams' ' cell' { } {};
246
- ' plotmatrix' ' string' { ' on' ' off' } ' off' ;
247
- ' plotbarplot' ' string' { ' on' ' off' } ' off' ;
248
- ' hemisphere' ' string' {' all' ' left' ' right' } ' all' ;
249
- ' region' ' string' { ' all' , ' cingulate' , ' prefrontal' , ' frontal' , ' temporal' , ' parietal' , ' central' , ' occipital' } ' all' ;
250
- ' largeplot' , ' string' { ' on' ' off' } ' off' ;
251
- ' plotpsd' , ' string' { ' on' ' off' } ' off' }, ' pop_roi_connectplot' );
264
+ ' freqrange' ' real' { } [];
265
+ ' smooth' ' real' { } 0.35 ;
266
+ ' plotcortex' ' string' { ' on' ' off' } ' on' ;
267
+ ' plotcortexparams' ' cell' { } {};
268
+ ' plotcortexseedregion' ' integer' { } [];
269
+ ' plot3d' ' string' { ' on' ' off' } ' off' ;
270
+ ' plot3dparams' ' cell' { } {};
271
+ ' plotmatrix' ' string' { ' on' ' off' } ' off' ;
272
+ ' plotbarplot' ' string' { ' on' ' off' } ' off' ;
273
+ ' hemisphere' ' string' {' all' ' left' ' right' } ' all' ;
274
+ ' region' ' string' { ' all' , ' cingulate' , ' prefrontal' , ' frontal' , ' temporal' , ' parietal' , ' central' , ' occipital' } ' all' ;
275
+ ' largeplot' , ' string' { ' on' ' off' } ' off' ;
276
+ ' plotpsd' , ' string' { ' on' ' off' } ' off' }, ' pop_roi_connectplot' );
252
277
if ischar(g ), error(g ); end
253
278
S = EEG .roi ;
254
279
285
310
MI = get_connect_mat( MI , S .nROI , + 1 );
286
311
MIM_matrix = squeeze(mean(MI(frq_inds , : , : )));
287
312
288
- pltlarge (EEG , MIM_matrix , TRGC_matrix , source_roi_power_norm_dB , titleStr )
313
+ roi_largeplot (EEG , MIM_matrix , TRGC_matrix , source_roi_power_norm_dB , titleStr )
289
314
else
290
315
switch lower(g .measure )
291
316
case { ' psd' ' roipsd' }
307
332
308
333
if strcmpi(g .plotbarplot , ' on' )
309
334
source_roi_power_norm_dB = 10 * log10( mean(EEG .roi .source_roi_power(frq_inds ,: )) );
310
- pltmatrix (EEG , source_roi_power_norm_dB , titleStr , g .measure , g .hemisphere , g .region );
335
+ roi_plotcoloredlobes (EEG , source_roi_power_norm_dB , titleStr , g .measure , g .hemisphere , g .region );
311
336
end
312
337
313
338
case { ' trgc' ' gc' }
314
339
% calculation of net TRGC scores (i->j minus j->i), recommended procedure
315
340
% TRGCnet = TRGC_(:, 1:2:end)-TRGC_(:, 2:2:end);
316
341
% new way to compute net scores
317
342
if strcmpi(g .measure , ' GC' )
318
- % TRGCnet = S.GC;
343
+ % TRGCnet = S.GC;
319
344
TRGCnet = S .GC(: , : , 1 ) - S .GC(: , : , 2 );
320
345
else
321
- % TRGCnet = S.TRGC;
346
+ % TRGCnet = S.TRGC;
322
347
TRGCnet = S .TRGC(: , : , 1 ) - S .TRGC(: , : , 2 );
323
348
end
324
349
% TRGCnet = TRGCnet - permute(TRGCnet, [1 3 2]);
325
350
% TRGCnet = TRGCnet(:,:);
326
- % TRGCnet = S.GC(:, :, 1) - S.GC(:, :, 2);
351
+ % TRGCnet = S.GC(:, :, 1) - S.GC(:, :, 2);
327
352
TRGC = get_connect_mat( TRGCnet , S .nROI , - 1 );
328
353
329
354
if strcmpi(g .plotmatrix , ' on' )
330
355
matrix = squeeze(mean(TRGC(frq_inds , : , : )));
331
- pltmatrix (EEG , matrix , titleStr , g .measure , g .hemisphere , g .region );
356
+ roi_plotcoloredlobes (EEG , matrix , titleStr , g .measure , g .hemisphere , g .region );
332
357
end
333
358
334
359
if strcmpi(g .plot3d , ' on' )
337
362
end
338
363
339
364
if strcmpi(g .plotcortex , ' on' )
340
- atrgc = mean(squeeze(mean(TRGC(frq_inds , : , : ))), 2 );
341
- allplots_cortex_BS(S .cortex , atrgc , [-max(abs(atrgc )) max(abs(atrgc ))], cm17 , upper(g .measure ), g .smooth );
365
+ if isempty(g .plotcortexseedregion )
366
+ atrgc = mean(squeeze(mean(TRGC(frq_inds , : , : ))), 2 );
367
+ allplots_cortex_BS(S .cortex , atrgc , [-max(abs(atrgc )) max(abs(atrgc ))], cm17 , upper(g .measure ), g .smooth );
368
+ movegui(gcf , ' south' )
369
+ else
370
+ [coordinate , seed_idx ] = get_seedregion_coordinate(EEG .roi .atlas .Scouts , g .plotcortexseedregion , EEG .roi .cortex .Vertices );
371
+ atrgc = squeeze(mean(TRGC(frq_inds , seed_idx , : )));
372
+ allplots_cortex_BS(S .cortex , atrgc , [-max(abs(atrgc )) max(abs(atrgc ))], cm17 , upper(g .measure ), g .smooth , [], {coordinate });
373
+ movegui(gcf , ' south' )
374
+ end
342
375
h = textsc([ upper(g .measure ) ' (' titleStr ' ); Red = net sender; Blue = net receiver' ], ' title' );
343
376
set(h , ' fontsize' , 20 );
344
377
end
353
386
354
387
if strcmpi(g .plotmatrix , ' on' )
355
388
matrix = squeeze(mean(MI(frq_inds , : , : )));
356
- pltmatrix (EEG , matrix , titleStr , g .measure , g .hemisphere , g .region );
389
+ roi_plotcoloredlobes (EEG , matrix , titleStr , g .measure , g .hemisphere , g .region );
357
390
end
358
391
359
392
if strcmpi(g .plotcortex , ' on' )
360
- ami = mean(squeeze(mean(MI(frq_inds , : , : ))), 2 );
361
- allplots_cortex_BS(S .cortex , ami , [min(ami ) max(ami )], cm17 , upper(g .measure ), g .smooth );
362
- h = textsc([ upper(g .measure ) ' (' titleStr ' ); Red = net sender; Blue = net receiver' ], ' title' );
393
+ if isempty(g .plotcortexseedregion )
394
+ ami = mean(squeeze(mean(MI(frq_inds , : , : ))), 2 );
395
+ allplots_cortex_BS(S .cortex , ami , [min(ami ) max(ami )], cm17a , upper(g .measure ), g .smooth );
396
+ else
397
+ [coordinate , seed_idx ] = get_seedregion_coordinate(EEG .roi .atlas .Scouts , g .plotcortexseedregion , EEG .roi .cortex .Vertices );
398
+ ami = squeeze(mean(MI(frq_inds , seed_idx ,: )));
399
+ allplots_cortex_BS(S .cortex , ami , [min(ami ) max(ami )], cm17a , upper(g .measure ), g .smooth , [], {coordinate });
400
+ end
401
+ h = textsc([ upper(g .measure ) ' (' titleStr ' ) ' ], ' title' );
363
402
set(h , ' fontsize' , 20 );
364
403
end
365
404
427
466
end
428
467
end
429
468
end
469
+
470
+ function [coordinate , seed_idx ] = get_seedregion_coordinate(scouts , seed_idx , vc )
471
+ % determine voxel of selected seed region, if needed
472
+ % assign region index to selected seed region (passed as index)
473
+ if ~isempty(seed_idx )
474
+ % ball not visible for these regions when plotting the mean voxel
475
+ manual_region_idxs = [2 , 16 , 18 , 25 , 26 , 31 , 32 , 45 , 49 , 50 , 55 , 56 , 59 , 60 , 61 , 64 ];
476
+ pos_idx = scouts(seed_idx ).Vertices;
477
+ pos = vc(pos_idx ,: );
478
+ if seed_idx == 1
479
+ coordinate = vc(736 ,: );
480
+ elseif ismember(seed_idx , manual_region_idxs )
481
+ pos_sorted = sortrows(pos , 3 , ' descend' ); % sort by descending Z-coordinate
482
+ coordinate = pos_sorted(1 ,: );
483
+ else
484
+ mid_point = mean(pos ,1 );
485
+ [~ ,closest_pos_idx ] = min(eucl(mid_point , pos )); % determine mean voxel
486
+ coordinate = pos(closest_pos_idx ,: );
487
+ end
488
+ else
489
+ error(' Selected region not in cortex' )
490
+ end
491
+ end
430
492
431
- function pltmatrix ( EEG , matrix , titleStr , measure , hemisphere , region )
432
- % plot individual ROI to ROI matrix with colored labels (corresponding lobes/regions)
493
+ function roi_plotcoloredlobes ( EEG , matrix , titleStr , measure , hemisphere , region )
494
+ % plot matrix with colored labels sorted by region according to the Desikan-Killiany atlas
433
495
load cm17
434
496
switch lower(measure )
435
497
case {' mim' , ' mic' , ' coh' }
@@ -438,7 +500,7 @@ function pltmatrix( EEG, matrix, titleStr, measure, hemisphere, region)
438
500
cmap = cm17 ;
439
501
end
440
502
441
- % plot matrix with colored labels sorted by region according to the Desikan-Killiany atlas
503
+ % retrieve labels from atlas
442
504
labels = strings(1 ,length(EEG .roi .atlas .Scouts ));
443
505
for i = 1 : length(labels )
444
506
scout = struct2cell(EEG .roi .atlas .Scouts(i ));
@@ -514,6 +576,15 @@ function pltmatrix( EEG, matrix, titleStr, measure, hemisphere, region)
514
576
color_idxx = color_idxx(start_idx : end_idx );
515
577
end
516
578
n_roi_labels = size(matrix , 1 ); % only 68 if no region is selected
579
+
580
+ % hemisphere parameters to determine which labels to use
581
+ if strcmpi(hemisphere , ' left' )
582
+ hem_idx = {1 2 2 }; % use labels 1:2:68 (first two values), only use 1/2 of the labels (3rd value)
583
+ elseif strcmpi(hemisphere , ' right' )
584
+ hem_idx = {2 2 2 }; % use labels 2:2:68 (first two values), only use 1/2 of the labels (3rd value)
585
+ else
586
+ hem_idx = {1 1 1 }; % use labels 1:1:68 (first two values, all labels), use 1/1 of the labels (3rd value, all labels)
587
+ end
517
588
518
589
% create dummy plot and add custom legend
519
590
f = figure();
@@ -525,15 +596,6 @@ function pltmatrix( EEG, matrix, titleStr, measure, hemisphere, region)
525
596
plot(x , x * k , ' -' , ' LineWidth' , 9 , ' Color' , colors{k });
526
597
end
527
598
528
- % hemisphere parameters to determine which labels to use
529
- if strcmpi(hemisphere , ' left' )
530
- hem_idx = {1 2 2 }; % use labels 1:2:68 (first two values), only use 1/2 of the labels (3rd value)
531
- elseif strcmpi(hemisphere , ' right' )
532
- hem_idx = {2 2 2 }; % use labels 2:2:68 (first two values), only use 1/2 of the labels (3rd value)
533
- else
534
- hem_idx = {1 1 1 }; % use labels 1:1:68 (first two values, all labels), use 1/1 of the labels (3rd value, all labels)
535
- end
536
-
537
599
% labels on dummy plot for positioning
538
600
xlim([0 n_roi_labels ])
539
601
ylim([0 n_roi_labels ])
@@ -575,7 +637,7 @@ function pltmatrix( EEG, matrix, titleStr, measure, hemisphere, region)
575
637
end
576
638
end
577
639
578
- function pltlarge (EEG , mim , trgc , roipsd , titleStr )
640
+ function roi_largeplot (EEG , mim , trgc , roipsd , titleStr )
579
641
% plot MIM, TRGC and power (barplot) in a single large figure
580
642
load cm17
581
643
0 commit comments