-
Notifications
You must be signed in to change notification settings - Fork 6
/
create_tab_source_modeling.m
747 lines (722 loc) · 77.3 KB
/
create_tab_source_modeling.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
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
function create_tab_source_modeling
% create a tab for performing source modeling
global h
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %%%%% Tab "Source Modeh.axes_source_wavesling" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
h.tab_source_modeling = uitab(h.tabgrp,'Title','Source Modeling','BackgroundColor',[1 1 1],'Foregroundcolor',[1 .3 .5]);
%% %%%%% Panel "Inverse Modeling" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% delete(h.panel_inv_soln);
h.panel_inv_soln = uipanel(h.tab_source_modeling,'Title','Inverse Modeling','FontSize',10,'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor',[0 0 0],...
'Units','normalize','Position',[.005 .795 .99 .2],'Visible','on');
%% menu inv solns
h.menu_inv_soln_txt = uicontrol(h.panel_inv_soln,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[.005 .75 .065 .2],...
'FontSize',10,'HorizontalAlignment','right','String','Inverse Solution');
h.menu_inv_soln = uicontrol(h.panel_inv_soln,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','popupmenu','Units','normalize',...
'Position',[sum(h.menu_inv_soln_txt.Position([1 3]))+.01 h.menu_inv_soln_txt.Position(2) .08 .25],...
'FontSize',8,'HorizontalAlignment','center','String',{'SPA' 'SIA' 'MIA' 'Dipole' 'LCMV (BST)' 'MNE (BST)' 'sLORETA (BST)' 'LCMV (FT)' 'MNE (FT)' 'sLORETA (FT)' 'eLORETA (FT)' 'dics (FT)' 'pcc (FT)' 'sMCMV' 'bRAPBeam' 'TrapMUSIC'},...
'Value',1,'Callback',@menu_inv_soln_txt_Callback);
% h.menu_inv_soln.String = {'SPA' 'SIA' 'MIA' 'LCMV (BST)' 'MNE (BST)' 'sLORETA (BST)' 'LCMV (FT)' 'MNE (FT)' 'sLORETA (FT)' 'eLORETA (FT)' 'SAM (FT)'};
h.menu_inv_soln.String = {'SPA' 'SIA' 'MIA' 'Dipole' 'LCMV (BST)' 'MNE (BST)' 'sLORETA (BST)' 'LCMV (FT)' 'MNE (FT)' 'sLORETA (FT)' 'eLORETA (FT)' 'SAM (FT)'};
% {'SPA' 'SIA' 'MIA' 'LCMV' 'eLORETA' 'sLORETA' 'MNE' 'dics' 'pcc' 'sMCMV' 'bRAPBeam' 'TrapMUSIC'}
%% Edit active & control intervals
% control interval
h.edit_ctrl_int_txt = uicontrol(h.panel_inv_soln,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[sum(h.menu_inv_soln.Position([1 3]))+.005 h.menu_inv_soln_txt.Position(2) .08 h.menu_inv_soln_txt.Position(4)],...
'FontSize',10,'HorizontalAlignment','right','String','Control Interval (sec)');
h.edit_ctrl_int = uicontrol(h.panel_inv_soln,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','edit','Units','normalize',...
'Position',[sum(h.edit_ctrl_int_txt.Position([1 3]))+.005 h.menu_inv_soln_txt.Position(2)+.05 .035 .2],...
'Tag','TFR Frequency Range','FontSize',10,'HorizontalAlignment','center','String','-0.5 0','Callback',@set_source_cfg);
% active interval
h.edit_act_int_txt = uicontrol(h.panel_inv_soln,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[sum(h.edit_ctrl_int.Position([1 3]))+.005 h.menu_inv_soln_txt.Position(2) .08 .2],...
'FontSize',10,'HorizontalAlignment','right','String','Active Interval (sec)');
h.edit_act_int = uicontrol(h.panel_inv_soln,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','edit','Units','normalize',...
'Position',[sum(h.edit_act_int_txt.Position([1 3]))+.005 h.menu_inv_soln_txt.Position(2)+.05 .035 .2],...
'Tag','TFR Frequency Range','FontSize',10,'HorizontalAlignment','center','String','0 0.25','Callback',@set_source_cfg);
%% Edit: noise alpha
h.edit_SPA_noise_alpha_txt = uicontrol(h.panel_inv_soln,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[sum(h.edit_act_int.Position([1 3]))+.005 h.menu_inv_soln_txt.Position(2) .05 .2],...
'FontSize',10,'HorizontalAlignment','right','String','Noise Alpha');
h.edit_SPA_noise_alpha = uicontrol(h.panel_inv_soln,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','edit','Units','normalize',...
'Position',[sum(h.edit_SPA_noise_alpha_txt.Position([1 3]))+.005 h.menu_inv_soln_txt.Position(2)+.05 .025 .2],...
'FontSize',10,'HorizontalAlignment','center','String','0.05');
%% Menu Head Model
h.menu_inv_headmodel_txt = uicontrol(h.panel_inv_soln,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[sum(h.edit_SPA_noise_alpha.Position([1 3]))+.005 h.menu_inv_soln_txt.Position(2) .08 .2],...
'FontSize',10,'HorizontalAlignment','right','String','Inverse Head Model');
h.menu_inv_headmodel = uicontrol(h.panel_inv_soln,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','popupmenu','Units','normalize',...
'Position',[sum(h.menu_inv_headmodel_txt.Position([1 3]))+.005 h.menu_inv_headmodel_txt.Position(2)+.05 .07 .2],...
'FontSize',8,'HorizontalAlignment','center','String',{'Volume' 'Cortical Surface'},'Value',1,'Callback',@menu_inv_headmodel_CallBack);
%% Menu: Inverse Model Orientations normal to surface
h.menu_inv_ori_normal_txt = uicontrol(h.panel_inv_soln,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[sum(h.menu_inv_headmodel.Position([1 3]))+.005 h.menu_inv_headmodel_txt.Position(2) .09 .25],...
'FontSize',10,'HorizontalAlignment','left','String','Orientation Constraint');
h.menu_inv_ori_normal = uicontrol(h.panel_inv_soln,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*.5,'Style','popupmenu','Units','normalize',...
'Position',[sum(h.menu_inv_ori_normal_txt.Position([1 3]))+.005 h.menu_inv_headmodel.Position(2) .09 .2],'Enable','inactive',...
'FontSize',8,'HorizontalAlignment','center','String',{'Random' 'Cortical Surface'},'Value',1,'Callback',@menu_inv_ori_normal_CallBack);
%% Btn Run Inverse Modeling
h.btn_run_source_modeling = uicontrol(h.panel_inv_soln,'BackgroundColor',[1 1 1]*.9,'ForegroundColor',h.src_clr(1,:),'Style','pushbutton','Units','normalize',...
'Position',[.91 h.txt_row_pos(1) .08 h.ui_height],'Visible','on','UserData',1,...
'FontSize',10,'HorizontalAlignment','center','String','Run Modeling','Callback',@run_source_modeling);
%% %%% Sub-Panels for specific Inv Soln SPA, SIA, MIA %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Sub-Panel: "SPA, SIA, MIA Parameters"
% delete(h.panel_SPA_params);
h.panel_SPA_params = uipanel(h.panel_inv_soln ,'Title','SPA Parameters','FontSize',10,'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor',[0 0 0],...
'Units','normalize','Position',[.005 .01 .38 .75],'Visible','on');
%% Menu: SPA loc flag
h.menu_SPA_loc_flag_txt = uicontrol(h.panel_SPA_params,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[.01 .74 .25 .25],...
'FontSize',10,'HorizontalAlignment','left','String','Localization Type');
h.menu_SPA_loc_flag = uicontrol(h.panel_SPA_params,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','popupmenu','Units','normalize',...
'Position',[sum(h.menu_SPA_loc_flag_txt.Position([1 3]))+.01 h.menu_SPA_loc_flag_txt.Position(2) .2125 .25],...
'FontSize',8,'HorizontalAlignment','center','String',{'pseudo Z' 'event-related' 'reduced event-related' 'activity index'},'Value',1);
%% Edit: Whitening Data
% h.edit_SPA_perc_whiten_data_txt = uicontrol(h.panel_SPA_params,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
% 'Position',[.01 h.edit_SPA_noise_alpha.Position(2)-.4 .225 .25],'Visible','on',...
% 'FontSize',10,'HorizontalAlignment','left','String','Percent Data Whitening');
% h.edit_SPA_perc_whiten_data = uicontrol(h.panel_SPA_params,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','edit','Units','normalize',...
% 'Position',[h.menu_SPA_loc_flag.Position(1) h.edit_SPA_perc_whiten_data_txt.Position(2) .1 h.edit_SPA_noise_alpha.Position(4)],'Visible','on',...
% 'FontSize',10,'HorizontalAlignment','center','String','0','Tooltip','If insufficient data rank: Diagonal whitening covariance matrices with this percentage of max(Cov)');
%% Edit: Max Number Sources
h.edit_SPA_max_sources_txt = uicontrol(h.panel_SPA_params,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[.01 h.edit_SPA_noise_alpha.Position(2)-.4 .225 h.edit_SPA_noise_alpha.Position(4)],'Visible','off',...
'FontSize',10,'HorizontalAlignment','left','String','Max # Sources');
h.edit_SPA_max_sources = uicontrol(h.panel_SPA_params,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','edit','Units','normalize',...
'Position',[h.menu_SPA_loc_flag.Position(1) h.edit_SPA_max_sources_txt.Position(2) .1 h.edit_SPA_noise_alpha.Position(4)],'Visible','off',...
'FontSize',10,'HorizontalAlignment','center','String','12','Tooltip','SIA/MIA loops will stop finding sources after Maximum # Sources are found');
%% Brainstorm's LCMV, sLORETA, MNE params %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
xsize=.22; ysize=.225; ypos=[.75 .4 .1]; xpos=[.01 .35 .7];
%% Sub-Panel: "Brainstorm Parameters"
% delete(h.panel_inv_bst_params)
h.panel_inv_bst_params = uipanel(h.panel_inv_soln ,'Title','BrainStorm Parameters','FontSize',10,'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor',[0 0 0],...
'Units','normalize','Position',[.005 .01 .38 .75],'Visible','off');
%% Radio: Depth weighting
h.radio_inv_bst_depth_weight = uicontrol(h.panel_inv_bst_params,'Style','radiobutton', 'BackgroundColor',h.panel_inv_bst_params.BackgroundColor,'Foregroundcolor',[0 0 0],'Units','normalize',...
'Position',[xpos(1) ypos(2) xsize ysize],...
'FontSize',9,'HorizontalAlignment','left','String','Depth Weighting:','Value',1,'Callback',@menu_inv_soln_txt_Callback);
%% Edit: "Order" for depth weighting
h.edit_inv_bst_depth_order_txt = uicontrol(h.panel_inv_bst_params,'Style','text', 'BackgroundColor',h.panel_inv_bst_params.BackgroundColor,'Foregroundcolor','k','Units','normalize',...
'Position',[xpos(1)+xsize+.01 ypos(2) xsize-.06 ysize],...
'FontSize',10,'HorizontalAlignment','left','String','Order [0,1]:');
h.edit_inv_bst_depth_order = uicontrol(h.panel_inv_bst_params,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','edit','Units','normalize',...
'Position',[sum(h.edit_inv_bst_depth_order_txt.Position([1 3]))-.005 ypos(2) .05 ysize],...
'FontSize',10,'HorizontalAlignment','center','String','0.5',...
'Tooltip',sprintf('Depth Weighting Order'));
%% Edit: "Max" for depth weighting
h.edit_inv_bst_depth_max_txt = uicontrol(h.panel_inv_bst_params,'Style','text', 'BackgroundColor',h.panel_inv_bst_params.BackgroundColor,'Foregroundcolor','k','Units','normalize',...
'Position',[sum(h.edit_inv_bst_depth_order.Position([1 3]))+.01 ypos(2) .06 ysize],...
'FontSize',10,'HorizontalAlignment','left','String','Max:');
h.edit_inv_bst_depth_max = uicontrol(h.panel_inv_bst_params,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','edit','Units','normalize',...
'Position',[sum(h.edit_inv_bst_depth_max_txt.Position([1 3]))+.005 ypos(2) .05 ysize],...
'FontSize',10,'HorizontalAlignment','center','String','10',...
'Tooltip',sprintf('Depth Weighting maximum amount'));
%% Menu: "Regularize Noise"
h.menu_inv_bst_reg_noise_type_txt = uicontrol(h.panel_inv_bst_params,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[xpos(1) ypos(1) xsize+.025 ysize],...
'FontSize',10,'HorizontalAlignment','left','String','Regularize NoiseCov:');
h.menu_inv_bst_reg_noise_type = uicontrol(h.panel_inv_bst_params,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','popupmenu','Units','normalize',...
'Position',[sum(h.menu_inv_bst_reg_noise_type_txt.Position([1 3])) ypos(1) xsize-.025 ysize],...
'FontSize',8,'HorizontalAlignment','center','String',{'Regularize' 'Median eigenvalue' 'Diagonal' 'None' 'Automatic shrinkage'},'Value',1,'Callback',@menu_inv_soln_txt_Callback);
%% Edit: Regularize factor
h.edit_inv_bst_reg_noise_factor_txt = uicontrol(h.panel_inv_bst_params,'Style','text', 'BackgroundColor',h.panel_inv_bst_params.BackgroundColor,'Foregroundcolor','k','Units','normalize',...
'Position',[sum(h.menu_inv_bst_reg_noise_type.Position([1 3]))+.005 ypos(1) .04 ysize],...
'FontSize',10,'HorizontalAlignment','right','String','by:');
h.edit_inv_bst_reg_noise_factor = uicontrol(h.panel_inv_bst_params,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','edit','Units','normalize',...
'Position',[h.edit_inv_bst_depth_max.Position(1) ypos(1) h.edit_inv_bst_depth_max.Position(3:4)],...
'FontSize',10,'HorizontalAlignment','center','String','0.1',...
'Tooltip',sprintf('Noise Covariance Regularization Amount'));
%% Edit: Regularization Parameter: 1/lambda
h.edit_inv_bst_reg_lambda_snr_txt = uicontrol(h.panel_inv_bst_params,'Style','text', 'BackgroundColor',h.panel_inv_bst_params.BackgroundColor,'Foregroundcolor','k','Units','normalize',...
'Position',[xpos(1) ypos(3) 2.25*xsize ysize],...
'FontSize',10,'HorizontalAlignment','right','String',sprintf('Reg. Param. (1/lambda): Signal-to-Noise Ratio (%%):'));
h.edit_inv_bst_reg_lambda_snr = uicontrol(h.panel_inv_bst_params,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','edit','Units','normalize',...
'Position',[h.edit_inv_bst_depth_max.Position(1) ypos(3) h.edit_inv_bst_depth_max.Position(3:4)],...
'FontSize',10,'HorizontalAlignment','center','String','3.0',...
'Tooltip',sprintf('Signal-to-Noise Ratio for Regularization Parameter: 1/\x03bb'));
%% Menu: Max Orientation or RMS Orientation for Vector InvSoln
% delete(h.menu_inv_bst_maxvectorori_txt); delete(h.menu_inv_bst_maxvectorori);
h.menu_inv_bst_maxvectorori_txt = uicontrol(h.panel_inv_bst_params,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[sum(h.edit_inv_bst_reg_lambda_snr.Position([1 3]))+.001 .075 .225 ysize],...
'FontSize',10,'HorizontalAlignment','left','String','Vector Summation','Visible','on');
h.menu_inv_bst_maxvectorori = uicontrol(h.panel_inv_bst_params,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','popupmenu','Units','normalize',...
'Position',[sum(h.menu_inv_bst_maxvectorori_txt.Position([1 3]))+.01 h.menu_inv_bst_maxvectorori_txt.Position(2) .175 ysize],...
'FontSize',8,'HorizontalAlignment','center','String',{'RMS' 'Max'},'Value',1,'Visible','on',...
'Tooltip',sprintf('Vector Summation 3-dipole Orientations for Vector Inverse Solutions\n"Max" = orientation with maximum power across active interval\n"RMS" = root-mean square orientation across active interval\n"avg.pow" = average power across active interval'));
%% Radio: Overwrite data in brainstorm's directories
% delete(h.radio_overwrite_bst_data);
h.radio_overwrite_bst_data = uicontrol(h.panel_inv_bst_params,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','radiobutton','Units','normalize',...
'Position',[h.menu_inv_bst_maxvectorori.Position(1) h.menu_inv_bst_reg_noise_type_txt.Position(2) 1-h.menu_inv_bst_maxvectorori.Position(1) ysize],'Visible','on',...
'FontSize',8,'Value', 0,'String', 're-export trial data');
%% Field Trip's LCMV, eLORETA, sLORETA, MNE params %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Sub-Panel: "Field Trip Parameters"
% delete(h.panel_inv_ft_params)
h.panel_inv_ft_params = uipanel(h.panel_inv_soln ,'Title','Field Trip Parameters','FontSize',10,'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor',[0 0 0],...
'Units','normalize','Position',[.005 .01 .38 .75],'Visible','off');
%% Menu: "Power Method" --> "lambda1" or "trace"
h.menu_inv_powmethod_txt = uicontrol(h.panel_inv_ft_params,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[.01 .75 .15 .225],...
'FontSize',10,'HorizontalAlignment','left','String','Power Method');
h.menu_inv_powmethod = uicontrol(h.panel_inv_ft_params,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','popupmenu','Units','normalize',...
'Position',[sum(h.menu_inv_powmethod_txt.Position([1 3]))+.01 h.menu_inv_powmethod_txt.Position(2)+.15 .125 .1],...
'FontSize',8,'HorizontalAlignment','center','String',{'lambda1', 'trace'},'Value',1,'Callback',@menu_inv_soln_txt_Callback);
%% Edit: "Power Method" --> Lambda
h.edit_inv_lambda_txt = uicontrol(h.panel_inv_ft_params,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[sum(h.menu_inv_powmethod.Position([1 3]))+.01 h.menu_inv_powmethod_txt.Position(2) .15 h.menu_inv_powmethod_txt.Position(4)],...
'FontSize',10,'HorizontalAlignment','left','String','Lambda (%)');
h.edit_inv_lambda = uicontrol(h.panel_inv_ft_params,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','edit','Units','normalize',...
'Position',[sum(h.edit_inv_lambda_txt.Position([1 3]))+.01 h.edit_inv_lambda_txt.Position(2) .075 .25],...
'FontSize',10,'HorizontalAlignment','center','String','3',...
'Tooltip',sprintf('scalar, regularisation parameter (can be empty, it will then be estimated from snr)\nSee "ft_sourceanalysis.m"'));
%% Menu: "Normalize LF" normalize lead field
h.menu_inv_normalize_txt = uicontrol(h.panel_inv_ft_params,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[.01 .4 h.menu_inv_powmethod_txt.Position(3) h.menu_inv_powmethod_txt.Position(4)],...
'FontSize',10,'HorizontalAlignment','left','String','Normalize LF');
h.menu_inv_normalize = uicontrol(h.panel_inv_ft_params,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','popupmenu','Units','normalize',...
'Position',[h.menu_inv_powmethod.Position(1) h.menu_inv_normalize_txt.Position(2)+.15 h.menu_inv_powmethod.Position(3:4)],...
'FontSize',8,'HorizontalAlignment','center','String',{'yes', 'no'},'Value',1,'Callback',@menu_inv_soln_txt_Callback,...
'Tooltip',sprintf('normalize the lead field (LF)\nSee "ft_sourceanalysis.m"'));
%% Edit: "Normalize LF" Normalization Paramater for normalizing the lead field
h.edit_inv_normalizeparam_txt = uicontrol(h.panel_inv_ft_params,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[sum(h.menu_inv_normalize.Position([1 3]))+.01 h.menu_inv_normalize_txt.Position(2) .15 h.menu_inv_normalize_txt.Position(4)],...
'FontSize',10,'HorizontalAlignment','left','String','Normalization');
h.edit_inv_normalizeparam = uicontrol(h.panel_inv_ft_params,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','edit','Units','normalize',...
'Position',[sum(h.edit_inv_normalizeparam_txt.Position([1 3]))+.01 h.edit_inv_normalizeparam_txt.Position(2) h.edit_inv_lambda.Position(3:4)],...
'FontSize',10,'HorizontalAlignment','center','String','0.5',...
'Tooltip',sprintf('scalar, regularisation parameter (can be empty, it will then be estimated from snr)\nSee "ft_sourceanalysis.m"'));
%% Menu: "Prewhiten LF" lead field
h.menu_inv_prewhiten_txt = uicontrol(h.panel_inv_ft_params,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[.01 .075 h.edit_inv_normalizeparam_txt.Position(3) h.edit_inv_normalizeparam_txt.Position(4)],...
'FontSize',10,'HorizontalAlignment','left','String','Prewhiten LF');
h.menu_inv_prewhiten = uicontrol(h.panel_inv_ft_params,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','popupmenu','Units','normalize',...
'Position',[sum(h.menu_inv_prewhiten_txt.Position([1 3]))+.01 h.menu_inv_prewhiten_txt.Position(2)+.15 h.menu_inv_powmethod.Position(3:4)],...
'FontSize',8,'HorizontalAlignment','center','String',{'yes', 'no'},'Value',1,...
'Tooltip',sprintf('prewhiten the lead field (LF) matrix with the noise covariance matrix C\nSee "ft_sourceanalysis.m"'));
%% Menu: "Reduce Rank"
h.menu_inv_reducerank_txt = uicontrol(h.panel_inv_ft_params,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[sum(h.menu_inv_prewhiten.Position([1 3]))+.01 h.menu_inv_prewhiten_txt.Position(2) h.edit_inv_normalizeparam_txt.Position(3) h.edit_inv_normalizeparam_txt.Position(4)],...
'FontSize',10,'HorizontalAlignment','left','String','Reduce Rank');
h.menu_inv_reducerank = uicontrol(h.panel_inv_ft_params,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','popupmenu','Units','normalize',...
'Position',[sum(h.menu_inv_reducerank_txt.Position([1 3]))+.01 h.menu_inv_reducerank_txt.Position(2) .075 h.edit_inv_normalizeparam.Position(4)],...
'FontSize',8,'HorizontalAlignment','center','String',{'yes', 'no'},'Value',1,...
'Tooltip',sprintf('"no" or "yes" --> rank for EEG or MEG (default rank = 3 for EEG, 2 for MEG)C\nSee "ft_sourceanalysis.m"'));
%% Menu: "Data Type" Use "Average Data" or "Time-Freq Data"
h.menu_inv_datatype_txt = uicontrol(h.panel_inv_ft_params,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[sum(h.menu_inv_reducerank.Position([1 3]))+.02 h.menu_inv_powmethod_txt.Position(2) h.edit_inv_normalizeparam_txt.Position(3) h.edit_inv_normalizeparam_txt.Position(4)],...
'FontSize',10,'HorizontalAlignment','left','String','Data Type');
h.menu_inv_datatype = uicontrol(h.panel_inv_ft_params,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','popupmenu','Units','normalize',...
'Position',[.82 h.menu_inv_datatype_txt.Position(2) .175 h.edit_inv_normalizeparam.Position(4)],...
'FontSize',8,'HorizontalAlignment','center','String',{'Averaged' 'Time-Freq'},'Value',1,...
'Tooltip',sprintf('Data Type to use for Source Modeling'));
%% Menu: "Beamformer Weights" weightnorm
h.menu_inv_weightnorm_txt = uicontrol(h.panel_inv_ft_params,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[sum(h.edit_inv_lambda.Position([1 3]))+.02 h.menu_inv_normalize_txt.Position(2) .25 h.menu_inv_reducerank_txt.Position(4)],...
'FontSize',10,'HorizontalAlignment','left','String','Beamformer Weights');
h.menu_inv_weightnorm = uicontrol(h.panel_inv_ft_params,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','popupmenu','Units','normalize',...
'Position',[sum(h.menu_inv_weightnorm_txt.Position([1 3]))+.01 h.menu_inv_weightnorm_txt.Position(2) h.menu_inv_datatype.Position(3:4)],...
'FontSize',8,'HorizontalAlignment','center','String',{'no' 'arraygain' 'nai' 'unitnoisegain' 'unitgain'},'Value',3,...
'Tooltip',sprintf('normalize the beamformer weights\nSee "ft_inverse_lcmv.m"'));
%% Menu: "Scale Source" Covariance
h.menu_inv_scalesourcecov_txt = uicontrol(h.panel_inv_ft_params,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[sum(h.edit_inv_lambda.Position([1 3]))+.02 h.menu_inv_normalize_txt.Position(2) .25 h.menu_inv_reducerank_txt.Position(4)],...
'FontSize',10,'HorizontalAlignment','left','String','Scale Source Covariance');
h.menu_inv_scalesourcecov = uicontrol(h.panel_inv_ft_params,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','popupmenu','Units','normalize',...
'Position',[sum(h.menu_inv_weightnorm_txt.Position([1 3]))+.01 h.menu_inv_scalesourcecov_txt.Position(2) h.menu_inv_datatype.Position(3:4)],...
'FontSize',8,'HorizontalAlignment','center','String',{'yes', 'no'},'Value',1,...
'Tooltip',sprintf('scale the source covariance matrix R such that trace(leadfield*R*leadfield'')/trace(C)=1\nSee "ft_sourceanalysis.m"'));
%% Menu: Max Orientation or RMS Orientation for Vector InvSoln
h.menu_inv_maxvectorori_txt = uicontrol(h.panel_inv_ft_params,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[sum(h.menu_inv_reducerank.Position([1 3]))+.02 h.menu_inv_prewhiten_txt.Position(2) .25 h.menu_inv_scalesourcecov_txt.Position(4)],...
'FontSize',10,'HorizontalAlignment','left','String','Vector Summation','Visible','off');
h.menu_inv_maxvectorori = uicontrol(h.panel_inv_ft_params,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','popupmenu','Units','normalize',...
'Position',[sum(h.menu_inv_maxvectorori_txt.Position([1 3]))+.01 h.menu_inv_maxvectorori_txt.Position(2) h.menu_inv_datatype.Position(3:4)],...
'FontSize',8,'HorizontalAlignment','center','String',{'RMS' 'Max' 'avg.pow'},'Value',1,'Visible','off',...
'Tooltip',sprintf('Vector Summation 3-dipole Orientations for Vector Inverse Solutions\n"Max" = orientation with maximum power across active interval\n"RMS" = root-mean square orientation across active interval\n"avg.pow" = average power as originally calulated from "ft_inverse_mne.m"'));
%% %%% Panel: "Inverse Solutions" ListBox %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
h.panel_3D_image_listbox = uipanel(h.tab_source_modeling ,'Title','Inverse Solutions','FontSize',10,'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor',[0 0 0],...
'Units','normalize','Position',[0.3898 0.8017 0.1978 0.1310],'Visible','on');
%% Listbox of Inverse Solution Results
h.listbox_inv_solns_txt = uicontrol(h.panel_3D_image_listbox,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor',[0 .6 0],'Units','normalize',...
'Position',[0.0100 0.7619 0.4000 0.1931],...
'FontSize',10,'HorizontalAlignment','left','String','Results','FontWeight','bold');
h.listbox_inv_solns = uicontrol(h.panel_3D_image_listbox,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','listbox','Units','normalize',...
'Position',[0.0181 0.0345 0.9500 0.7008],...
'FontSize',8,'HorizontalAlignment','center','String',{''},'max',100,'Value',1,'Callback',@listbox_inv_solns_Callback);
%% Delete Results
h.btn_delete_inv_solns = uicontrol(h.panel_3D_image_listbox,'BackgroundColor',[1 .8 .8],'ForegroundColor',[1 1 1]*0,'Style','pushbutton','Units','normalize',...
'Position',[0.6000 0.8000 0.3750 0.1950],'Visible','on',...
'FontSize',10,'HorizontalAlignment','center','String','Delete','Callback',@delete_inv_solns);
%% %%% Panel: "Plotting" ListBox %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% delete(h.panel_3D_image_plot_msg);
h.panel_3D_image_plot_msg = uipanel(h.tab_source_modeling ,'Title','Plotting Inverse Solution','FontSize',10,'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor',[0 0 0],...
'Units','normalize','Position',[0.3898 0.8017 0.1978 0.1310],'Visible','off');
h.panel_3D_image_plot_msg_txt = uicontrol(h.panel_3D_image_plot_msg,'Style','text', 'BackgroundColor',h.panel_3D_image_plot_msg.BackgroundColor,'Foregroundcolor',[1 0 0],'Units','normalize',...
'Position',[.05 .1 .85 .85],...
'FontSize',12,'HorizontalAlignment','left','String','Inverse Solution');
h.panel_3D_image_plot_msg_close = uicontrol(h.panel_3D_image_plot_msg,'BackgroundColor',h.panel_3D_image_plot_msg.BackgroundColor,'ForegroundColor',[1 0 0],'Style','pushbutton','Units','normalize',...
'Position',[.925 .75 .075 .25],'Visible','on',...
'FontSize',8,'Value',1,'String', 'X','Callback',{@sm_hide_panel,h.panel_3D_image_plot_msg});
%% Radio: Calculate step-wise thresholding
% delete(h.radio_3D_stepwise_thresh)
h.radio_3D_stepwise_thresh = uicontrol(h.tab_source_modeling,'BackgroundColor',h.tab_source_modeling.BackgroundColor,'ForegroundColor',[1 1 1]*0,'Style','radiobutton','Units','normalize',...
'Position',[sum(h.panel_3D_image_plot_msg.Position([1 3]))+.01 .89 .2 .025],'Visible','on',...
'FontSize',10,'Value',0,'String', 'Step-wise thresholding');
%% Radio: Calculate SPF CTF functions
% delete(h.radio_3D_calc_SPF_CTF)
h.radio_3D_calc_SPF_CTF = uicontrol(h.tab_source_modeling,'BackgroundColor',h.tab_source_modeling.BackgroundColor,'ForegroundColor',[1 1 1]*0,'Style','radiobutton','Units','normalize',...
'Position',[sum(h.panel_3D_image_plot_msg.Position([1 3]))+.01 .86 .2 .025],'Visible','on',...
'FontSize',10,'Value',0,'String', 'Calculate SPF & CTF');
%% %%% Panel: "Analyze Source Data" for PLV, ... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% delete(h.panel_3D_analyses)
h.panel_3D_analyses = uipanel(h.tab_source_modeling ,'Title','Analyze Source Data','FontSize',10,'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor',[0 0 0],...
'Units','normalize','Position',[.005 .005 .193 h.panel_inv_soln.Position(2)-.01],'Visible','on');
%% Menu: Analyses
h.menu_inv_analyses_txt = uicontrol(h.panel_3D_analyses,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[.025 .955 .5 .04],...
'FontSize',10,'HorizontalAlignment','left','String','Analysis Method');
h.menu_inv_analyses = uicontrol(h.panel_3D_analyses,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','popupmenu','Units','normalize',...
'Position',[.025 h.menu_inv_analyses_txt.Position(2)-.04 .95 .04],'Enable','on',...
'FontSize',8,'HorizontalAlignment','center','String',{'none','Seeded Functional Connectivity' 'more to come'},'Value',1,'Callback',@sm_menu_inv_analyses_CallBack);
%% %%% Sub-Panel: "Seeded Functional Connectivity" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% delete(h.panel_3D_PLV_PLI)
h.panel_3D_PLV_PLI = uipanel(h.panel_3D_analyses ,'Title','Seeded Functional Connectivity','FontSize',10,'BackgroundColor',[.95 1 1],'Foregroundcolor',[0 0 0],...
'Visible','off','Units','normalize','Position',[.005 .005 .99 h.menu_inv_analyses.Position(2)-.005],'Visible','on');
%% Listbox: PLV Seed locations to compare to seeds
h.listbox_inv_plv_seed_locs_txt = uicontrol(h.panel_3D_PLV_PLI,'Style','text', 'BackgroundColor',h.panel_3D_PLV_PLI.BackgroundColor,'Foregroundcolor',[1 0 1]*0.75,'Units','normalize',...
'Position',[.005 .96 .48 .04],'FontWeight','Bold',...
'FontSize',9,'HorizontalAlignment','left','String','Seed Locs');
h.listbox_inv_plv_seed_locs = uicontrol(h.panel_3D_PLV_PLI,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',h.listbox_inv_plv_seed_locs_txt.ForegroundColor,...
'Style','listbox','Units','normalize','Position',[.005 h.listbox_inv_plv_seed_locs_txt.Position(2)-.121 .48 .12],'Enable','on','Max',2,...
'FontSize',8,'HorizontalAlignment','center','String',{'True Sources (nearest to)' 'Hit Peak Sources' 'All Peak Sources' 'Lead Field Grid'},'Value',1,'Callback',@sm_menu_inv_analyses_CallBack);
%% Listbox: PLV Comparison locations to compare to seeds
h.listbox_inv_plv_comp_locs_txt = uicontrol(h.panel_3D_PLV_PLI,'Style','text', 'BackgroundColor',h.panel_3D_PLV_PLI.BackgroundColor,'Foregroundcolor',[1 0 1]*0,...
'Units','normalize','Position',[.5 h.listbox_inv_plv_seed_locs_txt.Position(2:4)],...
'FontSize',9,'FontWeight','Bold','HorizontalAlignment','left','String','Comparison Locs');
h.listbox_inv_plv_comp_locs = uicontrol(h.panel_3D_PLV_PLI,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',h.listbox_inv_plv_comp_locs_txt.ForegroundColor,...
'Style','listbox','Units','normalize','Position',[.5 h.listbox_inv_plv_seed_locs.Position(2:4)],'Enable','on','Max',2,...
'FontSize',8,'HorizontalAlignment','center','String',{'True Sources (nearest to)' 'Hit Peak Sources' 'All Peak Sources' 'Lead Field Grid'},...
'Value',1,'Callback',@sm_menu_inv_analyses_CallBack);
%% Edit: Downsampling Grid Locations of leadfield
h.edit_inv_plv_lf_grid_idx_txt = uicontrol(h.panel_3D_PLV_PLI,'Style','text', 'BackgroundColor',h.panel_3D_PLV_PLI.BackgroundColor,'Foregroundcolor','k','Units','normalize',...
'Position',[.01 h.listbox_inv_plv_comp_locs.Position(2)-.06 .78 .04],...
'FontSize',8,'HorizontalAlignment','right','String','Down Sample Lead Field Grid by:',...
'Tooltip',sprintf('Down sampling factor of lead field locations\n for PLV & PLI comparisons\n\n"Volume" Headmodel= integer locations indices downsampled [1:ds_factor:end]\n"Cortical Surface"=using "reducepatch.m" to downsample'));
h.edit_inv_plv_lf_grid_idx = uicontrol(h.panel_3D_PLV_PLI,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','edit','Units','normalize',...
'Position',[sum(h.edit_inv_plv_lf_grid_idx_txt.Position([1 3]))+.02 h.edit_inv_plv_lf_grid_idx_txt.Position(2) .1 .04],...
'FontSize',8,'HorizontalAlignment','center','String','1','Callback',@sm_downsample_leadfield,...
'Tooltip',sprintf('Down sampling factor of lead field locations\n for PLV & PLI comparisons\n\n"Volume" Headmodel= integer locations indices downsampled [1:ds_factor:end]\n"Cortical Surface"=using "reducepatch.m" to downsample'));
%% Text: Number of Seeds, Comparisons, and PLV contrasts
h.edit_inv_plv_num_seeds_comps_txt = uicontrol(h.panel_3D_PLV_PLI,'Style','text', 'BackgroundColor',h.panel_3D_PLV_PLI.BackgroundColor,'Foregroundcolor','k',...
'Units','normalize', 'Position',[.01 h.edit_inv_plv_lf_grid_idx.Position(2)-.1 .48 .095],...
'FontSize',8,'HorizontalAlignment','left','String',sprintf('Seeds = 0\nComparisons = 0\nFC Contrasts = 0'));
%% Radio: plot PLV grid
h.radio_3D_plot_plv_locs = uicontrol(h.panel_3D_PLV_PLI,'BackgroundColor',h.panel_3D_PLV_PLI.BackgroundColor,'ForegroundColor',[1 1 1]*0,'Style','radiobutton','Units','normalize',...
'Position',[.58 h.edit_inv_plv_lf_grid_idx.Position(2)-.045 .41 .04],'Visible','on',...
'FontSize',8,'Value',0,'String', 'Show FC locs','Callback',@sm_plot_plv_locs);
%% Button: create PLV contrasts
h.btn_3D_create_plv_contrasts = uicontrol(h.panel_3D_PLV_PLI,'BackgroundColor',[1 1 .85],'ForegroundColor',[1 1 1]*0,'Style','pushbutton','Units','normalize',...
'Position',[.58 h.radio_3D_plot_plv_locs.Position(2)-.05 .38 .05],'Visible','on',...
'FontSize',8,'Value',1,'String', 'Create Contrasts','Callback',@sm_create_plv_contrasts);
%% Listbox: FC Analysis Types -- > Currently only PLV and PLI implemented
h.listbox_inv_FC_type_txt = uicontrol(h.panel_3D_PLV_PLI,'Style','text', 'BackgroundColor',h.panel_3D_PLV_PLI.BackgroundColor,'Foregroundcolor',[1 0 1]*0,'Units','normalize',...
'Position',[.005 h.edit_inv_plv_num_seeds_comps_txt.Position(2)-.07 .43 .04],'FontWeight','Bold',...
'FontSize',9,'HorizontalAlignment','left','String','Analysis Types');
h.listbox_inv_FC_type = uicontrol(h.panel_3D_PLV_PLI,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor','k',...
'Style','listbox','Units','normalize','Position',[.01 h.listbox_inv_FC_type_txt.Position(2)-.181 .43 .18],'Enable','on','Max',2,...
'FontSize',8,'HorizontalAlignment','center','String',{'PLV' 'PLI' 'more to come'},'Value',[1 2]);
%% Text: "Parameters" Heading
h.text_inv_wavelet_params_txt = uicontrol(h.panel_3D_PLV_PLI,'Style','text', 'BackgroundColor',h.panel_3D_PLV_PLI.BackgroundColor,'Foregroundcolor','k','Units','normalize',...
'Position',[.5 h.listbox_inv_FC_type_txt.Position(2) .48 .04],...
'FontSize',9,'HorizontalAlignment','left','FontWeight','bold','String','Parameters');
%% Edit: Frequencies Bands for wavelet for PLV/PLI
h.edit_inv_plv_freq_bands_txt = uicontrol(h.panel_3D_PLV_PLI,'Style','text', 'BackgroundColor',h.panel_3D_PLV_PLI.BackgroundColor,'Foregroundcolor','k','Units','normalize',...
'Position',[.5 h.text_inv_wavelet_params_txt.Position(2)-.041 .32 .04],...
'FontSize',8,'HorizontalAlignment','left','FontWeight','normal','String','Frequency Band',...
'Tooltip',sprintf('Frequency limits for time-frequency analyses for Functional Connectivity (e.g., alpha band = [8 12])\n'));
h.edit_inv_plv_freq_bands = uicontrol(h.panel_3D_PLV_PLI,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','edit','Units','normalize',...
'Position',[1-.14 h.edit_inv_plv_freq_bands_txt.Position(2) .13 .04],...
'FontSize',8,'HorizontalAlignment','center','String','1 58',...
'Tooltip',sprintf('Frequency limits for time-frequency analyses for Functional Connectivity (e.g., alpha band = [8 12])\n'));
%% Edit: Number of Voices per Ocatve for calculating wavelets
h.edit_inv_wvlt_num_voices_txt = uicontrol(h.panel_3D_PLV_PLI,'Style','text', 'BackgroundColor',h.panel_3D_PLV_PLI.BackgroundColor,'Foregroundcolor','k','Units','normalize',...
'Position',[.5 h.edit_inv_plv_freq_bands_txt.Position(2)-.045 .36 .04],'FontSize',8,'HorizontalAlignment','left','String','Frequencies/Octave',...
'Tooltip',sprintf('Number of freq bins per octave for wavelet functions.\nMust be between 4 and 48. see "cwt.m" for more details'));
h.edit_inv_wvlt_num_voices = uicontrol(h.panel_3D_PLV_PLI,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','edit','Units','normalize',...
'Position',[1-.14 h.edit_inv_wvlt_num_voices_txt.Position(2) .13 .04],'FontSize',8,'HorizontalAlignment','center','String','10',...
'Tooltip',sprintf('Number of freq bins per octave for wavelet functions.\nMust be between 4 and 48. see "cwt.m" for more details'));
%% Edit: Number of Surrogates for Statistical thresholding of PLV/PLI
h.edit_inv_plv_surrogates_txt = uicontrol(h.panel_3D_PLV_PLI,'Style','text', 'BackgroundColor',h.panel_3D_PLV_PLI.BackgroundColor,'Foregroundcolor','k','Units','normalize',...
'Position',[.5 h.edit_inv_wvlt_num_voices.Position(2)-.045 .36 .04],'FontSize',8,'HorizontalAlignment','left','String','# Surrogates',...
'Tooltip',sprintf('Number of PLV/PLI surrogates for statistics\nIf set to zero, then no surrogates calculated'));
h.edit_inv_plv_surrogates = uicontrol(h.panel_3D_PLV_PLI,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','edit','Units','normalize',...
'Position',[1-.14 h.edit_inv_plv_surrogates_txt.Position(2) .13 .04],'FontSize',8,'HorizontalAlignment','center','String','0',...
'Tooltip',sprintf('Number of freq bins per octave for wavelet functions.\nMust be between 4 and 48. see "cwt.m" for more details'));
%% Radio: include projected noise
h.radio_3D_include_noise_PLV = uicontrol(h.panel_3D_PLV_PLI,'BackgroundColor',h.panel_3D_PLV_PLI.BackgroundColor,'ForegroundColor',[1 1 1]*0,'Style','radiobutton','Units','normalize',...
'Position',[h.edit_inv_plv_surrogates_txt.Position(1) h.edit_inv_plv_surrogates_txt.Position(2)-.045 .48 .04],'Visible','on',...
'FontSize',8,'Value',0,'String', 'include projected Noise FC');
%% Button: Calculate True Connectivity using wavelets
h.btn_3D_calc_true_PLV_PLI = uicontrol(h.panel_3D_PLV_PLI,'BackgroundColor',[.9 1 .9],'ForegroundColor',[1 1 1]*0,'Style','pushbutton','Units','normalize',...
'Position',[.01 h.listbox_inv_FC_type.Position(2)-.055 .47 .05],'Visible','on',...
'FontSize',8,'Value',1,'String', 'Calc True Connectivity','Callback',@sm_calc_true_PLV_PLI);
%% Button: Calculate InvSoln Connectivity using wavelets
h.btn_3D_calc_PLV_PLI = uicontrol(h.panel_3D_PLV_PLI,'BackgroundColor',[.9 .9 1],'ForegroundColor',[1 1 1]*0,'Style','pushbutton','Units','normalize',...
'Position',[.51 h.btn_3D_calc_true_PLV_PLI.Position(2) .47 .05],'Visible','on',...
'FontSize',8,'Value',1,'String', 'Calc Peak Connectivity','Callback',@sm_calc_PLV_PLI);
%% %%% Sub-Panel: "PLV & PLI" % delete(h.panel_3D_PLV_PLI)
% delete(h.panel_3D_PLV_PLI_ROI);
h.panel_3D_PLV_PLI_ROI = uipanel(h.panel_3D_PLV_PLI ,'Title','Region of Interest (ROI) Statistics','FontSize',10,'BackgroundColor',[.95 1 1],'Foregroundcolor',[0 0 0],...
'Visible','off','Units','normalize','Position',[.005 .005 .99 h.btn_3D_calc_true_PLV_PLI.Position(2)-.01],'Visible','on');
%% Edit: ROI Frequency Interval
h.edit_3D_PLV_PLI_ROI_freq_int_txt = uicontrol(h.panel_3D_PLV_PLI_ROI,'Style','text', 'BackgroundColor',h.panel_3D_PLV_PLI.BackgroundColor,'Foregroundcolor','k','Units','normalize',...
'Position',[.05 .875 .42 .095],...
'FontSize',9,'HorizontalAlignment','left','FontWeight','normal','String','ROI Frequency Band (Hz)',...
'Tooltip',sprintf('ROI Frequency limits for time-frequency analyses for Functional Connectivity (e.g., alpha band = [8 12])\n'));
h.edit_3D_PLV_PLI_ROI_freq_int = uicontrol(h.panel_3D_PLV_PLI_ROI,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','edit','Units','normalize',...
'Position',[sum(h.edit_3D_PLV_PLI_ROI_freq_int_txt.Position([1 3]))+.05 h.edit_3D_PLV_PLI_ROI_freq_int_txt.Position(2) .15 .095],...
'FontSize',8,'HorizontalAlignment','center','String','1 58',...
'Tooltip',sprintf('ROI Frequency limits for time-frequency analyses for Functional Connectivity (e.g., alpha band = [8 12])\n'));
%% Edit: ROI Time Interval
h.edit_3D_PLV_PLI_ROI_time_int_txt = uicontrol(h.panel_3D_PLV_PLI_ROI,'Style','text', 'BackgroundColor',h.panel_3D_PLV_PLI.BackgroundColor,'Foregroundcolor','k','Units','normalize',...
'Position',[.05 h.edit_3D_PLV_PLI_ROI_freq_int_txt.Position(2)-.125 .42 .095],...
'FontSize',9,'HorizontalAlignment','left','FontWeight','normal','String','ROI Time Interval (sec)',...
'Tooltip',sprintf('ROI Time limits for time-frequency analyses for Functional Connectivity (e.g., alpha band = [8 12])\n'));
h.edit_3D_PLV_PLI_ROI_time_int = uicontrol(h.panel_3D_PLV_PLI_ROI,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','edit','Units','normalize',...
'Position',[sum(h.edit_3D_PLV_PLI_ROI_time_int_txt.Position([1 3]))+.05 h.edit_3D_PLV_PLI_ROI_time_int_txt.Position(2) .15 .095],...
'FontSize',8,'HorizontalAlignment','center','String','0 0.5',...
'Tooltip',sprintf('ROI Time limits for time-frequency analyses for Functional Connectivity (e.g., alpha band = [8 12])\n'));
%% Radio: Calculate ROI stats using Stepwise Tresholding
% delete(h.radio_3D_PLV_PLI_ROI_stepwise_stats);
h.radio_3D_PLV_PLI_ROI_stepwise_stats = uicontrol(h.panel_3D_PLV_PLI_ROI,'BackgroundColor',h.panel_3D_PLV_PLI.BackgroundColor,'ForegroundColor',[1 1 1]*0,'Style','radiobutton','Units','normalize',...
'Position',[.01 h.edit_3D_PLV_PLI_ROI_time_int_txt.Position(2)-.15 1 .1],'Visible','on','FontSize',9,'Value',0,'String', 'calculate stats using step-wise thresholding');
%% Edit: ROI Threshold Step Size
h.edit_3D_PLV_PLI_ROI_step_size_txt = uicontrol(h.panel_3D_PLV_PLI_ROI,'Style','text', 'BackgroundColor',h.panel_3D_PLV_PLI.BackgroundColor,'Foregroundcolor','k','Units','normalize',...
'Position',[.05 h.radio_3D_PLV_PLI_ROI_stepwise_stats.Position(2)-.125 .42 .095],...
'FontSize',9,'HorizontalAlignment','left','FontWeight','normal','String','ROI Threshold Step Size',...
'Tooltip',sprintf('Step Size (ranging from 0 to 1) for thresholding FC data to calculate statistics'));
h.edit_3D_PLV_PLI_ROI_step_size = uicontrol(h.panel_3D_PLV_PLI_ROI,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','edit','Units','normalize',...
'Position',[sum(h.edit_3D_PLV_PLI_ROI_step_size_txt.Position([1 3]))+.05 h.edit_3D_PLV_PLI_ROI_step_size_txt.Position(2) .15 .095],...
'FontSize',8,'HorizontalAlignment','center','String','.01',...
'Tooltip',sprintf('Step Size (ranging from 0 to 1) for thresholding FC data to calculate statistics'));
%% Radio: Calculate ROI stats using Surg StdDev Tresholding
% delete(h.radio_3D_PLV_PLI_ROI_surg_std_stats);
h.radio_3D_PLV_PLI_ROI_surg_std_stats = uicontrol(h.panel_3D_PLV_PLI_ROI,'BackgroundColor',h.panel_3D_PLV_PLI.BackgroundColor,'ForegroundColor',[1 1 1]*0,'Style','radiobutton','Units','normalize',...
'Position',[.01 h.edit_3D_PLV_PLI_ROI_step_size_txt.Position(2)-.15 1 .1],'Visible','on','FontSize',9,'Value',0,'String', 'calculate stats using surrogate StdDev thresholding');
%% Edit: ROI Surrogate StdDev Step Size
h.edit_3D_PLV_PLI_ROI_std_step_size_txt = uicontrol(h.panel_3D_PLV_PLI_ROI,'Style','text', 'BackgroundColor',h.panel_3D_PLV_PLI.BackgroundColor,'Foregroundcolor','k','Units','normalize',...
'Position',[.05 h.radio_3D_PLV_PLI_ROI_surg_std_stats.Position(2)-.125 .42 .095],...
'FontSize',9,'HorizontalAlignment','left','FontWeight','normal','String','ROI StdDev Step Size',...
'Tooltip',sprintf('Surrogate Standard Deviation Step Size for thresholding FC data \nusing surrogate FC noise results when calculating statistics'));
h.edit_3D_PLV_PLI_ROI_std_step_size = uicontrol(h.panel_3D_PLV_PLI_ROI,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','edit','Units','normalize',...
'Position',[sum(h.edit_3D_PLV_PLI_ROI_std_step_size_txt.Position([1 3]))+.05 h.edit_3D_PLV_PLI_ROI_std_step_size_txt.Position(2) .15 .095],...
'FontSize',8,'HorizontalAlignment','center','String','.5',...
'Tooltip',sprintf('Surrogate Standard Deviation Step Size for thresholding FC data \nusing surrogate FC noise results when calculating statistics'));
%% Edit: ROI Surrogate StdDev Stop
h.edit_3D_PLV_PLI_ROI_std_stop_size_txt = uicontrol(h.panel_3D_PLV_PLI_ROI,'Style','text', 'BackgroundColor',h.panel_3D_PLV_PLI.BackgroundColor,'Foregroundcolor','k','Units','normalize',...
'Position',[.05 h.edit_3D_PLV_PLI_ROI_std_step_size_txt.Position(2)-.125 .42 .095],...
'FontSize',9,'HorizontalAlignment','left','FontWeight','normal','String','ROI StdDev Stop Criterion',...
'Tooltip',sprintf('Surrogate Thresholding stops at this level of standard deviation'));
h.edit_3D_PLV_PLI_ROI_std_stop_size = uicontrol(h.panel_3D_PLV_PLI_ROI,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','edit','Units','normalize',...
'Position',[sum(h.edit_3D_PLV_PLI_ROI_std_stop_size_txt.Position([1 3]))+.05 h.edit_3D_PLV_PLI_ROI_std_stop_size_txt.Position(2) .15 .095],...
'FontSize',8,'HorizontalAlignment','center','String','20',...
'Tooltip',sprintf('Surrogate Thresholding stops at this level of standard deviation'));
%% Button: Calculate ROI FC statistics
% delete(h.btn_3D_calc_ROI_FC_metrics);
h.btn_3D_calc_ROI_FC_metrics = uicontrol(h.panel_3D_PLV_PLI_ROI,'BackgroundColor',[.9 .9 1],'ForegroundColor',[1 1 1]*0,'Style','pushbutton','Units','normalize',...
'Position',[.71 .01 .28 .15],'Visible','on',...
'FontSize',8,'Value',1,'String', 'Calc ROI stats','Callback',@sm_calc_ROI_FC_metrics);
%% %%% Panel "Modeling Results" Axes for plotting %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% delete(h.panel_inv_results)
h.panel_inv_results = uipanel(h.tab_source_modeling,'Title','Modeling Results','FontSize',10,'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor',[0 0 0],...
'Units','normalize','Position',[sum(h.panel_3D_analyses.Position([1 3]))+.005 h.panel_3D_analyses.Position(2) .52 h.panel_inv_soln.Position(2)-.01],'Visible','on');
%% axes for 3D image plots
h.axes_3D_images = axes(h.panel_inv_results,'Position',[.45 .45 .35 .5],'View',[-90 90]); axis off;
%% axes for source waveform plots
h.axes_source_waves = axes(h.panel_inv_results,'Position',[.51 .07 .48 .2],'ButtonDownFcn',@bs_plot_map_time);
disableDefaultInteractivity(h.axes_source_waves); h.axes_source_waves.Toolbar.Visible='off';
% delete(h.text_cursor_specs)
h.text_cursor_specs = text(h.axes_source_waves, h.axes_source_waves.XLim(1)+(.02*range(h.axes_source_waves.XLim)) , ...
h.axes_source_waves.YLim(2)-(.1*range(h.axes_source_waves.YLim)), 'X: Y:','Color','r');
%% radio: plot ERP waves in grey
% delete(h.radio_3D_plot_erp_waves );
h.radio_3D_plot_erp_waves = uicontrol(h.panel_inv_results,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','radiobutton','Units','normalize',...
'Position',[1-.1 sum(h.axes_source_waves.Position([2 4]))+.01 .1 .025],...
'FontSize',8,'Value',1,'String', 'plot sensors','Callback',@toggle_sens_waves);
%% axes for source FFT plots
% delete(h.axes_source_fft);
h.axes_source_fft = axes(h.panel_inv_results,'Position',[.05 .07 0.38 .28]);
disableDefaultInteractivity(h.axes_source_fft); h.axes_source_fft.Toolbar.Visible='off';
%% axes for inverse solutions swf time-freq plot
% delete(h.axes_inv_soln_tfr);
h.axes_inv_soln_tfr = axes(h.panel_inv_results,'Position',[.05 .48 0.3 .28],'visible','off'); box on; h.axes_inv_soln_tfr.Title.String='Time-Frequency Plot';
disableDefaultInteractivity(h.axes_inv_soln_tfr); h.axes_inv_soln_tfr.Toolbar.Visible='off'; drawnow;
%% axes for true sources' swf time-freq plot
% delete(h.axes_true_source_tfr );
h.axes_true_source_tfr = axes(h.panel_inv_results,'Position',[.05 .07 0.3 .28],'Visible','off'); box on; h.axes_true_source_tfr.Title.String='TFR for True Sources';
disableDefaultInteractivity(h.axes_true_source_tfr); h.axes_true_source_tfr.Toolbar.Visible='off';
%% Edit: Xscale & yScale for waveform plots
% delete(h.edit_inv_source_waves_yscale_txt); delete(h.edit_inv_source_waves_yscale);
h.edit_inv_source_waves_yscale_txt = uicontrol(h.panel_inv_results,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[h.axes_source_waves.Position(1) .001 .06 .03],...
'Visible','on','FontSize',8,'HorizontalAlignment','center','String','Y Scale');
h.edit_inv_source_waves_yscale = uicontrol(h.panel_inv_results,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor','k','Style','edit','Units','normalize',...
'Position',[sum(h.edit_inv_source_waves_yscale_txt.Position([1 3]))+.005 h.edit_inv_source_waves_yscale_txt.Position(2) .055 .035],...
'Visible','on','FontSize',8,'String','-110 110','Max',1,'Min',0,'Callback',{@sm_set_source_wave_scales,'Yscale'});
% delete(h.edit_inv_source_waves_xscale_txt); delete(h.edit_inv_source_waves_xscale);
h.edit_inv_source_waves_xscale_txt = uicontrol(h.panel_inv_results,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[.99-.06-.06 .001 .06 .03],...
'Visible','on','FontSize',8,'HorizontalAlignment','center','String','X Scale');
h.edit_inv_source_waves_xscale = uicontrol(h.panel_inv_results,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor','k','Style','edit','Units','normalize',...
'Position',[sum(h.edit_inv_source_waves_xscale_txt.Position([1 3]))+.005 h.edit_inv_source_waves_xscale_txt.Position(2) .055 .035],...
'Visible','on','FontSize',8,'String','-1.0 1.0','Max',1,'Min',0,'Callback',{@sm_set_source_wave_scales,'Xscale'});
%% Slider: Face Alpha Transparency scale for plotting 3D image
h.slider_3D_transparency_txt = uicontrol(h.panel_inv_results,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[.87 .96 .12 .035],...
'FontSize',10,'HorizontalAlignment','center','String','Transparency');
h.slider_3D_transparency_anat = uicontrol(h.panel_inv_results,'BackgroundColor',[1 1 1]*.9,'ForegroundColor',[1 1 1]*0,'Style','slider','Units','normalize',...
'Position',[.87 h.slider_3D_transparency_txt.Position(2)-.04 .12 .035],...
'FontSize',8,'Value',.5,'Max',1,'Min',0,'Callback',@set_3D_transparency);
addlistener(h.slider_3D_transparency_anat,'Value','PostSet',@(~,~)set_3D_transparency);
h.slider_3D_transparency_func = uicontrol(h.panel_inv_results,'BackgroundColor',[1 1 1]*.9,'ForegroundColor',[1 1 1]*0,'Style','slider','Units','normalize',...
'Position',[.87 h.slider_3D_transparency_anat.Position(2)-.04 .12 .035],...
'FontSize',8,'Value',.5,'Max',1,'Min',0,'Callback',@set_3D_transparency);
addlistener(h.slider_3D_transparency_func,'Value','PostSet',@(~,~)set_3D_transparency);
h.slider_3D_transparency_anat_txt = uicontrol(h.panel_inv_results,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[h.slider_3D_transparency_anat.Position(1)-.125 h.slider_3D_transparency_anat.Position(2) .12 .035],...
'FontSize',10,'HorizontalAlignment','right','String','Anatomy');
h.slider_3D_transparency_func_txt = uicontrol(h.panel_inv_results,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[h.slider_3D_transparency_func.Position(1)-.125 h.slider_3D_transparency_func.Position(2) .12 .035],...
'FontSize',10,'HorizontalAlignment','right','String','Inverse Map');
%% radio plot peaks
% delete(h.radio_3D_true_locs); delete(h.radio_3D_peak_locs); delete(h.radio_3D_peak_flag);
h.radio_3D_true_locs = uicontrol(h.panel_inv_results,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','radiobutton','Units','normalize',...
'Position',[h.slider_3D_transparency_func.Position(1)-.04 h.slider_3D_transparency_func_txt.Position(2)-.03 .22 .025],...
'FontSize',8,'Value',1,'String', 'Show True Sources','Callback',@toggle_true_locs);
h.radio_3D_peak_locs = uicontrol(h.panel_inv_results,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','radiobutton','Units','normalize',...
'Position',[h.slider_3D_transparency_func.Position(1)-.04 h.radio_3D_true_locs.Position(2)-.025 .22 .025],...
'FontSize',8,'Value',1,'String', 'Show Peak Sources','Callback',@toggle_peak_locs);
%% Radio: Map Slices at peaks
h.radio_3D_peak_flag = uicontrol(h.panel_inv_results,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[.4 .5 .8],'Style','radiobutton','Units','normalize',...
'Position',[h.slider_3D_transparency_func.Position(1)-.04 h.radio_3D_peak_locs.Position(2)-.025 .22 .025],...
'FontSize',8,'Value',0,'String', 'Project to Midline','Callback',@sm_view_map_slices);
%% slider 3D_image caxis scaling relative to yscale
% delete(h.slider_3D_image_thresh)
h.slider_3D_image_thresh = uicontrol(h.panel_inv_results,'BackgroundColor',[1 1 1]*.9,'ForegroundColor',[1 1 1]*0,'Style','slider','Units','normalize',...
'Position',[.925 h.axes_3D_images.Position(2)+(range(h.axes_3D_images.Position([2 4])/2)) .03 .2],...
'FontSize',8,'Value',1,'Max',1,'Min',0.01,'UserData','slider_3D_image_thresh','Callback',@set_3D_image_thresh); %
h.slider_3D_image_thresh_text_val = uicontrol(h.panel_inv_results,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[h.slider_3D_image_thresh.Position(1)-.06 h.slider_3D_image_thresh.Position(2) .055 .03],...
'FontSize',10,'HorizontalAlignment','right','String','');
addlistener(h.slider_3D_image_thresh,'Value','PostSet',@(src,evt)sm_update_slider_text_value(src,evt,h.slider_3D_image_thresh,h.slider_3D_image_thresh_text_val));
h.slider_3D_image_thresh_txt = uicontrol(h.panel_inv_results,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[h.slider_3D_image_thresh.Position(1)-.03 h.slider_3D_image_thresh.Position(2)-.08 .1 .07],...
'FontSize',10,'HorizontalAlignment','center','String','Image Threshold');
h.slider_3D_image_thresh_text_max = uicontrol(h.panel_inv_results,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[sum(h.slider_3D_image_thresh.Position([1 3]))-.05 sum(h.slider_3D_image_thresh.Position([2 4]))+.01 .08 .025],...
'FontSize',10,'HorizontalAlignment','center','String','0.5');
%% Edit: Min Max scale for plotting 3D image
h.edit_3D_min_max_txt = uicontrol(h.panel_inv_results,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[.87 h.slider_3D_image_thresh_text_max.Position(2)+.08 .12 .035],...
'FontSize',10,'HorizontalAlignment','center','String','Image Scale');
h.edit_3D_min_max = uicontrol(h.panel_inv_results,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','edit','Units','normalize',...
'Position',[.87 h.slider_3D_image_thresh_text_max.Position(2)+.04 .12 .035],...
'Tag','TFR Frequency Range','FontSize',10,'HorizontalAlignment','center','String','0 1','Callback',@set_3D_image_caxis);
%% Radio: Find spatiotemporal peaks
h.radio_find_spatiotemp_peaks = uicontrol(h.panel_inv_results,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','radiobutton','Units','normalize',...
'Position',[.025 .95 .16 .045],...
'FontSize',8,'Value',0,'String', 'Find Spatiotemporal Peaks');
%% Radio: Plot Spatiotemporal maps and waves
h.btn_3D_plot_peak_waves = uicontrol(h.panel_inv_results,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','radiobutton','Units','normalize',...
'Position',[sum(h.radio_find_spatiotemp_peaks.Position([1 3]))+.005 h.radio_find_spatiotemp_peaks.Position(2) .15 .045],...
'FontSize',8,'Value',0,'String', 'Plot Map at Specific Time','Callback',@bs_plot_map_time);
%% Radio Plot normalized Peak Source Waveforms
h.radio_normalize_swf = uicontrol(h.panel_inv_results,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','radiobutton','Units','normalize',...
'Position',[h.radio_find_spatiotemp_peaks.Position(1) h.radio_find_spatiotemp_peaks.Position(2)-.0455 .15 .045],...
'FontSize',8,'Value',0,'String', 'plot normalized waves','Callback',@bs_plot_peak_waves);
%% Radio plot TFR
h.radio_plot_TFR_waves = uicontrol(h.panel_inv_results,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','radiobutton','Units','normalize',...
'Position',[sum(h.radio_normalize_swf.Position([1 3]))+.005 h.radio_normalize_swf.Position(2) .15 .045],...
'FontSize',8,'Value',0,'String', 'plot TFR waves','Callback',@sm_plot_TFR_waves);
%% Radio: "Plot Peak TFR" --> Peak Sources' Time-Frequency for Power, PLV, PLI, ...
h.radio_inv_plot_peak_tfr_connectivity = uicontrol(h.panel_inv_results,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','radiobutton','Units','normalize',...
'Position',[h.radio_normalize_swf.Position(1) h.radio_normalize_swf.Position(2)-.0455 .1 .045],...
'Visible','on','FontSize',8,'Value',0,'String', 'Plot Peak TFR','Callback',@sm_plot_tfr_connectivity);
%% Radio: "Plot True TFR" --> True Sources' Time-Frequency for Power, PLV, PLI, ...
h.radio_inv_plot_true_tfr_connectivity = uicontrol(h.panel_inv_results,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','radiobutton','Units','normalize',...
'Position',[sum(h.radio_inv_plot_peak_tfr_connectivity.Position([1 3]))+.005 h.radio_inv_plot_peak_tfr_connectivity.Position(2) .1 .045],...
'Visible','on','FontSize',8,'Value',0,'String', 'Plot True TFR','Callback',@sm_plot_true_tfr_connectivity);
%% Menu: Time-Freq Type --> Total Power, ...
h.menu_inv_tfr_type = uicontrol(h.panel_inv_results,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','popupmenu','Units','normalize',...
'Position',[sum(h.radio_inv_plot_true_tfr_connectivity.Position([1 3]))+.005 h.radio_inv_plot_true_tfr_connectivity.Position(2) .1 .045],...
'Visible','off','FontSize',8,'HorizontalAlignment','center','String',{'Total Power' 'Evoked Power' 'Induced Power' 'PLV' 'PLI' 'dPLI' 'none'},...
'Value',1,'Callback',{@sm_plot_connectivity,'Both'});
%% Edit: TFR colormap scale
% delete(h.edit_inv_tfr_caxis_txt); delete(h.edit_inv_tfr_caxis);
h.edit_inv_tfr_caxis_txt = uicontrol(h.panel_inv_results,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[.35 sum(h.axes_inv_soln_tfr.Position([2 4]))+.095 .06 .03],...
'Visible','off','FontSize',8,'HorizontalAlignment','center','String','TFR Scale');
h.edit_inv_tfr_caxis = uicontrol(h.panel_inv_results,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor','k','Style','edit','Units','normalize',...
'Position',[.35 h.edit_inv_tfr_caxis_txt.Position(2)-.036 .055 .035],...
'Visible','off','FontSize',8,'String','-6 6','Max',1,'Min',0,'Callback',{@set_inv_tfr_caxis,'TFR'});
%% Edit: FC colormap scale
% delete(h.edit_inv_plv_caxis_txt); delete(h.edit_inv_plv_caxis);
h.edit_inv_plv_caxis_txt = uicontrol(h.panel_inv_results,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[sum(h.edit_inv_tfr_caxis.Position([1 3]))+.01 h.edit_inv_tfr_caxis_txt.Position(2) .06 .03],...
'Visible','off','FontSize',8,'HorizontalAlignment','center','String','FC Scale');
h.edit_inv_plv_caxis = uicontrol(h.panel_inv_results,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor','k','Style','edit','Units','normalize',...
'Position',[h.edit_inv_plv_caxis_txt.Position(1) h.edit_inv_plv_caxis_txt.Position(2)-.036 .055 .035],...
'Visible','off','FontSize',8,'String','-.8 .8','Max',1,'Min',0,'Callback',{@set_inv_tfr_caxis,'FC'});
%% Radio: "Show connectivity" map on 3D maps
h.radio_inv_plot_connectivity_graph = uicontrol(h.panel_inv_results,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','radiobutton','Units','normalize',...
'Position',[h.radio_inv_plot_peak_tfr_connectivity.Position(1) h.radio_inv_plot_peak_tfr_connectivity.Position(2)-.04 .1 .035],...
'Visible','off','FontSize',8,'Value',0,'String', 'Show FC graph','Callback',@sm_plot_connectivity_graph);
%% Edit: FC stats alpha level
h.edit_3D_FC_stats_alpha_level_txt = uicontrol(h.panel_inv_results,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[h.radio_inv_plot_true_tfr_connectivity.Position(1) h.radio_inv_plot_connectivity_graph.Position(2) .06 .035],...
'FontSize',10,'HorizontalAlignment','left','String','Stats p <',...
'Tooltip',sprintf('T-test Statistical Thresholding for connnectivitiy TFR plots\nIMPORTANT! No family-wise correction performed'));
h.edit_3D_FC_stats_alpha_level = uicontrol(h.panel_inv_results,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','edit','Units','normalize',...
'Position',[sum(h.edit_3D_FC_stats_alpha_level_txt.Position([1 3]))+.001 h.edit_3D_FC_stats_alpha_level_txt.Position(2) .035 .035],...
'Tag','TFR Frequency Range','FontSize',10,'HorizontalAlignment','center','String','.05','Callback',@sm_plot_connectivity,...
'Tooltip',sprintf('T-test Statistical Thresholding for connnectivitiy TFR plots\nIMPORTANT! No family-wise correction performed'));
%% Menu: TFR Data Type --> Data, Surrogate, Noise ...
h.menu_inv_tfr_data_type = uicontrol(h.panel_inv_results,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','popupmenu','Units','normalize',...
'Position',[h.menu_inv_tfr_type.Position(1) h.menu_inv_tfr_type.Position(2)-.05 .1 .045],...
'Visible','off','FontSize',8,'HorizontalAlignment','center','String',{'Data' 'Noise' 'Surrogate' 'Data (Surrogate thresholded)' 'Data (Noise thresholded)'},...
'Value',1,'Callback',@sm_plot_connectivity);
%% Edit: Connectivity Threshold for plotting FC lines on maps
h.edit_inv_plv_thresh_txt = uicontrol(h.panel_inv_results,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[.25 h.axes_inv_soln_tfr.Position(2)-.075 .12 .03],...
'Visible','off','FontSize',8,'HorizontalAlignment','left','String','Connectivity threshold');
h.edit_inv_plv_thresh = uicontrol(h.panel_inv_results,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','edit','Units','normalize',...
'Position',[sum(h.edit_inv_plv_thresh_txt.Position([1 3]))+.005 h.edit_inv_plv_thresh_txt.Position(2) .035 .035],...
'Visible','off','FontSize',8,'HorizontalAlignment','center','String','0','Callback',@sm_plot_connectivity_graph);
%% Button: Light on/off
h.toggle_light_OnOff = uicontrol(h.panel_inv_results,'BackgroundColor',[1 1 1]*.9,'ForegroundColor',[1 0 0],'Style','togglebutton','Units','normalize',...
'Position',[.4 .96 .075 .0375],...
'FontSize',8,'Value',0,'String', 'Light Off','Callback',@toggle_light_OnOff_Callback);
%% Menu: colormap
h.menu_InvMap_colormap = uicontrol(h.panel_inv_results,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','popupmenu','Units','normalize',...
'Position',[sum(h.toggle_light_OnOff.Position([1 3]))+.005 h.toggle_light_OnOff.Position(2)-.0075 .075 .045],...
'Visible','on','FontSize',8,'HorizontalAlignment','center','String',{'hsv','jet','hot','cool','spring','summer','autumn','winter','gray','bone','copper','pink','lines','flag','prism'},...
'Value',2,'Callback',@sm_InvMap_colormap);
%% Menu: InvSoln Map Type {'image' 'normalized' 'PSF' 'CTF'}
% delete(h.menu_invsoln_map_type);
h.menu_invsoln_map_type = uicontrol(h.panel_inv_results,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','popupmenu','Units','normalize',...
'Position',[h.toggle_light_OnOff.Position(1) h.toggle_light_OnOff.Position(2)-.05 .15 .045],...
'Visible','on','FontSize',8,'HorizontalAlignment','center','String',{'image' 'normalized image to max(abs)' 'Point Spread Function (PSF)' 'Cross Talk Function (CTF)' 'normalized PSF' 'normalized CTF' 'Spatial Dispersion PSF' 'Spatial Dispersion CTF' 'Overall Amplitude PSF' 'Overall Amplitude CTF'},...
'Value',1,'Callback',@bs_plot_inv_soln);
%% Btn: ReFind Peak
% delete(h.radio_update_peaks);
h.radio_update_peaks = uicontrol(h.panel_inv_results,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','radiobutton','Units','normalize',...
'Position',[h.toggle_light_OnOff.Position(1) h.menu_invsoln_map_type.Position(2)-.05 .1 .045],...
'Visible','on','FontSize',8,'HorizontalAlignment','center','String','Update Peaks',...
'Value',1);
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %%% Panel "Peaks Found" Axes for plotting
% delete(h.panel_peaks_found);
h.panel_peaks_found = uipanel(h.tab_source_modeling,'Title','Peaks Found','FontSize',10,'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor',[0 0 0],...
'Units','normalize','Visible','on', ...
'Position',[sum(h.panel_inv_results.Position([1 3]))+.005 0.005 1-sum(h.panel_inv_results.Position([1 3]))-.01 h.panel_inv_soln.Position(2)-.01]);
%% Listbox of Peaks Found
h.listbox_peaks_found_txt = uicontrol(h.panel_peaks_found,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor',[0 .6 0],'Units','normalize',...
'Position',[.01 .96 .45 .035],...
'FontSize',8,'HorizontalAlignment','left','String','Peaks Found','FontWeight','bold');
h.listbox_peaks_found = uicontrol(h.panel_peaks_found,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','listbox','Units','normalize',...
'Position',[.01 .71 .55 .25],...
'FontSize',8,'HorizontalAlignment','center','String',{''},'max',2,'Value',1,'Callback',@listbox_peaks_found_Callback);
%% invert waveforms
% delete(h.btn_invert_wave)
h.btn_invert_wave = uicontrol(h.panel_peaks_found,'BackgroundColor',[1 1 1]*.9,'ForegroundColor',[0 0 0],'Style','pushbutton','Units','normalize',...
'Position',[.28 .97 .28 .035],'FontSize',8,'String', 'invert wave','Callback',@sm_invert_wave);
%% Peak Spread Distance to find peaks within an 3D image map
% delete(h.edit_inv_peak_spread_txt); delete(h.edit_inv_peak_spread)
h.edit_inv_peak_spread_txt = uicontrol(h.panel_peaks_found,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[.01 h.listbox_peaks_found.Position(2)-.055 .175 .05],...
'Visible','on','FontSize',8,'HorizontalAlignment','left','String','Minimum Peak Distance (mm)');
h.edit_inv_peak_spread = uicontrol(h.panel_peaks_found,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','edit','Units','normalize',...
'Position',[sum(h.edit_inv_peak_spread_txt.Position([1 3]))+.005 h.edit_inv_peak_spread_txt.Position(2) .075 .045],...
'Visible','on','FontSize',8,'HorizontalAlignment','center','String','15','Callback',@bs_plot_inv_soln,...
'Tooltip',sprintf('Minimum distance (mm) of map spread between peaks in all [X Y Z] direcitons to search for peaks within Inverse Solution''s map '));
%% search distance to find classifier performances
% delete(h.edit_inv_dist_search_thresh_txt); delete(h.edit_inv_dist_search_thresh)
h.edit_inv_dist_search_thresh_txt = uicontrol(h.panel_peaks_found,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[sum(h.edit_inv_peak_spread.Position([1 3]))+.05 h.edit_inv_peak_spread_txt.Position(2) .175 .05],...
'Visible','on','FontSize',8,'HorizontalAlignment','left','String','Hit Search Distance (mm)');
h.edit_inv_dist_search_thresh = uicontrol(h.panel_peaks_found,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','edit','Units','normalize',...
'Position',[sum(h.edit_inv_dist_search_thresh_txt.Position([1 3]))+.005 h.edit_inv_dist_search_thresh_txt.Position(2) .075 .045],...
'Visible','on','FontSize',8,'HorizontalAlignment','center','String','25','Callback',@sm_calc_localizer_performance,...
'Tooltip',sprintf('Search distance (mm) threshold in all [X Y Z] direcitons to search for Hits relative to the true source locations'));
%% Menu: search distance type ('Nearest' 'Wave Error')
% delete(h.menu_inv_hit_search_type)
h.menu_inv_hit_search_type = uicontrol(h.panel_peaks_found,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','popupmenu','Units','normalize',...
'Position',[sum(h.edit_inv_dist_search_thresh.Position([1 3]))+.02 h.listbox_peaks_found.Position(2)-.045 .345 .035],...
'Visible','on','FontSize',8,'HorizontalAlignment','center','String',{'Nearest' 'Wave Error' 'Wave Correlation'},'Callback',@bs_plot_inv_soln,...
'Value',1,'Tooltip',sprintf('Search Type for finding Hits within the "Search Distance"\n Nearest = finds nearest peak to true source\n Wave Error = finds peak with best source waveform fit to true source\n Wave Correlation = finds peak with best waveform correlation to true source'));
%% Listbox of Peaks FC contrasts
% delete(h.listbox_plv_contrasts_txt); delete(h.listbox_plv_contrasts);
h.listbox_plv_contrasts_txt = uicontrol(h.panel_peaks_found,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor',[1 .6 0],'Units','normalize',...
'Position',[sum(h.listbox_peaks_found.Position([1 3]))+.01 .96 .225 .035],...
'FontSize',8,'HorizontalAlignment','left','String','Peak FC','FontWeight','bold');
h.listbox_plv_contrasts = uicontrol(h.panel_peaks_found,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','listbox','Units','normalize',...
'Position',[h.listbox_plv_contrasts_txt.Position(1) .71 .26 .25],...
'FontSize',8,'HorizontalAlignment','center','String',{''},'max',2,'Value',1,'Callback',{@listbox_plv_contrasts_Callback,'Peaks'});
%% Listbox of Peaks FC conttrasts
% delete(h.listbox_true_plv_contrasts_txt); delete(h.listbox_true_plv_contrasts);
h.listbox_true_plv_contrasts_txt = uicontrol(h.panel_peaks_found,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor',[0 0 0],'Units','normalize',...
'Position',[sum(h.listbox_plv_contrasts.Position([1 3]))+.01 .96 .225 .035],...
'FontSize',8,'HorizontalAlignment','left','String','True FC','FontWeight','bold');
h.listbox_true_plv_contrasts = uicontrol(h.panel_peaks_found,'BackgroundColor',h.UserData.bkg_clr,'ForegroundColor',[1 1 1]*0,'Style','listbox','Units','normalize',...
'Position',[h.listbox_true_plv_contrasts_txt.Position(1) .71 .16 .25],...
'FontSize',8,'HorizontalAlignment','center','String',{''},'max',2,'Value',1,'Callback',{@listbox_plv_contrasts_Callback,'True'});
%% %%% Sub Panel "Results" Axes for plotting
% delete(h.panel_peak_results);
h.panel_peak_results = uipanel(h.panel_peaks_found,'Title','Results','FontSize',10,'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor',[0 0 1],...
'Units','normalize','Visible','on', ...
'Position',[0 0 1 h.edit_inv_dist_search_thresh.Position(2)-.005]);
%% Tabs for Peak Result
h.tabgrp_peak_results = uitabgroup(h.panel_peak_results,'Units','normalize','Position',[0 0 1 1],'Visible','on');
%% %%% SubPanel Tab for "Localziation Errors"
h.tab_peak_results_localization = uitab(h.tabgrp_peak_results,'Title','Current Errors','BackgroundColor',[1 1 1],'Foregroundcolor',[0 0 1]);
%% Text - Inv_soln performance
% delete(h.text_inv_soln_performance)
h.text_inv_soln_performance = uicontrol(h.tab_peak_results_localization,'Style','text', 'BackgroundColor',h.UserData.bkg_clr,'Foregroundcolor','k','Units','normalize',...
'Position',[.01 1-.05 .98 .035],...
'Visible','on','FontSize',8,'HorizontalAlignment','left','String',sprintf('Hits=0; Misses=0; FA=0; CR=0; MCC=0'),...
'Tooltip',sprintf('CR=Correct Rejections\nFA=False Alarms (above lowest Hit value)\nMCC=Mathews Correlation Coefficient'));
%% axes for Errors (MSE) in peak localization, orientations, source waveforms
% delete(h.axes_invSoln_errors_locs); delete(h.axes_invSoln_errors_ori); delete(h.axes_invSoln_errors_waves); delete(h.axes_invSoln_halfmax_width);
ysize = .3; ypos = [.05 .55]; xsize = .35; xpos = [.1 .6 .725];
h.axes_invSoln_errors_locs = axes(h.tab_peak_results_localization,'Position',[xpos(1) ypos(2) xsize ysize]); box on; title(h.axes_invSoln_errors_locs,sprintf('Location\nError'));
h.axes_invSoln_errors_ori = axes(h.tab_peak_results_localization,'Position',[xpos(2) ypos(2) xsize ysize]); box on; title(h.axes_invSoln_errors_ori,sprintf('Orientation\nError'));
h.axes_invSoln_errors_waves = axes(h.tab_peak_results_localization,'Position',[xpos(1) ypos(1) xsize ysize]); box on; title(h.axes_invSoln_errors_waves,sprintf('Wave\nError'));
h.axes_invSoln_halfmax_width = axes(h.tab_peak_results_localization,'Position',[xpos(2) ypos(1) xsize ysize]); box on; title(h.axes_invSoln_halfmax_width,sprintf('Half-Max\n Width (mm)')); h.axes_invSoln_halfmax_width.XLabel.String = 'Peaks';
%% %%% SubPanel Tab for "Performance" - MCC plots and ROC curves(TPR/FPR)
% delete(h.tab_peak_results_performance);
h.tab_peak_results_performance = uitab(h.tabgrp_peak_results,'Title','Performance','BackgroundColor',[1 1 1],'Foregroundcolor',[0 0 1]);
%% axes for Performances stepwise and std thresholding for MCC and ROC curves
ysize = [.325 .325]; ypos = [.1 .6]; xsize = .375; xpos = [.1 .6];
h.axes_invSoln_perf_ROC_stepwise = axes(h.tab_peak_results_performance,'Position',[xpos(1) ypos(2) xsize ysize(2)]); box on; title(h.axes_invSoln_perf_ROC_stepwise,sprintf('Hits & FA (Step-Wise)'));
h.axes_invSoln_perf_ROC_std = axes(h.tab_peak_results_performance,'Position',[xpos(2) ypos(2) xsize ysize(2)]); box on; title(h.axes_invSoln_perf_ROC_std,sprintf('Hits & FA (StdDev)'));
h.axes_invSoln_perf_ROC_stepwise_MCC = axes(h.tab_peak_results_performance,'Position',[xpos(1) ypos(1) xsize ysize(1)]); box on; title(h.axes_invSoln_perf_ROC_stepwise_MCC,sprintf('MCC: Step-Wise Thresholded'));
h.axes_invSoln_perf_ROC_std_MCC = axes(h.tab_peak_results_performance,'Position',[xpos(2) ypos(1) xsize ysize(1)]); box on; title(h.axes_invSoln_perf_ROC_std_MCC,sprintf('MCC: StdDev Thresholded'));
%% %%% SubPanel Tab for TFR "ROC" Receiver Operating Characteristics
% delete(h.tab_peak_results_TFR_ROC);
h.tab_peak_results_TFR_ROC = uitab(h.tabgrp_peak_results,'Title','TFR ROI','BackgroundColor',[1 1 1],'Foregroundcolor',[0 0 1]);
%% axes for ROCs stepwise and surg_std thresholding
% delete(h.axes_invSoln_TFR_ROC_stepwise); delete(h.axes_invSoln_TFR_ROC_surg_std); delete(h.axes_invSoln_TFR_ROC_wave_error_mse); delete(h.axes_invSoln_TFR_ROC_wave_error_abs);
ysize = [.325 .4]; ypos = [.05 .55]; xsize = .375; xpos = [.1 .6];
h.axes_invSoln_TFR_ROC_stepwise = axes(h.tab_peak_results_TFR_ROC,'Position',[xpos(1) ypos(2) xsize ysize(2)]); box on; title(h.axes_invSoln_TFR_ROC_stepwise,sprintf('Step-Wise Thresholded'));
h.axes_invSoln_TFR_ROC_surg_std = axes(h.tab_peak_results_TFR_ROC,'Position',[xpos(2) ypos(2) xsize ysize(2)]); box on; title(h.axes_invSoln_TFR_ROC_surg_std,sprintf('Surrogate StdDev Thresholded'));
h.axes_invSoln_TFR_ROC_wave_error_mse = axes(h.tab_peak_results_TFR_ROC,'Position',[xpos(1) ypos(1) xsize ysize(1)]); box on; title(h.axes_invSoln_TFR_ROC_wave_error_mse,sprintf('ROI: TFR wave Error (MSE)'));
h.axes_invSoln_TFR_ROC_wave_error_abs = axes(h.tab_peak_results_TFR_ROC,'Position',[xpos(2) ypos(1) xsize ysize(1)]); box on; title(h.axes_invSoln_TFR_ROC_wave_error_abs,sprintf('ROI: TFR wave Error (Absolute)'));
%% %%% SubPanel Tab for FC "ROC" Receiver Operating Characteristics
% delete(h.tab_peak_results_FC_ROC);
h.tab_peak_results_FC_ROC = uitab(h.tabgrp_peak_results,'Title','FC ROI','BackgroundColor',[1 1 1],'Foregroundcolor',[0 0 1]);
%% axes for ROCs stepwise and surg_std thresholding
% delete(h.axes_invSoln_FC_ROC_stepwise); delete(h.axes_invSoln_FC_ROC_surg_std); delete(h.axes_invSoln_FC_ROC_wave_error_mse); delete(h.axes_invSoln_FC_ROC_wave_error_abs);
ysize = [.325 .4]; ypos = [.05 .55]; xsize = .375; xpos = [.1 .6];
h.axes_invSoln_FC_ROC_stepwise = axes(h.tab_peak_results_FC_ROC,'Position',[xpos(1) ypos(2) xsize ysize(2)]); box on; title(h.axes_invSoln_FC_ROC_stepwise,sprintf('Step-Wise Thresholded'));
h.axes_invSoln_FC_ROC_surg_std = axes(h.tab_peak_results_FC_ROC,'Position',[xpos(2) ypos(2) xsize ysize(2)]); box on; title(h.axes_invSoln_FC_ROC_surg_std,sprintf('Surrogate StdDev Thresholded'));
h.axes_invSoln_FC_ROC_wave_error_mse = axes(h.tab_peak_results_FC_ROC,'Position',[xpos(1) ypos(1) xsize ysize(1)]); box on; title(h.axes_invSoln_FC_ROC_wave_error_mse,sprintf('ROI: FC wave Error (MSE)'));
h.axes_invSoln_FC_ROC_wave_error_abs = axes(h.tab_peak_results_FC_ROC,'Position',[xpos(2) ypos(1) xsize ysize(1)]); box on; title(h.axes_invSoln_FC_ROC_wave_error_abs,sprintf('ROI: FC wave Error (Absolute)'));