-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathaedes.m
More file actions
11218 lines (9803 loc) · 327 KB
/
Copy pathaedes.m
File metadata and controls
11218 lines (9803 loc) · 327 KB
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
function aedes(DATA,ROI,inputOverlay)
% AEDES - Graphical user interface for analyzing MRI images
%
%
% Synopsis:
% aedes(InArg)
%
% or
%
% aedes
%
% Description:
% AEDES is a graphic user interface (GUI) based tool for region
% of interest (ROI) analysis of (mainly) MRI images.
%
% The input argument InArg is optional. If the function is called
% without input arguments, an empty GUI window is initialized. InArg
% can be a DATA structure, containing at least the FTDATA and HDR
% fields, and a string or a cell array of strings containing the full
% path(s) to supported data file(s). Input argument can also be a 2D,
% 3D, or 4D-matrix containing image slices and possibly volumes in the
% 4th dimension.
%
% Examples:
% %% Example 1
% aedes % Initialize an empty GUI window
%
% %% Example 2
% DataMtx = rand(100); % Generate a 100x100 random matrix
% aedes(DataMtx) % Open the data in Aedes
%
% %% Example 3
% DATA=aedes_data_read; % Read various image data to a DATA-structure
% aedes(DATA) % Open data in Aedes
%
% %% Example 4
% % Read data from file with path given as a string
% aedes('C:\MyDataDirectory\MyDataFiles\MyData.fid')
%
% %% Example 5
% % Read data from multiple files given as a cell
% % array. Each file has to contain only one slice.
% files={'C:\MyData\MyDataFile1.nii','C:\MyData\MyDataFile1.nii'};
% aedes(files)
%
% See also:
% AEDES_DATA_READ, AEDES_READFID, AEDES_RESVIEWER, AEDES_JUIGETFILES
% Aedes - A graphical tool for analyzing medical images
%
% Copyright (C) 2006 Juha-Pekka Niskanen <Juha-Pekka.Niskanen@uku.fi>
%
% Department of Physics, Department of Neurobiology
% University of Eastern Finland, Kuopio, FINLAND
%
% This program may be used under the terms of the GNU General Public
% License version 2.0 as published by the Free Software Foundation
% and appearing in the file LICENSE.TXT included in the packaging of
% this program.
%
% This program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
% WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
% Define "public" variables. Since Aedes utilizes nested functions,
% these variables will be visible to all the subfunctions.
H = []; % Handles structure. Contains all handles to figure,
% uicontrols, axes, etc...
Dat = []; % Internal data structure for exchanging information between
% functions
switch nargin
case 0;
DATA = []; % The data structure containing image data and header
ROI = []; % The ROI structure
inputOverlay = [];
case 1
ROI = [];
inputOverlay = [];
case 2
inputOverlay = [];
end
% % Auto-check for updates ------------------------------
% try
% if getpref('Aedes','AutoCheckUpdates')
% Dat=aedes_update('semiprompt');
% if Dat
% return
% else
% Dat = [];
% end
% end
% catch
% % pass
% end
% Detect Matlab version
[Dat.MatlabVersion,Dat.isImageProc] = aedes_getmatlabversion;
% Show license and warranty notification ----------------
%
% NOTE: You can disable this license notification using the following
% command: setpref('Aedes','ShowLicenseAtStartUp',false)
if ~ispref('Aedes','ShowLicenseAtStartUp') || ...
getpref('Aedes','ShowLicenseAtStartUp')
l_PrintLicense([],[]);
end
%% Parse input arguments -------------------------
if nargin>0
if ischar(DATA) %% String input
tmp_filename = DATA;
DATA = [];
% Draw blank GUI
H=l_draw_gui();
% Read data and initialize
l_OpenFile([],[],'single',tmp_filename)
% Initialize GUI
%l_Initialize([],[])
elseif iscell(DATA) %% Cell input
if ischar(DATA{1})
tmp_filename = DATA;
DATA = [];
% Draw blank GUI
H=l_draw_gui();
% Read data and initialize
l_OpenFile([],[],'multi',tmp_filename)
% Initialize GUI
%l_Initialize([],[])
elseif ~isstruct(DATA{1})
error('Invalid type for input argument!')
else
% Draw blank GUI
H=l_draw_gui();
% Initialize GUI
l_Initialize([],[])
end
else
if isstruct(DATA) %% Structure input
DATA = {DATA};
% Check if kspace should be viewed
if isfield(DATA{1},'KSPACE') && ...
(isempty(DATA{1}.FTDATA) & ~isempty(DATA{1}.KSPACE))
resp=questdlg(['The inputted DATA structure contains only k-space',...
' information. Do you want to view real, imaginary, or absolute',...
' part of the complex k-space?'],...
'Complex data inputted',...
'Real','Imaginary','Absolute','Absolute');
if strcmpi(resp,'Real')
DATA{1}.FTDATA = real(DATA{1}.KSPACE);
elseif strcmpi(resp,'Imaginary')
DATA{1}.FTDATA = imag(DATA{1}.KSPACE);
elseif strcmpi(resp,'Absolute')
DATA{1}.FTDATA = abs(DATA{1}.KSPACE);
else
% Canceled
return
end
%DATA{1}.FTDATA = abs(DATA{1}.KSPACE);
end
elseif isnumeric(DATA) || islogical(DATA)
if isreal(DATA)
DATA_tmp=DATA;
else
resp=questdlg(['The inputted data is complex. Do you want ' ...
'to view real, imaginary, or absolute part of the data?'],...
'Complex data inputted',...
'Real','Imaginary','Absolute','Absolute');
if strcmpi(resp,'Real')
DATA_tmp = real(DATA);
elseif strcmpi(resp,'Imaginary')
DATA_tmp = imag(DATA);
else
DATA_tmp = abs(DATA);
end
end
DATA=[];
DATA.FTDATA = DATA_tmp;
DATA.HDR.fpath = '';
DATA.HDR.fname = '';
DATA={DATA};
clear DATA_tmp
else
error('Invalid type for input argument')
end
% Draw blank GUI
H=l_draw_gui();
% Initialize GUI
l_Initialize([],[])
end
% Load ROI if given as input argument
if nargin>1
if ~isempty(ROI)
l_RoiLoad([],[],'');
end
if nargin==3 && ~isempty(inputOverlay)
% Load overlay
l_LoadImageOverlay([],[],'inputarg')
end
end
else
% Open an empty GUI window, if called without input arguments
H=l_draw_gui;
end
% Build plugins menu
l_BuildPluginsMenu();
% Wait for quit in standalone
if isdeployed
waitfor(H.FIG)
end
% Debug function - paste debug information into workspace...
function l_debug(h,evd)
assignin('base','DATA',DATA);
assignin('base','H',H);
assignin('base','ROI',ROI);
assignin('base','Dat',Dat);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%
% CHECK FOR UPDATES
%%%%%%%%%%%%%%%%%%%%%%%%%%
function l_CheckUpdates(h,evd)
done = aedes_update('prompt');
end
%%%%%%%%%%%%%%%%%%%%%%%%%%
% DRAW GUI
%%%%%%%%%%%%%%%%%%%%%%%%%%
function H=l_draw_gui()
%% Toggle debug on/off
debug=true;
%% Determine paths
tmp=which('aedes');
[fp,fn,fe]=fileparts(tmp);
Dat.AedesFolder = [fp,filesep];
Dat.PluginsFolder = [Dat.AedesFolder,'plugins',filesep];
Dat.IconsFolder = [Dat.AedesFolder,'icons',filesep];
Dat.TablibFolder = [Dat.AedesFolder,'tablib',filesep];
%% Figure Size Definitions ----------------
taskbar_sz = 70; % The windows taskbar height in pixels
fig_w = 1000; % Screen width in pixels
fig_h = 661;%768-taskbar_sz; % Screen height in pixels
dx = 1/fig_w; % Horizontal space
dy = 1/fig_h; % Vertical space
dxx = 5*dx; % Horizontal big space
dyy = 5*dy; % Vertical big space
btn_h = 25/fig_h; % Push button height
btn_w = 75/fig_w; % Push button width
btns_w = 25/fig_w;
popup_h = 25/fig_h; % Popup menu height
popup_w = 100/fig_w; % Popup menu width
edit_w = 45/fig_w; % Edit box width
edit_h = 20/fig_h; % Edit box height
%% Load default font and colors
if isunix
DefaultColor = [239 235 222]/255;
else
DefaultColor=get(0,'DefaultUicontrolBackgroundcolor');
end
GD=aedes_gui_defaults;
GD.col.frame = DefaultColor;
Dat.HG2graphics = GD.HG2graphics;
% Calculate default position for Aedes window
try
% If multiple monitors are connected, draw Aedes on the monitor where the
% mouse cursor is located
scrsz = get(0,'MonitorPositions');
ind = aedes_getcurrentmonitor;
fig_pos = [scrsz(ind,3)/2-fig_w/2 scrsz(ind,4)/2-fig_h/2-20 fig_w fig_h];
fig_pos(1) = fig_pos(1)+scrsz(ind,1);
catch
% Get screen size
scrsz=get(0,'ScreenSize');
% Calculate gui position on the center of the screen
fig_pos = [scrsz(3)/2-fig_w/2 scrsz(4)/2-fig_h/2-20 fig_w fig_h];
end
%% Check if other Aedes windows exist
figs=findall(0,'tag','aedes_main_fig');
if ~isempty(figs)
tmp_pos=get(figs(1),'position');
fig_pos(1)=tmp_pos(1)+15;
fig_pos(2)=tmp_pos(2)-15;
end
%% Draw main figure
H.FIG=figure('Position',fig_pos, ...
'Units','Pixel', ...
'Name','Aedes 1.0', ...
'Numbertitle','off', ...
'Tag','aedes_main_fig', ...
'Color',GD.col.mainfig, ...
'Toolbar','none', ...
'Menubar','none', ...
'DockControls','off',...
'renderer','OpenGL',...
'KeyPressFcn',@l_KeyPressFcn,...
'CloseRequestFcn',@l_quit,...
'Handlevisibility','off');
if ~Dat.HG2graphics
set(H.FIG,'DoubleBuffer','on')
end
% File Uimenu ---------------------------
file_h = uimenu('Label','File','Accelerator','F', ...
'Parent',H.FIG);
H.FILEMENU_NEW = uimenu(file_h,'Label','New window',...
'Callback','aedes');
H.FILEMENU_OPEN_SINGLE = uimenu(file_h,'Label','&Open File',...
'Accelerator','O', ...
'Callback',{@l_OpenFile,'single'},'Tag', ...
'open_single_file',...
'separator','on');
H.FILEMENU_OPEN_MULTI = uimenu(file_h,'Label','Open &Multiple Files',...
'Callback',{@l_OpenFile,'multi'},'Tag', ...
'open_multiple_file');
H.FILEMENU_OPEN_RECENT = uimenu(file_h,'Label','Open Recent',...
'Tag','open_recent',...
'separator','on');
l_BuildRecentFilesMenu([],[],H.FILEMENU_OPEN_RECENT);
H.FILEMENU_SAVE_IMAGE = uimenu(file_h,'Label','Save Image Data as', ...
'Callback',@l_SaveImageData, ...
'Separator','on','userdata','','enable','off');
H.FILEMENU_SAVERES = uimenu(file_h,'Label','Save results as','Accelerator','S', ...
'Callback',{@l_SaveResults,[]}, ...
'Separator','off','userdata','','enable','off');
H.FILEMENU_EXPORT = uimenu(file_h,'Label','Export Image Data...', ...
'Callback',@l_ExportImages, ...
'Separator','on','userdata','','enable','off');
% $$$ H.FILEMENU_PRINT = uimenu(file_h,'Label','Print...', ...
% $$$ 'Callback',@l_Print, ...
% $$$ 'Separator','on','userdata','','enable','off');
closefile_h = uimenu(file_h,'Label','Close File', ...
'Callback',@l_CloseFile, ...
'Separator','on','userdata','','enable','off');
H.FILEMENU_QUIT = uimenu(file_h,'Label','Exit Aedes','Accelerator','Q', ...
'Callback',@l_quit,'Separator','on');
% Edit Uimenu ---------------------------------
edit_h = uimenu('Label','Edit', ...
'Parent',H.FIG,...
'enable','off');
H.UIEDIT_IMSTACK = uimenu(edit_h,'Label','&Image Stack',...
'Callback',@l_EditImageStack,...
'separator','off',...
'enable','off');
% Unfold data
H.UNFOLD_DATA = uimenu(edit_h,'Label','Unfold data',...
'Callback',@l_UnfoldData,...
'separator','on',...
'enable','off');
% Rotate/flip view
rotate_h=uimenu(edit_h,'Label','Rotate/Flip Images','separator','on',...
'enable','off');
H.UIMENU_ROTATEFLIP = rotate_h;
rot_h=uimenu(rotate_h,'Label','Rotate Current Slice');
tmp_str={'90','180','270'};
for ii=1:3
H.ROTATE(ii) = uimenu(rot_h,'Label',[tmp_str{ii},char(176)],...
'callback',...
{@l_RotateFlip,tmp_str{ii}});
end
flip_h=uimenu(rotate_h,'Label','Flip Current Slice');
tmp_str={'FlipLR','FlipUD'};
for ii=1:2
H.FLIP(ii) = uimenu(flip_h,'Label',tmp_str{ii},...
'callback',...
{@l_RotateFlip,tmp_str{ii}});
end
rotcustom_h = uimenu(rotate_h,'Label','Rotate/Flip Custom...',...
'callback',...
{@l_RotateFlip,'custom'},...
'separator','on');
H.UIROTRESET = uimenu(rotate_h,'Label','Reset Rotation/Flip',...
'callback',...
{@l_RotateFlip,'reset'},...
'separator','on');
% Rotate/Flip volumes ----------------------------------------
rotate3d_h=uimenu(edit_h,'Label','Rotate/Flip Volumes','separator','off',...
'enable','off');
H.UIMENU_ROTATEFLIP3D = rotate3d_h;
rot3d_h=uimenu(rotate3d_h,'Label','Rotate');
flip3d_h=uimenu(rotate3d_h,'Label','Flip');
tmpx_h = uimenu(rot3d_h,'Label','X-dir');
tmpy_h = uimenu(rot3d_h,'Label','Y-dir');
tmpz_h = uimenu(rot3d_h,'Label','Z-dir');
tmp_str={'90','180','270'};
tmp_h = [tmpx_h,tmpy_h,tmpz_h];
tmp_str2 = {'X','Y','Z'};
for kk=1:3
for ii=1:3
H.ROTATE3D(kk,ii) = uimenu(tmp_h(kk),'Label',[tmp_str{ii},char(176)],...
'callback',...
{@l_RotateFlip,['3d',tmp_str2{kk},'_',tmp_str{ii}]});
end
end
H.FLIP3D_X = uimenu(flip3d_h,'Label','X-dir',...
'callback',{@l_RotateFlip,'flipX'});
H.FLIP3D_Y = uimenu(flip3d_h,'Label','Y-dir',...
'callback',{@l_RotateFlip,'flipY'});
H.FLIP3D_Z = uimenu(flip3d_h,'Label','Z-dir',...
'callback',{@l_RotateFlip,'flipZ'});
H.FLIP3D_V = uimenu(flip3d_h,'Label','V-dir',...
'callback',{@l_RotateFlip,'flipV'},...
'enable','off');
% View Uimenu ------------------------------
view_h = uimenu('Label','View', ...
'Parent',H.FIG,...
'enable','off');
% View XYZ (3D) direction (default)
H.UIVIEW_3D = uimenu(view_h,'Label','View 3D',...
'callback',{@l_ChangeView,0},...
'checked','on');
% View only X direction
H.UIVIEW_X = uimenu(view_h,'Label','View X direction',...
'callback',{@l_ChangeView,1},...
'separator','on');
% View only X direction
H.UIVIEW_Y = uimenu(view_h,'Label','View Y direction',...
'callback',{@l_ChangeView,2});
% View only X direction
H.UIVIEW_Z = uimenu(view_h,'Label','View Z direction',...
'callback',{@l_ChangeView,3});
% View axes ticks and grid
H.UIVIEW_GRID = uimenu(view_h,'Label','Show Grid',...
'callback',{@l_ViewAxesUnits,'pixel'},...
'separator','on',...
'checked','off');
% View Header in aedes_headerbrowser
H.viewheader_h = uimenu(view_h,'Label','File Header',...
'callback',@l_LaunchHeaderBrowser,...
'enable','on','Accelerator','H',...
'separator','on');
% Show Info text background
H.UIVIEW_INFOTXTBACKGROUND = uimenu(view_h,'Label','Info/ROI Text Background',...
'callback',@l_InfoTextBackground,...
'separator','on',...
'checked','off');
% View Voxel Time Series
H.UIVIEW_TIMESERIES = uimenu(view_h,'Label','Voxel time-series',...
'callback',{@l_ShowTimeSeries,'toggle'},...
'separator','on',...
'checked','off');
% % Volume menu
% H.UIVIEW_VOL = uimenu(view_h,'Label','Select volume',...
% 'separator','on');
%
% $$$ H.UIVIEW_FOV_UNITS = uimenu(view_h,'Label','View FOV units',...
% $$$ 'callback',{@l_ViewAxesUnits,'FOV'},...
% $$$ 'checked','off');
% $$$ flipcustom_h=uimenu(rotate_h,'Label','Flip Custom',...
% $$$ 'callback',...
% $$$ {@l_RotateZoom,'flip','custom'},...
% $$$ 'separator','off');
% % Zoom view
% tmp_str={'normalized',...
% '0.5x',...
% '1x',...
% '2x',...
% '3x',...
% '4x',...
% '5x',...
% '6x',...
% '7x',...
% '8x',...
% '9x',...
% '10x',...
% '11x',...
% '12x',...
% '13x',...
% '14x',...
% '15x',...
% '16x',...
% '17x',...
% '18x',...
% '19x',...
% '20x'};
% tmp_fact = [0 0.5 1 2 3 4 5 6 7 8 9 10 ...
% 11 12 13 14 15 16 17 18 19 20];
% zoom_h=uimenu(view_h,'Label','Zoom',...
% 'separator','on');
% for ii=1:length(tmp_str)
% H.UIZOOM(ii)=uimenu(zoom_h,'Label',tmp_str{ii},...
% 'callback',{@l_Zoom,tmp_fact(ii)},...
% 'tag',['uizoom_' num2str(tmp_fact(ii))],...
% 'userdata',tmp_fact(ii));
% if ii==2
% set(H.UIZOOM(ii),'separator','on')
% end
% end
% set(H.UIZOOM(3),'checked','on')
% TOOLS UIMENU -------------------------------------
tools_h = uimenu('Label','Tools', ...
'Parent',H.FIG,...
'enable','on');
vnmredit_h = uimenu(tools_h,'Label','Edit VNMR defaults', ...
'callback','aedes_readfidprefs',...
'enable','on');
resview_h = uimenu(tools_h,'Label','Results Viewer', ...
'callback','aedes_resviewer',...
'enable','on',...
'separator','on');
% update_h = uimenu(tools_h,'Label','Check for updates', ...
% 'callback',@l_CheckUpdates,...
% 'enable','on',...
% 'separator','on');
% Overlay menu ---------------------------------------
H.UIOVERLAY = uimenu('Label','Overlay', ...
'Parent',H.FIG,...
'enable','off');
load_overlay_h = uimenu(H.UIOVERLAY,'Label','Load Image Overlay', ...
'separator','off',...
'enable','on');
uimenu(load_overlay_h,'Label','From File', ...
'callback',{@l_LoadImageOverlay,'file'},...
'separator','off',...
'enable','on');
uimenu(load_overlay_h,'Label','From Variable', ...
'callback',{@l_LoadImageOverlay,'var'},...
'separator','on',...
'enable','on');
H.UIOVERLAY_SAVE = uimenu(H.UIOVERLAY,'Label','Save Overlay to file', ...
'callback',{@l_OverlayControls,'save'},...
'separator','on',...
'enable','off');
H.UIOVERLAY_CONTROLS = uimenu(H.UIOVERLAY,'Label','Show Overlay Controls', ...
'callback',{@l_OverlayControls,'show'},...
'separator','on',...
'enable','off');
H.UIOVERLAY_DELETE = uimenu(H.UIOVERLAY,'Label','Delete Image Overlay', ...
'callback',{@l_OverlayControls,'delete'},...
'separator','on',...
'enable','off');
% ROI Tools ------------------------------------------
roi_tools_h = uimenu('Label','ROI', ...
'Parent',H.FIG,...
'enable','off');
% $$$ H.UIROITOOLS_AUTOCLOSE = uimenu(roi_tools_h,'Label','Autoclose',...
% $$$ 'callback',...
% $$$ ['if strcmp(get(gcbo,''checked''),''on''),' ...
% $$$ 'set(gcbo,''checked'',''off''),else,' ...
% $$$ 'set(gcbo,''checked'',''on''),end'],...
% $$$ 'checked','off');
H.UIROITOOLS_LOAD = uimenu(roi_tools_h,'Label','Load ROI(s)',...
'callback',{@l_RoiLoad,'interactive'},...
'separator','off');
H.UIROITOOLS_SAVE = uimenu(roi_tools_h,'Label','Save ROI(s)',...
'callback',@l_RoiSave,...
'separator','off',...
'enable','off');
H.UIROITOOLS_SAVETEMPLATE = uimenu(roi_tools_h,'Label','Save ROI template',...
'callback',{@l_RoiSave,'template'},...
'separator','off',...
'enable','off');
H.UIROISTATS = uimenu(roi_tools_h,'Label','View/Export ROI Statistics',...
'callback',@l_RoiViewStats,...
'separator','on',...
'enable','off');
H.UIROITOOLS_COPY = uimenu(roi_tools_h,'Label','Copy ROI',...
'separator','on',...
'enable','off');
H.UIROITOOLS_COPYSLICES = uimenu(H.UIROITOOLS_COPY,'Label','Copy ROI to slices/volumes',...
'callback',@l_RoiCopy,...
'separator','off',...
'enable','on');
H.UIROITOOLS_COPYADD = uimenu(H.UIROITOOLS_COPY,'Label','Copy current ROI to new',...
'callback',{@l_RoiAdd,'copy'},...
'separator','off',...
'enable','on');
H.UIROITOOLS_FLIP = uimenu(roi_tools_h,'Label','Flip current ROI',...
'separator','off',...
'enable','off');
tmp_str={'FlipLR','FlipUD'};
for ii=1:2
H.ROIFLIP(ii) = uimenu(H.UIROITOOLS_FLIP,'Label',tmp_str{ii},...
'callback',...
{@l_RoiFlip,tmp_str{ii}});
end
H.UIROITOOLS_COMP = uimenu(roi_tools_h,'Label','Boolean operations',...
'callback',@l_RoiBooleanOperations,...
'separator','off',...
'checked','off',...
'enable','off');
H.UIROISHOWEDGES = uimenu(roi_tools_h,'Label','Show ROI edges',...
'callback',@l_UiRoiEdgesCB,...
'separator','off',...
'checked','off',...
'enable','off');
H.UIROIRENAME = uimenu(roi_tools_h,'Label','Rename current ROI',...
'callback',@l_RoiRename,...
'separator','off',...
'checked','off',...
'enable','off');
H.UIROISETCOLOR = uimenu(roi_tools_h,'Label','Set current ROI color',...
'callback',@l_RoiSetColor,...
'separator','off',...
'checked','off',...
'enable','off');
H.UIROITOOLS_UNDO = uimenu(roi_tools_h,'Label','Undo draw (0)',...
'callback',@l_RoiUndo,...
'separator','on',...
'enable','off',...
'accelerator','z');
%% Plugins menu --------------------------------------------------------
%% DO NOT ADD/REMOVE PLUGINS FROM HERE.
% Construct plugins uimenu
H.UIPLUGINS = uimenu('Label','Plugins', ...
'Parent',H.FIG,...
'enable','off');
%% ----------------------------------------------------------------------
%% Help uimenu
help_h = uimenu('Label','Help', ...
'Parent',H.FIG,...
'enable','on');
help_about_h = uimenu(help_h,...
'Label','About Aedes', ...
'enable','on',...
'callback','eval(get(gcbo,''userdata''))');
set(help_about_h,'userdata',...
'aedes_helpabout');
if debug
debug_h=uimenu('Label','Debug', ...
'Parent',H.FIG,...
'enable','on',...
'callback',@l_debug);
end
%% Uitoolbar controls --------------------------------
H.UITOOLBAR = uitoolbar('parent',H.FIG);
%% load CData for buttons
btn_cdata = load('aedes_cdata.mat');
H.btn_cdata = btn_cdata;
%tmp=NaN(18,20,3);
%tmp(:,3:end,:)=btn_cdata.cdata.open;
% Open file
H.UIPUSH_OPEN = uipushtool('parent',H.UITOOLBAR,...
'CData',btn_cdata.cdata.open2,...
'ClickedCallback',{@l_OpenFile,'single'},...
'TooltipString','Open a new data file');
% Open multiple files
H.UIPUSH_OPENMULTI = uipushtool('parent',H.UITOOLBAR,...
'CData',btn_cdata.cdata.openmulti,...
'ClickedCallback',{@l_OpenFile,'multi'},...
'TooltipString',...
'Open multiple single-slice data files');
% Save file
H.UIPUSH_SAVE = uipushtool('parent',H.UITOOLBAR,...
'CData',btn_cdata.cdata.save2_small,...
'ClickedCallback',{@l_SaveResults,[]},...
'TooltipString','Save',...
'enable','off');
% Print
% $$$ H.UIPUSH_PRINT = uipushtool('parent',H.UITOOLBAR,...
% $$$ 'CData',btn_cdata.cdata.print2,...
% $$$ 'ClickedCallback','',...
% $$$ 'TooltipString','Print',...
% $$$ 'enable','off');
% Zoom Normalized
H.UITOGGLE_ZOOMNORM = uitoggletool('parent',H.UITOOLBAR,...
'CData',btn_cdata.cdata.fitheight,...
'separator','on',...
'ClickedCallback',{@l_Zoom,'normalize'},...
'TooltipString','Fit to Window Height',...
'enable','off');
% Zoom in
H.UIPUSH_ZOOMIN = uipushtool('parent',H.UITOOLBAR,...
'CData',btn_cdata.cdata.zoomin,...
'separator','off',...
'ClickedCallback',{@l_Zoom,'+'},...
'TooltipString','Zoom In',...
'enable','off');
% Zoom out
H.UIPUSH_ZOOMOUT = uipushtool('parent',H.UITOOLBAR,...
'CData',btn_cdata.cdata.zoomout,...
'ClickedCallback',{@l_Zoom,'-'},...
'TooltipString','Zoom Out',...
'enable','off');
% Show/hide crosshairs
H.UITOGGLE_CROSSHAIRS = uitoggletool('parent',H.UITOOLBAR,...
'CData',btn_cdata.cdata.crosshairs_small,...
'ClickedCallback',@l_ShowHideCrossbars,...
'TooltipString','Show/Hide Crosshairs',...
'enable','off',...
'state','off',...
'separator','on');
% Show Grid
H.UITOGGLE_GRID = uitoggletool('parent',H.UITOOLBAR,...
'CData',btn_cdata.cdata.grid,...
'ClickedCallback',{@l_ViewAxesUnits,'pixel'},...
'TooltipString','Show/Hide Grid',...
'enable','off',...
'state','off',...
'separator','on');
% Show/hide colorbar
H.UITOGGLE_COLORBAR = uitoggletool('parent',H.UITOOLBAR,...
'CData',btn_cdata.cdata.colorbar,...
'ClickedCallback',@l_ShowColorbar,...
'TooltipString','Show/Hide Colorbar',...
'enable','off',...
'state','off',...
'separator','off');
% Show Info Text
H.UITOGGLE_INFO = uitoggletool('parent',H.UITOOLBAR,...
'CData',btn_cdata.cdata.about,...
'ClickedCallback',@l_UpdateInfoText,...
'TooltipString','Show/Hide Info Text',...
'enable','off',...
'state','on',...
'separator','off');
% Show image stack
H.UIPUSH_IMSTACK = uipushtool('parent',H.UITOOLBAR,...
'CData',btn_cdata.cdata.editimagestack,...
'ClickedCallback',@l_EditImageStack,...
'TooltipString','Edit Image Stack',...
'enable','off',...
'separator','on');
% Show rotate/flip custom menu
H.UIPUSH_ROTATE = uipushtool('parent',H.UITOOLBAR,...
'CData',btn_cdata.cdata.rotateflip,...
'ClickedCallback',{@l_RotateFlip,'custom'},...
'TooltipString','Rotate/Flip Custom',...
'enable','off',...
'separator','off');
% View 3D
H.UITOGGLE_VIEW3D = uitoggletool('parent',H.UITOOLBAR,...
'CData',btn_cdata.cdata.view3d,...
'ClickedCallback',{@l_ChangeView,0},...
'TooltipString','View 3D',...
'enable','off',...
'state','off',...
'separator','on');
H.UITOGGLE_VIEWX = uitoggletool('parent',H.UITOOLBAR,...
'CData',btn_cdata.cdata.viewx,...
'ClickedCallback',{@l_ChangeView,1},...
'TooltipString','View X direction',...
'enable','off',...
'state','off',...
'separator','off');
H.UITOGGLE_VIEWY = uitoggletool('parent',H.UITOOLBAR,...
'CData',btn_cdata.cdata.viewy,...
'ClickedCallback',{@l_ChangeView,2},...
'TooltipString','View Y direction',...
'enable','off',...
'state','off',...
'separator','off');
H.UITOGGLE_VIEWZ = uitoggletool('parent',H.UITOOLBAR,...
'CData',btn_cdata.cdata.viewz,...
'ClickedCallback',{@l_ChangeView,3},...
'TooltipString','View Z direction',...
'enable','off',...
'state','off',...
'separator','off');
% Mouse uitoggletools
H.UITOGGLE_ARROW = uitoggletool('parent',H.UITOOLBAR,...
'CData',btn_cdata.cdata.arrow,...
'ClickedCallback',...
['set(get(gcbo,''userdata''),''state'',''off''),' ...
'set(gcbo,''state'',''on'')'],...
'TooltipString','Mouse: Normal',...
'enable','off',...
'state','on',...
'separator','on');
H.UITOGGLE_PAN = uitoggletool('parent',H.UITOOLBAR,...
'CData',btn_cdata.cdata.pan,...
'ClickedCallback',...
['set(get(gcbo,''userdata''),''state'',''off''),' ...
'set(gcbo,''state'',''on'')'],...
'TooltipString','Mouse: Pan image',...
'enable','off',...
'state','off',...
'separator','off');
% ROI buttons
H.UITOGGLE_DRAWROI = uitoggletool('parent',H.UITOOLBAR,...
'CData',btn_cdata.cdata.freedraw,...
'ClickedCallback',...
['set(get(gcbo,''userdata''),''state'',''off''),' ...
'set(gcbo,''state'',''on'')'],...
'TooltipString','Mouse: Draw ROI',...
'enable','off',...
'state','off',...
'separator','off');
H.UITOGGLE_ERASEROI = uitoggletool('parent',H.UITOOLBAR,...
'CData',btn_cdata.cdata.eraser,...
'ClickedCallback',...
['set(get(gcbo,''userdata''),''state'',''off''),' ...
'set(gcbo,''state'',''on'')'],...
'TooltipString','Mouse: Erase ROI',...
'enable','off',...
'state','off',...
'separator','off');
H.UITOGGLE_FILLROI = uitoggletool('parent',H.UITOOLBAR,...
'CData',btn_cdata.cdata.bucketfill,...
'ClickedCallback',...
['set(get(gcbo,''userdata''),''state'',''off''),' ...
'set(gcbo,''state'',''on'')'],...
'TooltipString','Mouse: Fill ROI',...
'enable','off',...
'state','off',...
'separator','off');
H.UITOGGLE_MOVEROI = uitoggletool('parent',H.UITOOLBAR,...
'CData',btn_cdata.cdata.move,...
'ClickedCallback',...
['set(get(gcbo,''userdata''),''state'',''off''),' ...
'set(gcbo,''state'',''on'')'],...
'TooltipString','Mouse: Move ROI in slice',...
'enable','off',...
'state','off',...
'separator','off');
H.UITOGGLE_MOVEROI3D = uitoggletool('parent',H.UITOOLBAR,...
'CData',btn_cdata.cdata.move3d,...
'ClickedCallback',...
['set(get(gcbo,''userdata''),''state'',''off''),' ...
'set(gcbo,''state'',''on'')'],...
'TooltipString','Mouse: Move ROI in volume',...
'enable','off',...
'state','off',...
'separator','off');
% Show ROI statistics
H.UIPUSH_STATS_ROI = uipushtool('parent',H.UITOOLBAR,...
'CData',btn_cdata.cdata.statistics,...
'ClickedCallback',@l_RoiViewStats,...
'TooltipString','View ROI statistics',...
'enable','off',...
'separator','on');
H.UIPUSH_NEWROI = uipushtool('parent',H.UITOOLBAR,...
'CData',btn_cdata.cdata.add_small,...
'ClickedCallback',@l_RoiAdd,...
'TooltipString','New ROI',...
'enable','off',...
'separator','on');
H.UIPUSH_COPYROI = uipushtool('parent',H.UITOOLBAR,...
'CData',btn_cdata.cdata.copy_small,...
'ClickedCallback',@l_RoiCopy,...
'TooltipString','Copy ROI to slices/volumes',...
'enable','off',...
'separator','off');
% $$$ H.UIPUSH_DELETEROI = uipushtool('parent',H.UITOOLBAR,...
% $$$ 'CData',btn_cdata.cdata.delete_small,...
% $$$ 'ClickedCallback',{@l_RoiFunctions,'delete'},...
% $$$ 'TooltipString','Delete selected ROI(s)',...
% $$$ 'enable','off',...
% $$$ 'separator','off');
% $$$
% $$$ H.UIPUSH_DELETEALLROI = uipushtool('parent',H.UITOOLBAR,...
% $$$ 'CData',btn_cdata.cdata.deleteall_small,...
% $$$ 'ClickedCallback',{@l_RoiFunctions,'delete_all'},...
% $$$ 'TooltipString','Delete ALL ROI(s)',...
% $$$ 'enable','off',...
% $$$ 'separator','off');
H.UIPUSH_UNDOROI = uipushtool('parent',H.UITOOLBAR,...
'CData',btn_cdata.cdata.undo_small,...
'ClickedCallback',@l_RoiUndo,...
'TooltipString','Undo last ROI action',...
'enable','off',...
'separator','off');
set([H.UITOGGLE_ARROW,H.UITOGGLE_PAN,...
H.UITOGGLE_DRAWROI,H.UITOGGLE_ERASEROI,H.UITOGGLE_MOVEROI,...
H.UITOGGLE_MOVEROI3D,H.UITOGGLE_FILLROI],...
'userdata',[H.UITOGGLE_ARROW,H.UITOGGLE_PAN,...
H.UITOGGLE_DRAWROI,H.UITOGGLE_ERASEROI,H.UITOGGLE_MOVEROI,...
H.UITOGGLE_MOVEROI3D,H.UITOGGLE_FILLROI])
fig_pos = get(H.FIG,'position');
H.ORIG_FIG_POS = fig_pos;
%% Draw uicontrol frame behind the uicontrols
% to make them draw faster in opengl mode
H.SIDEBAR_FRAME=uicontrol('parent',H.FIG,...
'units','pixel',...
'position',[0 0 232 fig_pos(4)+2],...
'backgroundcolor',GD.col.frame,...
'style','frame',...
'visible','on');
%% Draw sidebar -------------------------------
% H.SIDEBAR=uipanel('parent',H.FIG,...
% 'units','pixel',...
% 'position',[0 0 232 fig_pos(4)+1],...
% 'backgroundcolor',GD.col.frame);