-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathGUI_FishExplorer.m
4083 lines (3504 loc) · 124 KB
/
GUI_FishExplorer.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
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
%{
------Interactive app for exploratory analysis of calcium imaging data----
(with stimulus, behavior, and anatomy)
To start, run the included script "LoadGUI.m".
Input calcium data: 1 trace per cell/ROI, ~50-100k cells per fish
load collection of cells from multiple fish, or load full data of single fish individually
main outputs: GUI plots, clusters saved into "VAR_new.mat", export variables to MATLAB workspace
Tip: to see the structure of this code, use '(Right click -> )Code Folding\Fold all'
(or hotkey) to collapse all cells.
UI controls are organized by tabs and then by rows, instructions and
comments are where they are constructed ('User Interface:' -> function hfig... ->)
General internal functions are at the end, some specialized .m functions are outside.
Written in Matlab R2016a running on Windows 7.
- Xiuye Chen ([email protected]), Engert Lab, 2016
%}
%% User Interface:
function [hfig,fcns] = GUI_FishExplorer()%data_masterdir)
%% Make figure
scrn = get(0,'Screensize');
hfig = figure('Position',[scrn(3)*0.2 scrn(4)*0.05 scrn(3)*0.75 scrn(4)*0.86],...% [50 100 1700 900]
'Name','GUI_LSh','DeleteFcn',@closefigure_Callback,...
'KeyPressFcn',@KeyPressCallback,...
'ToolBar', 'none'); % 'MenuBar', 'none'
hold off; axis off
%% Make menu
global hm1;
hm1 = uimenu(hfig,'Label','My File');
hm1_1 = uimenu(hm1,'Label','Quick save to workspace');
hm1_2 = uimenu(hm1,'Label','Save to file (default path)');
%% general setup (import external data, initialize all GUI flags etc)
InitializeAppData(hfig); % (stored under main figure handle appdata)
M_fish_set = getappdata(hfig,'M_fish_set');
nFish = length(M_fish_set);
%% setup for GUI
% GUI cache
bCache = []; % Cache for going b-ack (bad abbr)
fCache = []; % Cache for going f-orward
bCache.cIX = cell(1,1);
bCache.gIX = cell(1,1);
bCache.numK = cell(1,1);
fCache.cIX = cell(1,1);
fCache.gIX = cell(1,1);
fCache.numK = cell(1,1);
setappdata(hfig,'bCache',bCache);
setappdata(hfig,'fCache',fCache);
%% Create UI controls
set(gcf,'DefaultUicontrolUnits','normalized');
set(gcf,'defaultUicontrolBackgroundColor',[1 1 1]);
% tab group setup
tgroup = uitabgroup('Parent', hfig, 'Position', [0.05,0.88,0.91,0.12]);
numtabs = 6;
tab = cell(1,numtabs);
M_names = {'General','Operations','Regression','Clustering etc.','Saved Clusters','Atlas'};
for i = 1:numtabs,
tab{i} = uitab('Parent', tgroup, 'BackgroundColor', [1,1,1], 'Title', M_names{i});
end
% grid setup, to help align display elements
rheight = 0.2;
yrow = 0.7:-0.33:0;%0.97:-0.03:0.88;
dTextHt = 0.05; % dTextHt = manual adjustment for 'text' controls:
% (vertical alignment is top instead of center like for all other controls)
bwidth = 0.03;
grid = 0:bwidth+0.001:1;
%% global variables: various UI element handles
global hback hfwd hclusgroupmenu hclusgroupname hclusmenu hclusname...
hstimrangemenu hopID hloadfish hstimreg hmotorreg...
hcentroidreg hcentroid hstimrange hmasklistbox hshowrefanat hshowfishoutline...
h_isStimAvr h_israwtime h_iszscore hisshowmasks; % hfishnum
%% UI ----- tab one ----- (General)
i_tab = 1;
%% UI row 1: File
i_row = 1;
i = 1;n = 0;
i=i+n;
n=2; % saves both to workspace and to 'VAR_current.mat' and to arc folder
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Save .mat',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@pushbutton_savemat_Callback);
i=i+n;
n=2; % plots selected cells on anatomy z-stack, display and save tiff stack in current directory
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Save Zstack',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@pushbutton_writeZstack_Callback);
i=i+n;
n=2; % plots selected cells on anatomy z-stack, tiled display
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Tile Zstack',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@pushbutton_tileZstack_Callback);
i=i+n;
n=2; % plots selected cells on anatomy z-stack, tiled display
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Tile Clusters',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@pushbutton_tileClusters_Callback);
i=i+n;
n=2; % export main working variables to workspace, can customize!
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Export(workspace)',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@pushbutton_exporttoworkspace_Callback);
i=i+n;
n=2; %
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Import(VAR)',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@pushbutton_loadVARfromworkspace_Callback);
i=i+n;
n=2; %
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Import(current)',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@pushbutton_loadCurrentClustersfromworkspace_Callback);
i=i+n;
n=2; % create popup figure without the GUI components, can save manually from default menu
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Popup plot',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@pushbutton_popupplot_Callback);
i=i+n;
n=2; % popupplot option: whether to plot cluster mean lines instead of all raw traces
uicontrol('Parent',tab{i_tab},'Style','checkbox','String','Plot lines',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@checkbox_isPlotLines_Callback);
i=i+n;
n=2; % popupplot option: whether to plot behavior bar
uicontrol('Parent',tab{i_tab},'Style','checkbox','String','Plot behavior','Value',1,...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@checkbox_isPlotBehavior_Callback);
i=i+n;
n=2; % popupplot option: whether to only plot anatomy map (right half)
uicontrol('Parent',tab{i_tab},'Style','checkbox','String','Plot anatomy only',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@checkbox_isPlotAnatomyOnly_Callback);
i=i+n;
n=3; % popupplot option: whether to plot regressor
uicontrol('Parent',tab{i_tab},'Style','checkbox','String','Plot Regressor',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@checkbox_isPlotRegressorWithTS_Callback);
%% UI row 2: Load
i_row = 2;
i = 1;n = 0;
% i=i+n;
% n=2; % this design is underused now... Quick-load only depends on CONSTs,
% % which is a minimum collection of clusters from all fish, so you can load
% % the program without full single-fish data. eventually can use this
% % platform to do things across fish (like after anatomical alignment).
% uicontrol('Parent',tab{i_tab},'Style','text','String','Quick-load fish:',...
% 'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
%
% i=i+n;
% n=1; % loads 'CONSTs_current.mat' from current directory
% temp = {}; for j = 1:nFish, temp = [temp,{num2str(j)}];end
% hfishnum = uicontrol('Parent',tab{i_tab},'Style','popupmenu','String',temp,...
% 'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
% 'Callback',@popup_quickloadfishmenu_Callback);
i=i+n;
n=2; % loads full single-fish data from CONST_F?.mat
uicontrol('Parent',tab{i_tab},'Style','text','String','Load fish #:',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=2; %
temp = {}; for j = 1:nFish, temp = [temp,{num2str(j)}];end
temp = [{'(choose)'},temp];
hloadfish = uicontrol('Parent',tab{i_tab},'Style','popupmenu','String',temp,...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@popup_loadfullfishmenu_Callback);
i=i+n;
n=2; % only centroids (~mean) of clusters shown on left-side plot, the rest is unchanged
uicontrol('Parent',tab{i_tab},'Style','checkbox','String','Load 100% data',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],'Value',1,...
'Callback',@checkbox_isFullData_Callback);
% i=i+n;
% n=2; %
% uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','or choose files',...
% 'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
% 'Callback',@pushbutton_choosefilestoload_Callback);
i=i+n;
n=2; % options to load different stimulus types (if applicable for this fish)
uicontrol('Parent',tab{i_tab},'Style','text','String','Stim type:',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=3;
hstimrangemenu = uicontrol('Parent',tab{i_tab},'Style','popupmenu','String','(empty)',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@popup_stimrangemenu_Callback);
i=i+n;
n=2; % only centroids (~mean) of clusters shown on left-side plot, the rest is unchanged
uicontrol('Parent',tab{i_tab},'Style','checkbox','String','Motorseed',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],'Value',1,...
'Callback',@checkbox_isMotorseed_Callback);
%% UI row 3: Display
i_row = 3;
i = 1;n = 0;
i=i+n;
n=2; % only centroids (~mean) of clusters shown on left-side plot, the rest is unchanged
h_isStimAvr = uicontrol('Parent',tab{i_tab},'Style','checkbox','String','Show stim-avr',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],'Value',1,...
'Callback',@checkbox_isStimAvr_Callback);
i=i+n;
n=2; % only centroids (~mean) of clusters shown on left-side plot, the rest is unchanged
h_israwtime = uicontrol('Parent',tab{i_tab},'Style','checkbox','String','Show raw-time',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],'Value',0,...
'Callback',@checkbox_isRawtime_Callback);
i=i+n;
n=2; % showing z-scored version (each cell normalized to mean=0, std=1) on left-side plot
h_iszscore = uicontrol('Parent',tab{i_tab},'Style','checkbox','String','Show z-score',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],'Value',1,...
'Callback',@checkbox_isZscore_Callback);
i=i+n;
n=2; % functional data: functional trace minus its tiled trial-average
uicontrol('Parent',tab{i_tab},'Style','checkbox','String','Show TrialRes',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],'Value',0,...
'Callback',@checkbox_isTrialRes_Callback);
i=i+n;
n=2; % choose stimulus range - use numbers indicated in stimrangemenu % (eg 1:2,3-5)
uicontrol('Parent',tab{i_tab},'Style','text','String','Stim range:',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=1;
hstimrange = uicontrol('Parent',tab{i_tab},'Style','edit',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],'String','1:end',...
'Callback',@edit_stimrange_Callback);
i=i+n;
n=3; % only centroids (~mean) of clusters shown on left-side plot, the rest is unchanged
hcentroid = uicontrol('Parent',tab{i_tab},'Style','checkbox','String','Show cluster-centroids',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@checkbox_showcentroids_Callback);
i=i+n;
n=3; % only centroids (~mean) of clusters shown on left-side plot, the rest is unchanged
hshowrefanat = uicontrol('Parent',tab{i_tab},'Style','checkbox','String','Show normalized stack',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@checkbox_showrefanat_Callback);
i=i+n;
n=3; % only centroids (~mean) of clusters shown on left-side plot, the rest is unchanged
hshowfishoutline = uicontrol('Parent',tab{i_tab},'Style','checkbox','String','Show fish outline',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],'Value',0,...
'Callback',@checkbox_showfishoutline_Callback);
%% UI ----- tab two ----- (Operations)
i_tab = 2;
%% UI row 1: Range
i_row = 1;
i = 1;n = 0;
i=i+n;
n=2; % saves up to 20 steps backwards (datatype/stimrangemenu change does not count)
hback = uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Back',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@pushbutton_back_Callback);
i=i+n;
n=2; % same, 20 steps forward if applicable
hfwd = uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Forward',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@pushbutton_forward_Callback);
i=i+n;
n=3; % Choose range of clusters to keep. format: e.g. '1:2,4-6,8:end'
uicontrol('Parent',tab{i_tab},'Style','text','String','Select cluster range:',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=1;
uicontrol('Parent',tab{i_tab},'Style','edit',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@edit_selectclusterrange_Callback);
i=i+n;
n=2; % Choose range of clusters to exclude. format: e.g. '1:2,4-6,8:end'
uicontrol('Parent',tab{i_tab},'Style','text','String','Exclude:',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=1;
uicontrol('Parent',tab{i_tab},'Style','edit',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@edit_exclude_range_Callback);
i=i+n;
n=1; % Choose range of clusters to fuse/combine into single cluster. format: e.g. '1:2,4-6,8:end'
uicontrol('Parent',tab{i_tab},'Style','text','String','Fuse:',... % (eg 1:2,3-5)
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=1;
uicontrol('Parent',tab{i_tab},'Style','edit',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@edit_fuse_range_Callback);
%% UI row 2: Operations
i_row = 2;
i = 1;n = 0;
i=i+n;
n=2; % operates between the current cell selection and the next (in this order).
uicontrol('Parent',tab{i_tab},'Style','text','String','Set operations:',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n; % 'setdiff' is current minus next, 'rev setdiff' is next minus current.
n=2; % smartUnion = SmartUnique, cells belonging to 2 clusters goes to the more correlated one
menu = {'(choose)','union','intersect','setdiff','rev setdiff','parent full clus','rev full clus'};
hopID = uicontrol('Parent',tab{i_tab},'Style','popupmenu','String',menu,'Value',1,...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',{@popup_operations_Callback});
i=i+n;
n=2; % rank clusters based on various criteria (to choose)
uicontrol('Parent',tab{i_tab},'Style','text','String','Rank by:',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n; % 'hier' is the same as default (used after every k-means);'stim-lock' uses std across reps;
n=2; % motor stuff uses the best alignment (by cross-correlation) with the behavior trace;
% L+R is average of L & R; stim-motor is combines 'stim-lock' w 'motor' with arbituary weighting.
menu = {'(choose)','hier.','size','stim-lock','corr','motor','L motor','R motor','L+R motor',...
'fft','inverse sparseness','multi-motor w/ stim-avr','sparseness'};
uicontrol('Parent',tab{i_tab},'Style','popupmenu','String',menu,'Value',1,...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',{@popup_ranking_Callback});
i=i+n;
n=3; % cluster indices will rank from 1 to number of clusters
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Sqeeze clusters',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@pushbutton_sqeeze_Callback);
i=i+n;
n=3; % flip the sequenc of clusters, first becomes last
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Flip up-down',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@pushbutton_flipud_Callback);
% i=i+n;
% n=3; % switch between 2 colormaps now, jet and a cropped version of hsv (so not all circular)
% uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Switch colormap',...
% 'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
% 'Callback',{@pushbutton_clrmap_Callback});
i=i+n;
n=3; % loads full single-fish data from CONST_F?.mat
uicontrol('Parent',tab{i_tab},'Style','text','String','Choose colormap:',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=2; %
hloadfish = uicontrol('Parent',tab{i_tab},'Style','popupmenu',...
'String',{'hsv(new)','jet','random clrs','hsv(old)'},...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@popup_chooseclrmap_Callback);
i=i+n;
n=2; % Choose range of clusters to exclude. format: e.g. '1:2,4-6,8:end'
uicontrol('Parent',tab{i_tab},'Style','text','String','numK:',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=1;
uicontrol('Parent',tab{i_tab},'Style','edit',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@edit_manualsetnumK_Callback);
%% UI row 3: Anatomy
i_row = 3;
i = 1;n = 0;
i=i+n;
n=4; % Draw a polygon on anatomy maps to select the cells within those boundaries
uicontrol('Parent',tab{i_tab},'Style','text','String','Draw on anatomy map to crop:',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n; % Draw on the yx-view (main view)
n=2; % Click to make new vertex, double click to connect to first vertex,
% then optionally drag vertices to reposition, and finally double click again to set
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Draw yx',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@pushbutton_polygon_yx_Callback);
i=i+n;
n=2; % Draw on yz-view (side projection), same as above
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Draw yz',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@pushbutton_polygon_yz_Callback);
i=i+n;
n=2; % Draw on zx-view (front projection), same as above
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Draw zx',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@pushbutton_polygon_zx_Callback);
i=i+n;
n=5;
uicontrol('Parent',tab{i_tab},'Style','text','String','Select all cells within boundaries:',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=2; % selects ALL cells contained in dataset that are within the convex shape defined by current cells
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Convex hull',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@pushbutton_withinConvexHull_Callback);
%% UI ----- tab three ----- (Regression)
i_tab = 3;
%% UI row 1: regressor
i_row = 1; % Step 1:
i = 1;n = 0; % Choose one type of regressor here, choice highlighted in yellow
i=i+n;
n=2; % stimulus regressors, go to 'GetStimRegressor.m' to add/update
uicontrol('Parent',tab{i_tab},'Style','text','String','Stim reg.:',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=3; % (updated when loading fish)
menu = {'(choose)',''};
hstimreg = uicontrol('Parent',tab{i_tab},'Style','popupmenu','String',menu,'Value',1,...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@popup_getstimreg_Callback);
i=i+n;
n=2; % stimulus regressors, type range of stim-reg ID (e.g. '1-3,5',but can't use 'end')
uicontrol('Parent',tab{i_tab},'Style','text','String','stim combo:',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=2;
uicontrol('Parent',tab{i_tab},'Style','edit',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@edit_getstimregcombo_Callback);
i=i+n; % motor regressors from behavior, not yet convolved/adjusted for time lag
n=2; % go to 'GetMotorRegressor.m' to add/update
uicontrol('Parent',tab{i_tab},'Style','text','String','Motor reg.:',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=2; % (unlike stim regressors, names hardcoded, not importet from regressor...)
menu = {'(choose)','left swims','forward swims','right swims','raw left','raw right','raw average'};
hmotorreg = uicontrol('Parent',tab{i_tab},'Style','popupmenu','String',menu,'Value',1,...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@popup_getmotorreg_Callback);
i=i+n;
n=2; % if checked, plot regressor during selection, together with stim and motor
uicontrol('Parent',tab{i_tab},'Style','checkbox','String','Plot regressor',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],'Value',1,...
'Callback',@checkbox_popupplotreg_Callback);
i=i+n+1;
n=4; % Get centroid (~mean) of selected cluster as regressor
uicontrol('Parent',tab{i_tab},'Style','text','String','Regressor from centroid #:',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=1;
hcentroidreg = uicontrol('Parent',tab{i_tab},'Style','edit','String',num2str(1),...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@edit_ctrdID_as_reg_Callback);
%% UI row 2: regression
i_row = 2; % Step 2:
i = 1;n = 0; % Choose regression, using the regressor chosen above, search in full dataset
i=i+n;
n=3;
uicontrol('Parent',tab{i_tab},'Style','text','String','Choose regression ->',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=2; % do regression, show all cells with correlation coeff (with regressor) above threshold
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Corr. threshold:',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@pushbutton_thres_regression_Callback);
i=i+n;
n=1;
thres_reg = getappdata(hfig,'thres_reg');
uicontrol('Parent',tab{i_tab},'Style','edit','String',num2str(thres_reg),...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@edit_regthres_Callback);
i=i+n;
n=2; % optionally plot histogram of correlation values for all cells in dataset, visualize cut-off
uicontrol('Parent',tab{i_tab},'Style','checkbox','String','Plot corr. hist',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@checkbox_plotcorrhist_Callback);
i=i+n;
n=3; % probably not so useful. Show top n cells of highest correlation coeff with regressor
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','top corr., number limit:',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',{@pushbutton_topnum_regression_Callback});
i=i+n;
n=1; % specify n for above
uicontrol('Parent',tab{i_tab},'Style','edit',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@edit_topCorrNumber_Callback);
i=i+n+1; % more automatic, do a regression with every centroid, then combine (with 'SmartUnique'
n=4; % i.e. overlapping cells are assigned to the cluster with which the correlation is the highest)
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Regression with all centroids',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',{@pushbutton_allCentroidRegression_Callback});
i=i+n; % this is a remnant button from a failed experiment, idea was to iterate the regression process
n=2; % until the cluster converges, but most of the time it doesn't...
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','iter.reg','Enable','off',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',{@pushbutton_IterCentroidRegression_Callback});
i=i+n;
n=2;
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Cluster regression',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',{@pushbutton_clusterregression_Callback});
i=i+n;
n=3; % optionally plot histogram of correlation values for all cells in dataset, visualize cut-off
uicontrol('Parent',tab{i_tab},'Style','checkbox','String','(individual cells)',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],'Value',1,...
'Callback',@checkbox_isRegIndividualCells_Callback);
i=i+n;
n=3; % optionally plot histogram of correlation values for all cells in dataset, visualize cut-off
uicontrol('Parent',tab{i_tab},'Style','checkbox','String','(current cells)',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],'Value',1,...
'Callback',@checkbox_isRegCurrentCells_Callback);
%% UI row 3: t-tests, and stim-locking
i_row = 3;
i = 1;n = 0;
i=i+n;
n=2;
uicontrol('Parent',tab{i_tab},'Style','text','String','Choose stim pair:',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=1;
uicontrol('Parent',tab{i_tab},'Style','edit','String','(blank)',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@edit_tteststimrange_Callback); % e.g. '1-3,5', but can't use 'end'
i=i+n;
n=2;
uicontrol('Parent',tab{i_tab},'Style','text','String','t-test thres:',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=1;
thres_ttest = getappdata(hfig,'thres_ttest');
uicontrol('Parent',tab{i_tab},'Style','edit','String',num2str(thres_ttest),...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@edit_ttestthres_Callback);
i=i+n;
n=2;
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','t-test',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@pushbutton_ttest_Callback);
i=i+n;
n=2;
uicontrol('Parent',tab{i_tab},'Style','text','String','Stim-lock ranking %:',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=1;
uicontrol('Parent',tab{i_tab},'Style','edit','String','(blank)',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@edit_stimlockprctile_Callback); % e.g. '1-3,5', but can't use 'end'
i=i+n;
n=2;
uicontrol('Parent',tab{i_tab},'Style','text','String','%',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
% i=i+n;
% n=2;
% s = 'Choose single motor-regressor';
% uicontrol('Parent',tab{i_tab},'Style','text','String','Motor reg:',...
% 'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
%
% i=i+n;
% n=2; % (unlike stim regressors, names hardcoded, not importet from regressor...)
% menu = {'(choose)','left swims','right swims','forward swims','raw left','raw right','raw average'};
% uicontrol('Parent',tab{i_tab},'Style','popupmenu','String',menu,'Value',1,...
% 'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
% 'Callback',@popup_getmotorreg_Callback);
%% UI ----- tab four ----- (Clustering etc.)
i_tab = 4;
%% UI row 1: k-means
i_row = 1;
i = 1;n = 0;
i=i+n;
n=2; % k-means clustering
uicontrol('Parent',tab{i_tab},'Style','text','String','k-means, k =',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=1;
uicontrol('Parent',tab{i_tab},'Style','edit',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@edit_kmeans_Callback);
i=i+n;
n=4; % anatomy is added to the fluo trace as new dimensions, and (arbituarily) weighted strongly
uicontrol('Parent',tab{i_tab},'Style','text','String','k-means with anatomy, k =',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=1;
uicontrol('Parent',tab{i_tab},'Style','edit',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@edit_kmeans2_Callback);
i=i+n; % trying to use Silhouette to evaluate cluster quality, find peak to determine optimal k,
n=3; % then display results with that k. But have not set k-means to replicate (speed concern), can be very noisy
uicontrol('Parent',tab{i_tab},'Style','text','String','Find best k in range:',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=1;
uicontrol('Parent',tab{i_tab},'Style','edit',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@edit_kmeans_elbow_Callback);
%% UI row 2: Auto-clustering
i_row = 2;
i = 1;n = 0;
i=i+n; % Adjacent clusters (arranged by hier.) will be merged
n=4; % if correlation between centroids is above merging threshold
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Merge thres. (corr. based)',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',{@pushbutton_merge_Callback});
i=i+n;
n=1;
thres_merge = getappdata(hfig,'thres_merge');
uicontrol('Parent',tab{i_tab},'Style','edit','String',num2str(thres_merge),...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',{@edit_mergethres_Callback});
i=i+n; % further split initial clusters so that the average within-cluster corr coeff is above thres
n=2; % (not so iterative anymore, but could easily restore)
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Iter. split',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',{@pushbutton_iter_split});
i=i+n;
n=1;
thres_split = getappdata(hfig,'thres_split');
uicontrol('Parent',tab{i_tab},'Style','edit','String',num2str(thres_split),...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',{@edit_splitthres_Callback});
i=i+n;
n=3; % minimal size of cluster, otherwise delete at the end
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Cluster size thres.',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',{@pushbutton_thressize_Callback});
i=i+n;
n=1;
thres_size = getappdata(hfig,'thres_size');
uicontrol('Parent',tab{i_tab},'Style','edit','String',num2str(thres_size),...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',{@edit_sizethres_Callback});
i=i+n+1; % longest script here. Splits clusters and prunes them, to yield only very tight clusters.
n=3;
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Full Auto-Clustering',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',{@pushbutton_autoclus_Callback});
i=i+n;
n=3; % by default it starts with a k-mean of 20 of the current cells. Could skip that if already clustered.
uicontrol('Parent',tab{i_tab},'Style','checkbox','String','(start with k-mean)',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],'Value',1,...
'Callback',@checkbox_wkmeans_Callback);
i=i+n;
n=3; % by default it starts with a k-mean of 20 of the current cells. Could skip that if already clustered.
uicontrol('Parent',tab{i_tab},'Style','checkbox','String','(reg. with all cells)',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],'Value',1,...
'Callback',@checkbox_wAllCells_Callback);
i=i+n; % longest script here. Splits clusters and prunes them, to yield only very tight clusters.
n=3;
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Make foxels',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',{@pushbutton_makefoxels_Callback});
i=i+n; % starting with foxels
n=3;
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Auto-Clustering from foxels',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',{@pushbutton_autoclusfromfoxels_Callback});
%% UI row 3: Hier. clustering
i_row = 3;
i = 1;n = 0;
i=i+n; % k-means are always ranked like in hierachical clustering ~ optimal leaf order
n=2; % here you can rank them again and plot the dengrogram.
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Hier. plot',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@pushbutton_hierplot_Callback);
i=i+n; % partitioning based on hier. clustering
n=2; % choose between max cluster numbers...
uicontrol('Parent',tab{i_tab},'Style','text','String','Hier.cut, max n:',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=1;
uicontrol('Parent',tab{i_tab},'Style','edit',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@edit_hierpartn_Callback);
i=i+n; % partitioning based on hier. clustering
n=3; % ...or set correlation value threshold
uicontrol('Parent',tab{i_tab},'Style','text','String','Hier.cut, corr thres:',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=1;
uicontrol('Parent',tab{i_tab},'Style','edit',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@edit_hierpartthres_Callback);
i=i+n; % hier. partition in place, i.e. without rearranging order clusters
n=3;
uicontrol('Parent',tab{i_tab},'Style','checkbox','String','Hier.cut in place',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],'Value',1,...
'Callback',@checkbox_hierinplace_Callback);
i=i+n;
n=2; % Plots the correlation between all current clusters as a matrix
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Corr. plot',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',{@pushbutton_corrplot_Callback});
i=i+n;
n=3; % by default it starts with a k-mean of 20 of the current cells. Could skip that if already clustered.
uicontrol('Parent',tab{i_tab},'Style','checkbox','String','(weighted)',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],'Value',0,...
'Callback',@checkbox_corrplotweighted_Callback);
i=i+n;
n=2; % find clusters that may be artifacts (small std in any dimension)
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Artifacts',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',{@pushbutton_findartifacts_Callback});
i=i+n;
n=2; % remove clusters that may be artifacts (small std in any dimension)
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Remove artifacts',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',{@pushbutton_removeartifacts_Callback});
%% UI ----- tab five ----- (Saved Clusters)
i_tab = 5;
%% UI row 1: Cluster-Group (one level above 'Clusters')
i_row = 1;
i = 1;n = 0;
i=i+n;
n=2;
uicontrol('Parent',tab{i_tab},'Style','text','String','Group of Clusters:',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=2;
% menu = MakeNumberedMenu(VAR(i_fish).ClusGroupName);
hclusgroupmenu = uicontrol('Parent',tab{i_tab},'Style','popupmenu','String','(blank)',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@popup_clusgroupmenu_Callback);
i=i+n;
n=2;
uicontrol('Parent',tab{i_tab},'Style','text','String','Edit name:',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=2;
hclusgroupname = uicontrol('Parent',tab{i_tab},'Style','edit','String','(blank)',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@edit_clusgroupname_Callback);
i=i+n; % just adds a new number to the ClusterGroup-number menu,
n=3; % and saves current view as the first cluster in the new Clustergroup
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','New Clus.Group',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',{@pushbutton_newclusgroup_Callback});
i=i+n;
n=3; % delete current Folder
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Delete Clus.Group',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',{@pushbutton_delclusgroup_Callback});
%% UI row 2: Clusters
i_row = 2;
i = 1;n = 0;
i=i+n;
n=2;
uicontrol('Parent',tab{i_tab},'Style','text','String','Clusters:',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=3;
hclusmenu = uicontrol('Parent',tab{i_tab},'Style','popupmenu','String','(blank)',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@popup_clusmenu_Callback);
i=i+n;
n=1;
uicontrol('Parent',tab{i_tab},'Style','text','String','Edit name:',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=3;
hclusname = uicontrol('Parent',tab{i_tab},'Style','edit',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',{@edit_editclusname_Callback});
i=i+n;
n=2;
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Save cluster',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@pushbutton_saveclus_Callback);
i=i+n;
n=1;
uicontrol('Parent',tab{i_tab},'Style','text','String','New name:',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=2;
uicontrol('Parent',tab{i_tab},'Style','edit','String','(blank)',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@edit_newclusname_Callback);
i=i+n;
n=2;
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Create cluster',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@pushbutton_makeclus_Callback);
i=i+n;
n=2;
uicontrol('Parent',tab{i_tab},'Style','text','String','Set rank:',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=1;
uicontrol('Parent',tab{i_tab},'Style','edit',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',{@edit_setrank_Callback});
i=i+n;
n=1;
uicontrol('Parent',tab{i_tab},'Style','text','String','Notes:',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=2;
uicontrol('Parent',tab{i_tab},'Style','edit',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',{@edit_notes_Callback});
i=i+n;
n=2;
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Delete Cluster!',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',{@pushbutton_delclus_Callback});
%% UI row 3: misc
i_row = 3; % continuation, dealing with the Cluster groups
i = 1;n = 0; % (Cluster-group number: number menu before the Cluster-name menu)
i=i+n;
n=2; % Combines the chosen clusters into one view
uicontrol('Parent',tab{i_tab},'Style','text','String','Union(cluster):',... % (eg 1,3-5)
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=1;
uicontrol('Parent',tab{i_tab},'Style','edit',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@edit_clusUnion_Callback);
%% UI ----- tab six ----- (Atlas)
i_tab = 6;
%% UI row 1: find masks
i_row = 1;
i = 1;n = 0;
% row-height exception! listboxes are tall
i=i+n+5;
n=3; % if checked, show thresholded masks on right-side plot
hisshowmasks = uicontrol('Parent',tab{i_tab},'Style','checkbox','String','Show masks',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],'Value',1,...
'Callback',@checkbox_showmasks_Callback);
i=i+n;
n=2;
s = 'plot histogram of all masks, also printing thresholded mask-names';
uicontrol('Parent',tab{i_tab},'Style','pushbutton','String','Find masks',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',{@pushbutton_findmasks_Callback},'TooltipString',s);
i=i+n;
n=3; % if checked, control for mask size when finding relevant masks
uicontrol('Parent',tab{i_tab},'Style','checkbox','String','normalize size',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],'Value',1,...
'Callback',@checkbox_normMskSize_Callback);
i=i+n;
n=3; % if checked, control for mask size when finding relevant masks
uicontrol('Parent',tab{i_tab},'Style','checkbox','String','plot hist',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],'Value',1,...
'Callback',@checkbox_isplotMskhist_Callback);
%% UI row 2:
i_row = 2;
i = 1;n = 0;
i=i+n+5;
n=2; % display selected mask(s)
uicontrol('Parent',tab{i_tab},'Style','text','String','Draw masks:',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;
n=1; % manual input (can choose from histogram recommendation)
uicontrol('Parent',tab{i_tab},'Style','edit',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],...
'Callback',@edit_chooseMskIDtodraw_Callback);
i=i+n;
n=3; % if checked, show thresholded masks on right-side plot
uicontrol('Parent',tab{i_tab},'Style','checkbox','String','Show outline only',...
'Position',[grid(i) yrow(i_row) bwidth*n rheight],'Value',0,...
'Callback',@checkbox_showmskoutline_Callback);
i=i+n;
n=3; % select cells that fall within chosen masks
uicontrol('Parent',tab{i_tab},'Style','text','String','Screen with masks:',...
'Position',[grid(i) yrow(i_row)-dTextHt bwidth*n rheight],'HorizontalAlignment','right');
i=i+n;