-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathEvalGUI.m
2628 lines (2404 loc) · 114 KB
/
EvalGUI.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
function varargout = EvalGUI(varargin)
% GUI to evaluate the registration results
%
% opens from RegiGUI with the current registration results or from the
% command window, then, registration mat-file has to be loaded
%
% For detailed documentation see "Documentation of GUIs for MR image
% registration" (pdf).
%
% Before the first start check the path in th EvalGUI_OpeningFcnResult
%
% -------------------------------------------------------------------------
% (c) 2015: Thomas Kuestner, Verena Neumann
% -------------------------------------------------------------------------
% Last Modified by GUIDE v2.5 07-Jun-2016 16:21:30
% Begin initialization code - DO NOT EDIT
gui_Singleton = 0;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @EvalGUI_OpeningFcn, ...
'gui_OutputFcn', @EvalGUI_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% -------------------------------------------------------------------------
% basic GUI functions
% -------------------------------------------------------------------------
% --- Executes just before EvalGUI is made visible.
function EvalGUI_OpeningFcn(hObject, eventdata, handles, varargin)
%% standard paths
currpath = fileparts(mfilename('fullpath'));
if(~exist('GUIPreferences.mat','file')) % first run
SPaths.sResults = uigetdir(pwd,'Select default result directory');
SPaths.sData = uigetdir(pwd,'Select default data directory');
SPaths.sCode = currpath;
standardVoxelsize = [1,1,1];
save('GUIPreferences.mat','SPaths','standardVoxelsize');
else
load GUIPreferences.mat;
try
% check if path are reachable
if(~exist(SPaths.sResults,'dir')), error('path not existing'); end;
if(~exist(SPaths.sData,'dir')), error('path not existing'); end;
if(~exist(SPaths.sCode,'dir')), error('path not existing'); end;
catch
% loading failed or paths not reachable
clear 'SPaths' 'standardVoxelsize';
end
end
if(~exist('SPaths','var'))
% if no valid GUIPreferences are set use the standard paths:
if ~exist([currpath,filesep,'Results'],'dir'); mkdir(currpath,'results'); end
SPaths.sResults = [currpath,filesep,'results'];
SPaths.sData = [currpath,filesep,'example'];
SPaths.sCode = currpath;
end
handles.SPaths = SPaths;
% set some folders on the path
addpath(genpath([currpath,filesep,'io']));
addpath(genpath([currpath,filesep,'metrics']));
addpath(genpath([currpath,filesep,'registration']));
addpath(genpath([currpath,filesep,'segmentation']));
addpath(genpath([currpath,filesep,'utils']));
%% read inputs
if(nargin > 3)
for index = 1:2:(nargin-3),
if nargin-3==index, break, end
switch lower(varargin{index})
case 'inarg'
handles.h = varargin{index+1};
case 'egmode'
handles.EGmode = varargin{index+1};
case 'path'
h = fwaitbar(0,'Loading image data ...');
[sPathname, sFilename, sExt] = fileparts(varargin{index+1});
load([sPathname, filesep, sFilename, sExt]); fwaitbar(1,h);
try close(h); catch; end;
handles.h = SRegiResult;
if isempty(sPathname)
handles.closeFigure = true;
% Update handles structure
guidata(hObject, handles);
return;
end
handles.h.sFilename = sFilename;
handles.SPaths.sData = sPathname;
end
end
end
% when opening without data, select a data struct from the hard drive
% originating from registration with RegiGUI
if ~isfield(handles, 'h') || isempty(handles.h)
[handles.h, sPathname, sFilename] = fSelectStruct(handles);
if isempty(sPathname)
handles.closeFigure = true;
% Update handles structure
guidata(hObject, handles);
error('Missing data for viewing!');
end
handles.h.sFilename = sFilename;
handles.SPaths.sData = sPathname;
end
%% set icons
try % Try to apply a nice icon
warning('off','MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame');
jframe = get(hObject, 'javaframe');
jIcon = javax.swing.ImageIcon([currpath, filesep, 'icons', filesep, 'EvalGUI_icon.png']);
pause(0.001);
jframe.setFigureIcon(jIcon);
clear jframe jIcon
catch
warning('Could not apply a nice icon to the figure :(');
end
dImage = double(imread([currpath,filesep,'icons',filesep,'layers.png']))./255;
if size(dImage, 3) == 1, dImage = repmat(dImage, [1 1 3]); end
set(handles.pb_DispGates, 'CData', dImage/max(dImage(:)));
dImage = double(imread([currpath,filesep,'icons',filesep,'reset.png']))./255;
if size(dImage, 3) == 1, dImage = repmat(dImage, [1 1 3]); end
set(handles.pb_resetContrast, 'CData', dImage/max(dImage(:)));
dImage = double(imread([currpath,filesep,'icons',filesep,'save.png']))./255;
if size(dImage, 3) == 1, dImage = repmat(dImage, [1 1 3]); end
set(handles.pb_save, 'CData', dImage/max(dImage(:)));
dImage = double(imread([currpath,filesep,'icons',filesep,'doc_export.png']))./255;
if size(dImage, 3) == 1, dImage = repmat(dImage, [1 1 3]); end
set(handles.pb_SaveAs, 'CData', dImage/max(dImage(:)));
%% check inputs
if ~isfield(handles.h, 'SGeo') || isempty(handles.h.SGeo.cVoxelsize)
handles.h.SGeo.cVoxelsize{1} = standardVoxelsize;
handles.h.SGeo.cOrientation{1} = 'coronal';
end
if(~isfield(handles.h,'nSCT'))
if(~isfield(handles.h.SGeo, 'cOrientation'))
handles.nSCT = 1; % slice orientation (default: coronal)
else
cont = {'coronal', 'sagittal', 'transverse'};
handles.nSCT = find(strcmp(cont,handles.h.SGeo.cOrientation{1}));
end
else
handles.nSCT = handles.h.nSCT;
end
set(handles.pop_SagCorTrans,'Value',handles.nSCT)
if(~isfield(handles.h,'sRegMethod'))
handles.h.sRegMethod = 'N/A';
end
if(~isfield(handles.h, 'sParFile'))
handles.h.sParFile = 'N/A';
end
if(~isfield(handles.h, 'sFilename'))
handles.h.sFilename = 'default';
end
if(~isfield(handles.h,'sShownames'))
handles.h.sShownames = cell(1,size(handles.h.dImg,4));
end
if(~isfield(handles.h,'nRegMethod'))
handles.h.nRegMethod = 1;
end
handles.iActualGates = size(handles.h.dImg,4);
if(handles.iActualGates < 4) % if input has less than four gates
% pad with zeros
handles.h.dImg = cat(4,handles.h.dImg,zeros(size(handles.h.dImg,1),size(handles.h.dImg,2),size(handles.h.dImg,3),4-size(handles.h.dImg,4)));
handles.h.dImgReg = cat(4,handles.h.dImgReg,zeros(size(handles.h.dImgReg,1),size(handles.h.dImgReg,2),size(handles.h.dImgReg,3),4-size(handles.h.dImgReg,4)));
for iI=handles.iActualGates+1:4
handles.h.SDeform(iI).dBx = zeros(size(handles.h.SDeform(2).dBx));
handles.h.SDeform(iI).dBy = zeros(size(handles.h.SDeform(2).dBy));
handles.h.SDeform(iI).dBz = zeros(size(handles.h.SDeform(2).dBz));
handles.h.SDeform(iI).dFx = zeros(size(handles.h.SDeform(2).dFx));
handles.h.SDeform(iI).dFy = zeros(size(handles.h.SDeform(2).dFy));
handles.h.SDeform(iI).dFz = zeros(size(handles.h.SDeform(2).dFz));
handles.h.SGeo.cVoxelsize{iI} = handles.h.SGeo.cVoxelsize{1};
end
end
%% Choose default command line output for EvalGUI
handles.output = hObject;
handles.slice = max([1,floor(size(handles.h.dImg,3)/2)]); % slice number
handles.quiverScale = 1;
handles.quiverFactor = 8;
handles.dStep = [0.25, 1]; % quiverScale, quiverFactor
handles.level_set = 2;
handles.level_set_incr = 0.25;
handles.tcmap=[ 0 0 0; 7 0 17; 14 0 33; 21 0 50; 29 0 67; 36 0 84; 43 0 100; 50 0 117;
57 0 134; 64 0 150; 72 0 167; 80 3 164; 89 7 156; 97 11 149; 106 15 142; 114 19 134;
123 23 127; 131 27 119; 140 31 112; 149 35 105; 157 39 97; 166 43 90; 174 47 82;
183 51 75; 192 55 68; 200 59 60; 209 63 53; 217 67 45; 226 71 38; 234 75 31;
243 79 23; 252 83 16; 255 88 12; 255 95 12; 255 102 11; 255 109 11; 255 116 10;
255 123 10; 255 130 9; 255 137 9; 255 144 8; 255 151 8; 255 158 7; 255 165 7;
255 172 6; 255 179 6; 255 186 5; 255 193 4; 255 200 4; 255 207 3; 255 214 3; 255 221 2;
255 228 2; 255 235 1; 255 242 1; 255 249 0; 255 252 22; 255 252 55; 255 253 88;
255 253 122; 255 254 155; 255 254 188; 255 255 222; 255 255 255]/255;
handles.dView = [-30,60];
handles.dCamlight = [-45,45];
handles.jacDiv = 0; % 'gradient' method to measure change of defField
handles.sImageData='origImage'; % start with original image data (can be changed to registered images)
handles.FButtonDown = 0; % start with no pressed button
handles.newGates = 0; % the gates have not been changed yet
handles.cMetrics = {'smi', 'snmi', 'efinfo', 'rmi', 'rnmi', 'tmi', 'tnmi', 'ejp', 'gre', 'finfo', 'mssim', 'cc', 'zcc', 'spr', 'ket', 'mse', 'nmse', ...
'rmse', 'nrmse', 'psnr', 'tam', 'zca', 'zcr', 'mr', 'ssd', 'msd', 'nssd', 'sad', 'zsad', 'lsad', 'mad', 'shd', 'besov'; ...
'Shannon mutual information', 'Shannon normalized mutual information', 'exclusive F-information', 'Renyi mutual information', 'Renyi normalized mutual information', 'Tsallis mutual information', 'Tsallis normalized mutual information', 'energy of joint probability', 'gradient entropy', ...
'F-information measures', 'Mean structural similarity', '(Pearson) cross correlation', 'zero-mean normalized (Pearson) cross correlation', 'Spearman rank correlation', ...
'Kendall''s tau', 'mean squared error', 'normalized mean squared error', 'root mean squared error', 'normalized root mean squared error', 'peak signal to noise ratio', ...
'Tanimoto measure', 'zero crossings (absolute)', 'zero crossings (relative)', 'minimum ratio', 'sum of squared differences', 'median of squared differences', 'normalized sum of squared differences', ...
'sum of absolute differences', 'zero-mean sum of absolute differences', 'locally scaled sum of absolute differences', 'median of absolute differences', 'sum of hamming distance', 'besov norm'};
if(~exist('lEvalMetrics','var'))
handles.lEvalMetrics = logical([0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0]); % default to be evaluated intensity-based metrics
else
handles.lEvalMetrics = lEvalMetrics;
end
if(~isfield(handles.h.SDeform(2),'dBx'))
set(handles.rbBackward, 'Visible', 'off');
end
handles.iShown = 1:4;
handles.methods = {'elastix', 'halar', 'grics', 'LAP', 'demons'};
% normalize image data to [0,1]
for k = 1:size(handles.h.dImg,4)
dImgData = handles.h.dImg(:,:,:,k);
handles.h.dImg(:,:,:,k) = (dImgData-min(dImgData(:)))./(max(dImgData(:))-min(dImgData(:)));
dImgData = handles.h.dImgReg(:,:,:,k);
dImgData(dImgData<0) = 0;
handles.h.dImgReg(:,:,:,k) = (dImgData-min(dImgData(:)))./(max(dImgData(:))-min(dImgData(:)));
end
if isfield(handles, 'EGmode') && strcmp(handles.EGmode,'auto')
fEvalAuto(hObject,handles);
handles.closeFigure = true;
% Update handles structure
guidata(hObject, handles);
else
set(handles.cb_showQuiver,'Value',1)
% set(handles.textFilename, 'String', ['Dataset: ',handles.h.sFilename(1:min(end,94))])
% methods = {'elastix', 'halar', 'grics', 'LAP', 'demons'};
% method = methods{handles.h.nRegMethod};
handles.RegMParam = ['Registration Method: ', handles.h.sRegMethod];
handles.RegMParam = [handles.RegMParam, ', Parameter: ',handles.h.sParFile];
set(handles.tRegMParm, 'String', handles.RegMParam)
sStandardLabel = {'Image 01 (reference/fixed)'; 'Image 02'; 'Image 03'; 'Image 04'};
for iI=1:4
if(iI <= length(handles.h.sShownames) && ~isempty(handles.h.sShownames{iI}))
eval(sprintf('set(handles.txGate0%d,''String'',{sStandardLabel{iI}, handles.h.sShownames{iI}});',iI));
else % if iNGates < 4
eval(sprintf('set(handles.txGate0%d,''String'',sStandardLabel(iI));',iI));
end
end
% compute det(Jac), divergence and arrow length of deformation field
handles = fComputeDiv(handles);
% Update handles structure
guidata(hObject, handles);
% plot all gates
fPlotImageAndDefField(hObject, handles);
drawnow update;
end
function EvalGUI_ResizeFcn(hObject, eventdata, handles)
function varargout = EvalGUI_OutputFcn(hObject, eventdata, handles)
try varargout{1}= handles.output; catch; end;
if(isfield(handles,'closeFigure') && handles.closeFigure)
EvalGUI_CloseRequestFcn(hObject, eventdata, handles)
end
function EvalGUI_CloseRequestFcn(hObject, ~, handles)
% save GUIPreference
try
currpath = fileparts(mfilename('fullpath'));
if(isfield(handles,'SPaths'))
SPaths = handles.SPaths;
standardVoxelsize = [1 1 1];
lEvalMetrics = handles.lEvalMetrics;
if(exist([currpath, filesep, 'GUIPreferences.mat'],'file'))
save([currpath, filesep, 'GUIPreferences.mat'],'SPaths','standardVoxelsize', 'lEvalMetrics', '-append');
else
save([currpath, filesep, 'GUIPreferences.mat'],'SPaths','standardVoxelsize', 'lEvalMetrics');
end
end
delete(hObject);
catch
end
%% ------------------------------------------------------------------------
% callback functions
% -------------------------------------------------------------------------
function pop_SagCorTrans_Callback(hObject, eventdata, handles)
% change view between sagital, coronal and transverse slices
% get selected slice orientation
contents = cellstr(get(handles.pop_SagCorTrans,'String'));
lead=contents{get(handles.pop_SagCorTrans,'value')};
% get image array and deformation fields
dImg = handles.h.dImg;
dImgReg = handles.h.dImgReg;
dFx2 = handles.h.SDeform(2).dFx;
dFy2 = handles.h.SDeform(2).dFy;
dFz2 = handles.h.SDeform(2).dFz;
dFx3 = handles.h.SDeform(3).dFx;
dFy3 = handles.h.SDeform(3).dFy;
dFz3 = handles.h.SDeform(3).dFz;
dFx4 = handles.h.SDeform(4).dFx;
dFy4 = handles.h.SDeform(4).dFy;
dFz4 = handles.h.SDeform(4).dFz;
if(strcmp(get(handles.rbForward,'Visible'),'on'))
dBx2 = handles.h.SDeform(2).dBx;
dBy2 = handles.h.SDeform(2).dBy;
dBz2 = handles.h.SDeform(2).dBz;
dBx3 = handles.h.SDeform(3).dBx;
dBy3 = handles.h.SDeform(3).dBy;
dBz3 = handles.h.SDeform(3).dBz;
dBx4 = handles.h.SDeform(4).dBx;
dBy4 = handles.h.SDeform(4).dBy;
dBz4 = handles.h.SDeform(4).dBz;
lBackward = true;
else
lBackward = false;
end
% permutation vector for orientation changes
CorSag = [1,3,2,4];
CorTra = [3,2,1,4];
SagCor = [1,3,2,4];
SagTra = [2,3,1,4];
TraCor = [3,2,1,4];
TraSag = [3,1,2,4];
% -------------------------------------------------------------------------
% -------------------------------------------------------------------------
% very sensitive code: be attentive when changing it!
% especially Fx/Fy/Fz permutation is tricky!
switch lead % for all combinations of orientation changes:
case 'coronal'
nSCT=1; % 1. set: - flag for slice orientation
handles.quiverFactor = 8; % - standard quiver densitiy
handles.quiverScale = 1; % - standard quiver length
% set(handles.slider_quiverScale,'value', handles.quiverScale); % - slider positions
% set(handles.slider_quiverFac,'value', handles.quiverFactor);
if handles.nSCT == 2 % sag -> cor
dImgRot = permute(dImg,SagCor); % 2. a) permute all image data according to permutation vector
dImgRegRot = permute(dImgReg,SagCor);
handles.h.SDeform(2).dFx = permute(dFz2,SagCor); % b) permute all deformation fields (x, y and z coordinates)
handles.h.SDeform(2).dFz = permute(dFx2,SagCor); % c) set permuted deformFields into old ones
handles.h.SDeform(2).dFy = permute(dFy2,SagCor); % ! swap names (e.g. y <-> z) according to permutation
handles.h.SDeform(3).dFx = permute(dFz3,SagCor);
handles.h.SDeform(3).dFz = permute(dFx3,SagCor);
handles.h.SDeform(3).dFy = permute(dFy3,SagCor);
handles.h.SDeform(4).dFx = permute(dFz4,SagCor);
handles.h.SDeform(4).dFz = permute(dFx4,SagCor);
handles.h.SDeform(4).dFy = permute(dFy4,SagCor);
if(lBackward)
handles.h.SDeform(2).dBx = permute(dBz2,SagCor); % b) permute all deformation fields (x, y and z coordinates)
handles.h.SDeform(2).dBz = permute(dBx2,SagCor); % c) set permuted deformFields into old ones
handles.h.SDeform(2).dBy = permute(dBy2,SagCor); % ! swap names (e.g. y <-> z) according to permutation
handles.h.SDeform(3).dBx = permute(dBz3,SagCor);
handles.h.SDeform(3).dBz = permute(dBx3,SagCor);
handles.h.SDeform(3).dBy = permute(dBy3,SagCor);
handles.h.SDeform(4).dBx = permute(dBz4,SagCor);
handles.h.SDeform(4).dBz = permute(dBx4,SagCor);
handles.h.SDeform(4).dBy = permute(dBy4,SagCor);
end
if isfield(handles,'divF2')
handles.divF2 = permute(handles.divF2,SagCor);
handles.divF3 = permute(handles.divF3,SagCor);
handles.divF4 = permute(handles.divF4,SagCor);
end
if isfield(handles,'detJ2')
handles.detJ2 = permute(handles.detJ2,SagCor);
handles.detJ3 = permute(handles.detJ3,SagCor);
handles.detJ4 = permute(handles.detJ4,SagCor);
end
if isfield(handles,'arrL2')
handles.arrL2 = permute(handles.arrL2,SagCor);
handles.arrL3 = permute(handles.arrL3,SagCor);
handles.arrL4 = permute(handles.arrL4,SagCor);
end
if isfield(handles,'gradL2')
handles.gradL2 = permute(handles.gradL2,SagCor);
handles.gradL3 = permute(handles.gradL3,SagCor);
handles.gradL4 = permute(handles.gradL4,SagCor);
end
elseif handles.nSCT == 3 % tra -> cor
dImgRot = permute(dImg,TraCor);
dImgRegRot = permute(dImgReg,TraCor);
handles.h.SDeform(2).dFz = permute(dFy2,TraCor);
handles.h.SDeform(2).dFy = permute(dFz2,TraCor);
handles.h.SDeform(2).dFx = permute(dFx2,TraCor);
handles.h.SDeform(3).dFz = permute(dFy3,TraCor);
handles.h.SDeform(3).dFy = permute(dFz3,TraCor);
handles.h.SDeform(3).dFx = permute(dFx3,TraCor);
handles.h.SDeform(4).dFz = permute(dFy4,TraCor);
handles.h.SDeform(4).dFy = permute(dFz4,TraCor);
handles.h.SDeform(4).dFx = permute(dFx4,TraCor);
if(lBackward)
handles.h.SDeform(2).dBz = permute(dBy2,TraCor);
handles.h.SDeform(2).dBy = permute(dBz2,TraCor);
handles.h.SDeform(2).dBx = permute(dBx2,TraCor);
handles.h.SDeform(3).dBz = permute(dBy3,TraCor);
handles.h.SDeform(3).dBy = permute(dBz3,TraCor);
handles.h.SDeform(3).dBx = permute(dBx3,TraCor);
handles.h.SDeform(4).dBz = permute(dBy4,TraCor);
handles.h.SDeform(4).dBy = permute(dBz4,TraCor);
handles.h.SDeform(4).dBx = permute(dBx4,TraCor);
end
if isfield(handles,'divF2')
handles.divF2 = permute(handles.divF2,TraCor);
handles.divF3 = permute(handles.divF3,TraCor);
handles.divF4 = permute(handles.divF4,TraCor);
end
if isfield(handles,'detJ2')
handles.detJ2 = permute(handles.detJ2,TraCor);
handles.detJ3 = permute(handles.detJ3,TraCor);
handles.detJ4 = permute(handles.detJ4,TraCor);
end
if isfield(handles,'arrL2')
handles.arrL2 = permute(handles.arrL2,TraCor);
handles.arrL3 = permute(handles.arrL3,TraCor);
handles.arrL4 = permute(handles.arrL4,TraCor);
end
if isfield(handles,'gradL2')
handles.gradL2 = permute(handles.gradL2,TraCor);
handles.gradL3 = permute(handles.gradL3,TraCor);
handles.gradL4 = permute(handles.gradL4,TraCor);
end
else return % 3. do nothing, if slice orientation did not change
end
case 'sagittal'
nSCT=2;
handles.quiverFactor = 6;
handles.quiverScale = 1;
% set(handles.slider_quiverScale,'value', 4);
% set(handles.slider_quiverFac,'value', 5);
if handles.nSCT == 1 % cor -> sag
dImgRot = permute(dImg,CorSag);
dImgRegRot = permute(dImgReg,CorSag);
handles.h.SDeform(2).dFx = permute(dFz2,CorSag);
handles.h.SDeform(2).dFz = permute(dFx2,CorSag);
handles.h.SDeform(2).dFy = permute(dFy2,CorSag);
handles.h.SDeform(3).dFx = permute(dFz3,CorSag);
handles.h.SDeform(3).dFz = permute(dFx3,CorSag);
handles.h.SDeform(3).dFy = permute(dFy3,CorSag);
handles.h.SDeform(4).dFx = permute(dFz4,CorSag);
handles.h.SDeform(4).dFz = permute(dFx4,CorSag);
handles.h.SDeform(4).dFy = permute(dFy4,CorSag);
if(lBackward)
handles.h.SDeform(2).dBx = permute(dBz2,CorSag);
handles.h.SDeform(2).dBz = permute(dBx2,CorSag);
handles.h.SDeform(2).dBy = permute(dBy2,CorSag);
handles.h.SDeform(3).dBx = permute(dBz3,CorSag);
handles.h.SDeform(3).dBz = permute(dBx3,CorSag);
handles.h.SDeform(3).dBy = permute(dBy3,CorSag);
handles.h.SDeform(4).dBx = permute(dBz4,CorSag);
handles.h.SDeform(4).dBz = permute(dBx4,CorSag);
handles.h.SDeform(4).dBy = permute(dBy4,CorSag);
end
if isfield(handles,'divF2')
handles.divF2 = permute(handles.divF2,CorSag);
handles.divF3 = permute(handles.divF3,CorSag);
handles.divF4 = permute(handles.divF4,CorSag);
end
if isfield(handles,'detJ2')
handles.detJ2 = permute(handles.detJ2,CorSag);
handles.detJ3 = permute(handles.detJ3,CorSag);
handles.detJ4 = permute(handles.detJ4,CorSag);
end
if isfield(handles,'arrL2')
handles.arrL2 = permute(handles.arrL2,CorSag);
handles.arrL3 = permute(handles.arrL3,CorSag);
handles.arrL4 = permute(handles.arrL4,CorSag);
end
if isfield(handles,'gradL2')
handles.gradL2 = permute(handles.gradL2,CorSag);
handles.gradL3 = permute(handles.gradL3,CorSag);
handles.gradL4 = permute(handles.gradL4,CorSag);
end
elseif handles.nSCT == 3 % tra -> sag
dImgRot = permute(dImg,TraSag);
dImgRegRot = permute(dImgReg,TraSag);
handles.h.SDeform(2).dFy = permute(dFz2,TraSag);
handles.h.SDeform(2).dFz = permute(dFx2,TraSag);
handles.h.SDeform(2).dFx = permute(dFy2,TraSag);
handles.h.SDeform(3).dFy = permute(dFz3,TraSag);
handles.h.SDeform(3).dFz = permute(dFx3,TraSag);
handles.h.SDeform(3).dFx = permute(dFy3,TraSag);
handles.h.SDeform(4).dFy = permute(dFz4,TraSag);
handles.h.SDeform(4).dFz = permute(dFx4,TraSag);
handles.h.SDeform(4).dFx = permute(dFy4,TraSag);
if(lBackward)
handles.h.SDeform(2).dBy = permute(dBz2,TraSag);
handles.h.SDeform(2).dBz = permute(dBx2,TraSag);
handles.h.SDeform(2).dBx = permute(dBy2,TraSag);
handles.h.SDeform(3).dBy = permute(dBz3,TraSag);
handles.h.SDeform(3).dBz = permute(dBx3,TraSag);
handles.h.SDeform(3).dBx = permute(dBy3,TraSag);
handles.h.SDeform(4).dBy = permute(dBz4,TraSag);
handles.h.SDeform(4).dBz = permute(dBx4,TraSag);
handles.h.SDeform(4).dBx = permute(dBy4,TraSag);
end
if isfield(handles,'divF2')
handles.divF2 = permute(handles.divF2,TraSag);
handles.divF3 = permute(handles.divF3,TraSag);
handles.divF4 = permute(handles.divF4,TraSag);
end
if isfield(handles,'detJ2')
handles.detJ2 = permute(handles.detJ2,TraSag);
handles.detJ3 = permute(handles.detJ3,TraSag);
handles.detJ4 = permute(handles.detJ4,TraSag);
end
if isfield(handles,'arrL2')
handles.arrL2 = permute(handles.arrL2,TraSag);
handles.arrL3 = permute(handles.arrL3,TraSag);
handles.arrL4 = permute(handles.arrL4,TraSag);
end
if isfield(handles,'gradL2')
handles.gradL2 = permute(handles.gradL2,TraSag);
handles.gradL3 = permute(handles.gradL3,TraSag);
handles.gradL4 = permute(handles.gradL4,TraSag);
end
else return
end
case 'transverse'
nSCT=3;
handles.quiverFactor = 5;
handles.quiverScale = 1;
% set(handles.slider_quiverScale,'value', 4);
% set(handles.slider_quiverFac,'value', 6);
if handles.nSCT == 1 % cor -> tra
dImgRot = permute(dImg,CorTra);
dImgRegRot = permute(dImgReg,CorTra);
handles.h.SDeform(2).dFz = permute(dFy2,CorTra);
handles.h.SDeform(2).dFy = permute(dFz2,CorTra);
handles.h.SDeform(2).dFx = permute(dFx2,CorTra);
handles.h.SDeform(3).dFz = permute(dFy3,CorTra);
handles.h.SDeform(3).dFy = permute(dFz3,CorTra);
handles.h.SDeform(3).dFx = permute(dFx3,CorTra);
handles.h.SDeform(4).dFz = permute(dFy4,CorTra);
handles.h.SDeform(4).dFy = permute(dFz4,CorTra);
handles.h.SDeform(4).dFx = permute(dFx4,CorTra);
if(lBackward)
handles.h.SDeform(2).dBz = permute(dBy2,CorTra);
handles.h.SDeform(2).dBy = permute(dBz2,CorTra);
handles.h.SDeform(2).dBx = permute(dBx2,CorTra);
handles.h.SDeform(3).dBz = permute(dBy3,CorTra);
handles.h.SDeform(3).dBy = permute(dBz3,CorTra);
handles.h.SDeform(3).dBx = permute(dBx3,CorTra);
handles.h.SDeform(4).dBz = permute(dBy4,CorTra);
handles.h.SDeform(4).dBy = permute(dBz4,CorTra);
handles.h.SDeform(4).dBx = permute(dBx4,CorTra);
end
if isfield(handles,'divF2')
handles.divF2 = permute(handles.divF2,CorTra);
handles.divF3 = permute(handles.divF3,CorTra);
handles.divF4 = permute(handles.divF4,CorTra);
end
if isfield(handles,'detJ2')
handles.detJ2 = permute(handles.detJ2,CorTra);
handles.detJ3 = permute(handles.detJ3,CorTra);
handles.detJ4 = permute(handles.detJ4,CorTra);
end
if isfield(handles,'arrL2')
handles.arrL2 = permute(handles.arrL2,CorTra);
handles.arrL3 = permute(handles.arrL3,CorTra);
handles.arrL4 = permute(handles.arrL4,CorTra);
end
if isfield(handles,'gradL2')
handles.gradL2 = permute(handles.gradL2,CorTra);
handles.gradL3 = permute(handles.gradL3,CorTra);
handles.gradL4 = permute(handles.gradL4,CorTra);
end
elseif handles.nSCT == 2 % sag -> tra
dImgRot = permute(dImg,SagTra);
dImgRegRot = permute(dImgReg,SagTra);
handles.h.SDeform(2).dFz = permute(dFy2,SagTra);
handles.h.SDeform(2).dFx = permute(dFz2,SagTra);
handles.h.SDeform(2).dFy = permute(dFx2,SagTra);
handles.h.SDeform(3).dFz = permute(dFy3,SagTra);
handles.h.SDeform(3).dFx = permute(dFz3,SagTra);
handles.h.SDeform(3).dFy = permute(dFx3,SagTra);
handles.h.SDeform(4).dFz = permute(dFy4,SagTra);
handles.h.SDeform(4).dFx = permute(dFz4,SagTra);
handles.h.SDeform(4).dFy = permute(dFx4,SagTra);
if(lBackward)
handles.h.SDeform(2).dBz = permute(dBy2,SagTra);
handles.h.SDeform(2).dBx = permute(dBz2,SagTra);
handles.h.SDeform(2).dBy = permute(dBx2,SagTra);
handles.h.SDeform(3).dBz = permute(dBy3,SagTra);
handles.h.SDeform(3).dBx = permute(dBz3,SagTra);
handles.h.SDeform(3).dBy = permute(dBx3,SagTra);
handles.h.SDeform(4).dBz = permute(dBy4,SagTra);
handles.h.SDeform(4).dBx = permute(dBz4,SagTra);
handles.h.SDeform(4).dBy = permute(dBx4,SagTra);
end
if isfield(handles,'divF2')
handles.divF2 = permute(handles.divF2,SagTra);
handles.divF3 = permute(handles.divF3,SagTra);
handles.divF4 = permute(handles.divF4,SagTra);
end
if isfield(handles,'detJ2')
handles.detJ2 = permute(handles.detJ2,SagTra);
handles.detJ3 = permute(handles.detJ3,SagTra);
handles.detJ4 = permute(handles.detJ4,SagTra);
end
if isfield(handles,'arrL2')
handles.arrL2 = permute(handles.arrL2,SagTra);
handles.arrL3 = permute(handles.arrL3,SagTra);
handles.arrL4 = permute(handles.arrL4,SagTra);
end
if isfield(handles,'gradL2')
handles.gradL2 = permute(handles.gradL2,SagTra);
handles.gradL3 = permute(handles.gradL3,SagTra);
handles.gradL4 = permute(handles.gradL4,SagTra);
end
else return
end
otherwise
error('unexpected error');
end
% -------------------------------------------------------------------------
% -------------------------------------------------------------------------
set(handles.slider_quiverScale,'value', handles.quiverScale); % - slider positions
set(handles.tQuiverSize,'String',num2str(handles.quiverScale));
dVal = get(handles.slider_quiverFac, 'Max') - handles.quiverFactor + 1;
set(handles.slider_quiverFac,'value', dVal);
set(handles.txtDens,'String',num2str(1/handles.quiverFactor,'%.3f'));
% set new values in handle structure.
handles.h.dImg = dImgRot;
handles.h.dImgReg = dImgRegRot;
handles.nSCT = nSCT;
handles.slice= floor(size(handles.h.dImg,3)/2);
if(isfield(handles,'hI1'))
if(ishandle(handles.hI1))
delete(handles.hI1);
end
handles.hI1 = [];
end
if(isfield(handles,'hI'))
for n=2:4
if(ishandle(handles.hI(n)))
delete(handles.hI(n));
end
handles.hI(n) = -1;
end
end
if(isfield(handles,'hQ'))
for n=2:4
if(ishandle(handles.hQ(n)))
delete(handles.hQ(n));
end
handles.hQ(n) = -1;
end
end
% plot new slice orientation
fPlotImageAndDefField(hObject, handles)
function pb_SegLung_Callback(hObject, eventdata, handles)
% segment lung
if handles.nSCT == 2 || handles.nSCT == 3
errordlg('Please segment the lungs in the coronal view.')
return
end
% which type of image shall be segmented?
if(isfield(eventdata,'autoMode'))
qSegImg = 'transformed images';
else
qSegImg = questdlg('Which images shall be segmented?', ' ', 'original images', 'transformed images', 'transformed images');
end
switch qSegImg
case 'original images'
dImg2Seg = handles.h.dImg(:,:,:,1:handles.iActualGates);
isOrigImg = 1;
case 'transformed images'
dImg2Seg = handles.h.dImgReg(:,:,:,1:handles.iActualGates);
dImg2Seg(:,:,:,1) = handles.h.dImg(:,:,:,1);
isOrigImg = 0;
case ''
return
end
% segment lungs in the 4 gates and display overlap measures
h = fwaitbar(0,'Segmenting lungs. Please wait...'); st = 0; steps = 2*size(dImg2Seg,4)-1;
% check if there are already masks and if the gates have changed since the last computation
if (~isfield(handles,'lung3d') || handles.newGates == 1 || ~strcmp(qSegImg, handles.qSegImg))
for iI=1:size(dImg2Seg,4)
handles.lung3d{iI} = fLungSegmKohlm(dImg2Seg,iI,1); st= st+1;fwaitbar(st/steps,h);
end
else
st= size(dImg2Seg,4);fwaitbar(st/steps,h);
end
if isOrigImg % transform images according to deformation field
for iI = 2:size(dImg2Seg,4)
uB = {handles.h.SDeform(iI).dBy,handles.h.SDeform(iI).dBx,handles.h.SDeform(iI).dBz};
handles.lung3d{iI} = imshift_3D(handles.lung3d{iI},uB,'bilinear');
end
end
handles.newGate = 0; % flag reset to 0
hData.dImg = dImg2Seg;
hData.lung3d = handles.lung3d;
hData.nGate = 1;
CutOffValue = CutLungGUI('inarg', hData);
if CutOffValue == 1; try close(h); catch; end; return; end;
handles.lung3dcut = handles.lung3d;
for iI=1:size(dImg2Seg,4)
handles.lung3dcut{iI}(1:CutOffValue,:,:)= 0;
end
dice = zeros(size(dImg2Seg,4)-1,1);
jac = zeros(size(dImg2Seg,4)-1,1);
for k = 1:size(dImg2Seg,4)-1
[dice(k), jac(k)] = fEvalOverlap(handles.lung3dcut{1},handles.lung3dcut{k+1}); st= st+1;fwaitbar(st/steps,h);
end
try close(h); catch; end;
handles.qSegImg = qSegImg;
if(isOrigImg) % starting from original image
if(isfield(handles,'lung'))
handles.lung.isPerformed = handles.lung.isPerformed | [true, false]; % original images, transformed images
else
handles.lung.isPerformed = [true, false];
end
handles.lung.diceOri = dice;
handles.lung.jacOri = jac;
else
if(isfield(handles,'lung'))
handles.lung.isPerformed = handles.lung.isPerformed | [false, true]; % original images, transformed images
else
handles.lung.isPerformed = [false, true];
end
handles.lung.diceReg = dice;
handles.lung.jacReg = jac;
end
iInd = get(handles.pm_Gate,'Value');
lMap = repmat(handles.iShown,2,1);
lMap = lMap(:);
if(mod(iInd,2) == 0) % even -> transformed
if(handles.lung.isPerformed(2))
set(handles.textDice,'String',num2str(handles.lung.diceReg(lMap(iInd)-1),'%6.4g'));
set(handles.textJac,'String',num2str(handles.lung.jacReg(lMap(iInd)-1),'%6.4g'));
else
set(handles.textDice,'String', '');
set(handles.textJac,'String', '');
end
else % odd -> original
if(handles.lung.isPerformed(1))
set(handles.textDice,'String',num2str(handles.lung.diceOri(lMap(iInd)-1),'%6.4g'));
set(handles.textJac,'String',num2str(handles.lung.jacOri(lMap(iInd)-1),'%6.4g'));
else
set(handles.textDice,'String', '');
set(handles.textJac,'String', '');
end
end
guidata(hObject, handles);
function pb_lmPoints_Callback(hObject, eventdata, handles)
% open landmarkpoint GUI
h.dImg = handles.h.dImg(:,:,:,1:handles.iActualGates);
h.dImgReg = handles.h.dImgReg(:,:,:,1:handles.iActualGates);
h.SDeform = handles.h.SDeform(1:handles.iActualGates);
h.nRegMethod = handles.h.nRegMethod;
h.sFilename = handles.h.sFilename;
h.sParFile = handles.h.sParFile;
h.nSCT = handles.nSCT;
try h.SPaths = handles.h.SPaths; catch; end;
try h.SPaths = handles.SPaths; catch; end;
h.SGeo = handles.h.SGeo;
LandmarkGUI('inarg', h);
function slider_quiverFac_Callback(hObject, eventdata, handles)
% Slider for quiver Factor manipulation (density)
% get slider position and compute corresponding standard quiver Factor
x = get(hObject,'Max') - get(hObject,'Value') + 1;
% x = get(hObject,'Value');
k = get(hObject,'Min'):handles.dStep(2):get(hObject,'Max');
y = interp1(k,k,x,'nearest');
% dStep = get(hObject,'SliderStep');
% y = get(hObject,'Min'):dStep(1):get(hObject,'Max');
% y = 20:-1:1;
% y = [12,10,8,7,6,5,4,3,2,1];
% get deformation field arrays
if(get(handles.rbForward,'Value') > 0)
dFx2 = handles.h.SDeform(2).dFx;
dFy2 = handles.h.SDeform(2).dFy;
dFx3 = handles.h.SDeform(3).dFx;
dFy3 = handles.h.SDeform(3).dFy;
dFx4 = handles.h.SDeform(4).dFx;
dFy4 = handles.h.SDeform(4).dFy;
else % backward
dFx2 = handles.h.SDeform(2).dBx;
dFy2 = handles.h.SDeform(2).dBy;
dFx3 = handles.h.SDeform(3).dBx;
dFy3 = handles.h.SDeform(3).dBy;
dFx4 = handles.h.SDeform(4).dBx;
dFy4 = handles.h.SDeform(4).dBy;
end
% for different slice orientation adjust quiver Factor
% handles.quiverFactor = y(round(x));
% handles.quiverFactor = round(1/x);
handles.quiverFactor = y;
set(handles.txtDens,'String',num2str(1/handles.quiverFactor,'%.3f'));
% get new positions for quiver arrows
iX = 1:handles.quiverFactor:size(dFx2, 2);
iY = 1:handles.quiverFactor:size(dFy2, 1);
% draw new quiver arrows
% if(isfield(handles,'hQ') && handles.hQ(2) > 0 && ishandle(handles.hQ(2)))
% delete(handles.hQ(2));
% end
try
delete(handles.hQ(2));
catch
end
axes(handles.Gate02)
hold on
handles.hQ(2)=quiver(iX, iY, handles.quiverScale*dFx2(1:handles.quiverFactor:end, 1:handles.quiverFactor:end, handles.slice),...
handles.quiverScale*dFy2(1:handles.quiverFactor:end, 1:handles.quiverFactor:end, handles.slice), 0);
set(handles.hQ(2), 'Linewidth', 1.5, 'Color', 'y');
hold off
% if(isfield(handles,'hQ') && handles.hQ(3) > 0 && ishandle(handles.hQ(3)))
% delete(handles.hQ(3));
% end
try
delete(handles.hQ(3));
catch
end
axes(handles.Gate03)
hold on
handles.hQ(3)=quiver(iX, iY, handles.quiverScale*dFx3(1:handles.quiverFactor:end, 1:handles.quiverFactor:end, handles.slice),...
handles.quiverScale*dFy3(1:handles.quiverFactor:end, 1:handles.quiverFactor:end, handles.slice), 0);
set(handles.hQ(3), 'Linewidth', 1.5, 'Color', 'y');
hold off
% if(isfield(handles,'hQ') && handles.hQ(4) > 0 && ishandle(handles.hQ(4)))
% delete(handles.hQ(4));
% end
try
delete(handles.hQ(4));
catch
end
axes(handles.Gate04)
hold on
handles.hQ(4)=quiver(iX, iY, handles.quiverScale*dFx4(1:handles.quiverFactor:end, 1:handles.quiverFactor:end, handles.slice),...
handles.quiverScale*dFy4(1:handles.quiverFactor:end, 1:handles.quiverFactor:end, handles.slice), 0);
set(handles.hQ(4), 'Linewidth', 1.5, 'Color', 'y');
hold off
guidata(hObject, handles)
function slider_quiverScale_Callback(hObject, eventdata, handles)
% Slider for quiver size
% get slider position and set standard scale value
x = get(hObject,'Value');
% dStep = get(hObject,'SliderStep');
k = get(hObject,'Min'):handles.dStep(1):get(hObject,'Max');
% k = [0.25 0.5 0.75 1 1.5 2 2.5 3 4 5 6];
% y = k(round(x));
y = interp1(k,k,x,'nearest');
set(handles.tQuiverSize, 'String', num2str(y))
handles.quiverScale = y;
% get deformation field arrays
if(get(handles.rbForward,'Value') > 0)
dFx2 = handles.h.SDeform(2).dFx;
dFy2 = handles.h.SDeform(2).dFy;
dFx3 = handles.h.SDeform(3).dFx;
dFy3 = handles.h.SDeform(3).dFy;
dFx4 = handles.h.SDeform(4).dFx;
dFy4 = handles.h.SDeform(4).dFy;
else % backward
dFx2 = handles.h.SDeform(2).dBx;
dFy2 = handles.h.SDeform(2).dBy;
dFx3 = handles.h.SDeform(3).dBx;
dFy3 = handles.h.SDeform(3).dBy;
dFx4 = handles.h.SDeform(4).dBx;
dFy4 = handles.h.SDeform(4).dBy;
end
% get new positions for quiver arrows
iX = 1:handles.quiverFactor:size(dFx2, 2);
iY = 1:handles.quiverFactor:size(dFy2, 1);
% draw new quiver arrows
% if(isfield(handles,'hQ') && handles.hQ(2) > 0 && ishandle(handles.hQ(2)))
% delete(handles.hQ(2));
% end
try
delete(handles.hQ(2));
catch
end
axes(handles.Gate02)
hold on
handles.hQ(2)=quiver(iX, iY, handles.quiverScale*dFx2(1:handles.quiverFactor:end, 1:handles.quiverFactor:end, handles.slice),...
handles.quiverScale*dFy2(1:handles.quiverFactor:end, 1:handles.quiverFactor:end, handles.slice), 0);
set(handles.hQ(2), 'Linewidth', 1.5, 'Color', 'y');
hold off
% if(isfield(handles,'hQ') && handles.hQ(3) > 0 && ishandle(handles.hQ(3)))
% delete(handles.hQ(3));
% end
try
delete(handles.hQ(3));
catch
end
axes(handles.Gate03)
hold on
handles.hQ(3)=quiver(iX, iY, handles.quiverScale*dFx3(1:handles.quiverFactor:end, 1:handles.quiverFactor:end, handles.slice),...
handles.quiverScale*dFy3(1:handles.quiverFactor:end, 1:handles.quiverFactor:end, handles.slice), 0);
set(handles.hQ(3), 'Linewidth', 1.5, 'Color', 'y');
hold off
% if(isfield(handles,'hQ') && handles.hQ(4) > 0 && ishandle(handles.hQ(4)))
% delete(handles.hQ(4));
% end
try
delete(handles.hQ(4));
catch
end
axes(handles.Gate04)
hold on
handles.hQ(4)=quiver(iX, iY, handles.quiverScale*dFx4(1:handles.quiverFactor:end, 1:handles.quiverFactor:end, handles.slice),...
handles.quiverScale*dFy4(1:handles.quiverFactor:end, 1:handles.quiverFactor:end, handles.slice), 0);
set(handles.hQ(4), 'Linewidth', 1.5, 'Color', 'y');
hold off
guidata(hObject, handles)
function cb_showQuiver_Callback(hObject, eventdata, handles)
% checkbox for quivers
if(get(handles.rbForward,'Value') > 0)
dFx2 = handles.h.SDeform(2).dFx;
dFy2 = handles.h.SDeform(2).dFy;
dFx3 = handles.h.SDeform(3).dFx;
dFy3 = handles.h.SDeform(3).dFy;
dFx4 = handles.h.SDeform(4).dFx;
dFy4 = handles.h.SDeform(4).dFy;
else % backward
dFx2 = handles.h.SDeform(2).dBx;
dFy2 = handles.h.SDeform(2).dBy;
dFx3 = handles.h.SDeform(3).dBx;
dFy3 = handles.h.SDeform(3).dBy;
dFx4 = handles.h.SDeform(4).dBx;
dFy4 = handles.h.SDeform(4).dBy;
end
iX = 1:handles.quiverFactor:size(dFx2, 2);
iY = 1:handles.quiverFactor:size(dFy2, 1);
if get(hObject, 'Value')
axes(handles.Gate02)
hold on
handles.hQ(2)=quiver(iX, iY, handles.quiverScale*dFx2(1:handles.quiverFactor:end, 1:handles.quiverFactor:end, handles.slice),...
dFy2(1:handles.quiverFactor:end, 1:handles.quiverFactor:end, handles.slice), 0);
set(handles.hQ(2), 'Linewidth', 1.5, 'Color', 'y');
hold off
axes(handles.Gate03)
hold on
handles.hQ(3)=quiver(iX, iY, handles.quiverScale*dFx3(1:handles.quiverFactor:end, 1:handles.quiverFactor:end, handles.slice),...