-
Notifications
You must be signed in to change notification settings - Fork 2
/
dd_patch.m
1864 lines (1650 loc) · 70.3 KB
/
dd_patch.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 = dd_patch(varargin)
% DD_PATCH automatically detects excessive inplane residual errors (e.g. due to
% cardiac or subject motion) in DW images (b > 50 s/mm^2). Artefact corrected
% files ('artc_*') and PATCH info will be saved to disk ('PATCH.*').
%
% A full description of the method can be found in:
% Zwiers, M.P. (2010). Patching cardiac and head motion artefacts in
% diffusion-weighted images. Neuroimage doi:10.1016/j.neuroimage.2010.06.014
%
%
% Requirements:
% ~~~~~~~~~~~~~
% - SPM8/12 and FSL (optional, see commandline usage of Mask)
%
%
% GUI Usage:
% ~~~~~~~~~~
% Running DD_PATCH by itself (no input arguments) creates a new gui or
% raises the existing one. The upper panels show the minimal voxel
% (left) and sum (right) of the in plane residual error according to the
% diffusion tensor model.
% Slices for which the residual errors exceed the threshold (dashed line;
% can be set with [Threshold]) are considered outliers and are shown in
% the lower panels. You can navigate through these outliers by using the
% slider. The goal is to decide which image is best, the uncorrected image
% (left), the partially corrected image (middle) or the slice corrected
% image (right). In addition to browsing just through the outliers, you can
% also browse through the slices ([z+]/[z-]), through the different
% diffusion directions ([b+]/[b-]), or directly pick a particular slice
% ([set]). Note that navigation functionality is also available by using
% your keyboard: <Left Arrow>/<Right Arrow> for browsing through the
% detected outliers, <Arrow Up>/<Arrow Down> for browsing in the
% z-direction, and the <Ctrl>+<Left/Right Arrow> for browsing through
% neighbouring DW acquisitions (diffusion directions).
% When you are satisfied with all of the image selections you can press
% [Accept]. If you find the algorithm not sensitive enough or too
% sensitive, or you feel that the data is corrupted by vibrations from the
% x-gradient of the scanner, you can restart the outlier detection process
% ([Recalculate]) using different weighting criteria (see also the 'WCrit'
% description below).
%
%
% Commandline Usage:
% ~~~~~~~~~~~~~~~~~~
%
% FUNCTION [DTIFiles PATCH] = DD_PATCH(DTIFiles, Mask, WCrit, Auto, AffM)
%
% INPUT
% DTIFiles - Cell containg char array of DTI filenames (optional)
% NB: Matlab crashes if it's a char array
% Mask - Mask or name of Mask-file of voxels to include. If left
% empty an automatically generated mask is used (requires FSL bet)
% WCrit - Scaling vector with 5 entries:
% WCrit(1) = Voxel (cardiac) weighting. This value ranges
% from zero to infinity: zero gives equal weighting
% and larger values give less weighting to larger
% residuals (e.g. 0.3 supresses residuals larger
% than 3 times the standard deviation). Negative
% values evoke the use of image closure of the
% weights instead of the normal median filtering of
% the residuals (see paper for details).
% WCrit(2) = Slicewise (head motion) weighting. This value
% ranges in the same way as WCrit(1)
% WCrit(3) = Logarithmic intensity weighting (Salvador et al.,
% 2005). The weight ranges from 0 (no weighting) to
% 1 (full weighting)
% WCrit(4) = Weigting value for x-vibration affected volumes.
% The weight ranges from 0 to 1
% WCrit(5) = Threshold for applying x-vibration weighting. The
% value represents the x-component of the diffusion
% gradient and ranges from 0 to 1. A value of zeros
% includes all directions and a value of one
% includes only pure x-directions.
% When WCrit = [] the default is used: [0.15 0.15 0 1 0.7]
% When WCrit = NaN the GMM method is used (Basser et al., 2006)
% Auto - Skips user interaction if true (default false)
% AffM - Rotation matrices used for realignment
%
% OUTPUT
% DTIFiles - char array of artefact-corrected DTI filenames
% PATCH - Struct with fields containing information of IRLS regression
% with fields: 'input' (DTIFiles), 'MaskFile' (Mask), 'b0File',
% 'WCrit', 'WVox' (voxel weightings), 'WSlc' (slice-wise weightings),
% 'Thresh' (handles.Thresh), 'Outliers' (user selections)
%
%
% FUNCTION [..] = DD_PATCH(PATCH)
%
% Alternative use of DD_PATCH in which the calculation restarts from the
% endpoint of a previous calculation
%
% INPUT
% PATCH - IRLS struct from previous DD_PATCH run (see also above)
%
% _________________________________________________________________________
% DD_PATCH was developed by Marcel Zwiers. Please report all bugs to:
%
% Ver 4.0, 23/04/2010. For GPLv3 license see: www.ru.nl/neuroimaging/diffusion
%
% See also: DD_BASICPROC.
% DD_PATCH M-file for dd_patch.fig
% DD_PATCH, by itself, creates a new DD_PATCH or raises the existing
% singleton*.
%
% H = DD_PATCH returns the handle to a new DD_PATCH or the handle to
% the existing singleton*.
%
% DD_PATCH('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in DD_PATCH.M with the given input arguments.
%
% DD_PATCH('Property','Value',...) creates a new DD_PATCH or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before dd_patch_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to dd_patch_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help dd_patch
% Last Modified by GUIDE v2.5 05-Aug-2009 15:32:58
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @dd_patch_OpeningFcn, ...
'gui_OutputFcn', @dd_patch_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
%% --- Executes just before dd_patch is made visible.
function dd_patch_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to dd_patch (see VARARGIN)
%
% USAGE I:
% dd_patch_OpeningFcn(hObject, eventdata, handles)
% -> all input arguments are acquired interactively
%
% USAGE II:
% dd_patch_OpeningFcn([..], PATCH, [LogName], [SeriesNr])
% -> Used for pre-computed interactive sessions
% -> Info is copied from previously saved PATCH file
% -> LogName is used in spm_print (handy for distributed computing)
% -> SeriesNr is used in spm_print (handy for distributed computing)
%
% USAGE III:
% dd_patch_OpeningFcn([..], DTIFiles, Mask, WCrit, Auto, AffM, [LogName], [SeriesNr])
% -> Default commandline use
% -> Mask is a string (=> dd_basicproc) or matrix.
% -> LogName is used in spm_print (handy for distributed computing)
% -> SeriesNr is used in spm_print (handy for distributed computing)
%
% USAGE IV:
% dd_patch_OpeningFcn([..], DTIFiles, Mask, WCrit, Auto, AffM, Outliers)
% -> Used by GUI => Recalc
% -> Info from previous call is passed via handles.[*] (no need to load
% or compute them again = faster).
% -> Mask is a matrix
% Add the path to the Diffusion toolbox
AddPath = false;
WhatdTB = what('Diffusion'); % Check if the Diffusion-toolbox on the Matlab-path
if numel(WhatdTB)==0
xTB = spm('TBs'); % Check if the Diffusion-toolbox is installed in SPM
dTB = find(strcmp('Diffusion', {xTB.name}));
addpath(genpath(xTB(dTB).dir))
AddPath = true;
end
% -- Initialize some variables
WVox = [];
WSlc = [];
B0 = 50; % Threshold for selecting b0 images
Thresh = [0.5 0.5]; % Default values
WCrit = [0.15 0.15 0 1 0.7]; % Default values
tzyx = [4 3 2 1]; % This dim-order is convenient for later calculations
Keep = false;
R = 2; % Radius of the Mask dilation kernel
Kernel = ones(2*R+1, 2*R+1, 2*R+1);
[I J K] = ind2sub(size(Kernel), find(Kernel));
Kernel(sqrt((I-R-1).^2 + (J-R-1).^2 + (K-R-1).^2) > R) = 0;
% -- Parse the input variables
IsRecalc = false;
[S LWarn] = mywarning('Off', 'SPM:noDisplay'); % Else spm_figure gives warning when using qsubcellfun
if (numel(varargin)>5) && isnumeric(varargin{6}) % Usage IV (= Recalculation from the GUI)
IsRecalc = true;
elseif (numel(varargin)>5) && ischar(varargin{6}) && ~isempty(varargin{6}) % Usage III + distributed computing
spm_jobman('initcfg');
HG = spm_figure('GetWin', 'Graphics');
setappdata(HG, 'LogName', varargin{6});
if numel(varargin)>6
setappdata(HG, 'SeriesNr', varargin{7});
end
end
if numel(varargin)>=1 && numel(varargin)<=3 && isfield(varargin{1}, 'WVox') % Usage II
PATCH = varargin{1};
HG = spm_figure('FindWin', 'Graphics');
if numel(varargin)>1 && ishandle(HG)
setappdata(HG, 'LogName', varargin{2});
if numel(varargin)>2
setappdata(HG, 'SeriesNr', varargin{3});
end
end
elseif numel(varargin)==0 % Usage I => get PATCH or DTIFiles
set(spm_figure('GetWin','Graphics'), 'visible','off')
set(spm_figure('GetWin','Interactive'), 'visible','off')
ValidInput = false;
while ~ValidInput
SelFiles = spm_select(Inf, 'any', 'Select the DWI files or PATCH.mat from a previous session', ...
{''}, pwd, 'PATCH.mat|\.img$|\.nii$');
if size(SelFiles,1)==0
return
elseif size(SelFiles,1)==1
if regexp(SelFiles, 'PATCH.mat\>') % An PATCH-file was selected
load(SelFiles) % Load the PATCH-file
ValidInput = true;
Keep = true; % Keep selected outliers (=> UsrOutliers)
else
uiwait(warndlg('More than 6 DWI volumes required'))
end
elseif size(SelFiles,1)>6
varargin{1} = SelFiles; % DWI-files were selected
ValidInput = true;
else
uiwait(warndlg('Select more than 6 DWI files or 1 PATCH.mat file'))
end
end
end
mywarning(S, LWarn)
if exist('PATCH', 'var') % Copy info from the PATCH variable (Usage I or II)
DTIFiles = PATCH.input; % Load the DTI volumes from disk
Mask = PATCH.MaskFile; % Load the Mask volume from disk
b0File = PATCH.b0File;
WVox = PATCH.WVox;
WSlc = PATCH.WSlc;
WLog = PATCH.WLog;
Thresh = PATCH.Thresh;
UsrOutliers = PATCH.Outliers;
for n = 1:numel(PATCH.WCrit)
WCrit(n) = PATCH.WCrit(n);
end
if isfield(PATCH, 'AffM')
AffM = PATCH.AffM;
else
AffM = [];
end
else % Get the info from the input
if isempty(varargin{1})
handles.close = true; % Used in dd_patch_outputfcn
guidata(hObject, handles);
return
end
DTIFiles = char(varargin{1});
if numel(varargin)<2
Mask = spm_select([0 1], 'image', 'Select a Mask file (leave empty for automaticly generated mask)', {''}, pwd, 'mask.*');
else
Mask = varargin{2};
end
if numel(varargin)>=3
for n = 1:numel(varargin{3})
WCrit(n) = varargin{3}(n);
end
end
if numel(varargin)>=4 && varargin{4} % Auto = No user-interaction
handles.close = true; % Used in dd_patch_outputfcn
end
if numel(varargin)<5 || isempty(varargin{5})
AffM = [];
else
AffM = varargin{5};
end
WLog = [];
end
% -- Get necessary variables
fprintf('\n%s\nRunning ''PATCH''\n', repmat('-',[1 40]))
if IsRecalc % Usage IV (Previous info passed via handles (no need to load them again=faster))
if any(varargin{6}>=2) % 1=DWI, 2=PCDWI, 3=CDWI
UsrOutliers = varargin{6};
Keep = strcmp(questdlg('Do you want to keep the current selection?', ...
'Recalculate residuals', 'Yes', 'No', 'No'), 'Yes');
end
tzyx = handles.tzyx;
DWISel = handles.DWISel;
q = handles.q;
Vol = handles.Vol;
MaskFile = handles.MaskFile;
b0File = handles.b0File;
BBox = handles.BBox;
WVox = handles.WVox;
WSlc = handles.WSlc;
WLog = handles.WLog;
Thresh = handles.Thresh;
VolHdr = spm_vol(DTIFiles(DWISel,:));
else % Load the info (NB: mask avoids log of zero)
disp('Loading data...')
for n = 1:size(DTIFiles,1)
D(n) = orderfields(dti_get_dtidata(DTIFiles(n,:)));
end
DWISel = [D(:).b] > B0; % We're not interested in the b0-volumes
q = vertcat(D(DWISel).g); % Matrix containing DTI gradient directions
VolHdr = spm_vol(DTIFiles(DWISel,:));
try % Assume all orientations are identical
Vol = permute(spm_read_vols(VolHdr), tzyx);
catch % Try reading them otherwise
disp('WARNING: Ignoring orientation mismatches and proceeding...')
Vol = zeros([numel(VolHdr) VolHdr(1).dim(3:-1:1)]);
for n = 1:numel(VolHdr)
Vol(n,:,:,:) = permute(spm_read_vols(VolHdr(n)), tzyx(2:end));
end
end
if isempty(Mask)
[Mask b0File] = dd_getmeanmask(DTIFiles(~DWISel,:), true);
end
if ischar(Mask)
MaskFile = Mask;
Mask = spm_read_vols(spm_vol(Mask));
end
Mask = permute(Mask>0.5, tzyx(2:end)); % Use same dimorder as Vol
Myi = find(any(any(Mask,3)));
Mxi = find(any(any(Mask,2)));
BBox = [min(Myi) max(Myi) min(Mxi) max(Mxi)]; % Bounding box Mask (used for display)
BBox = BBox + round(0.06*max(BBox))*[-1 1 -1 1]; % Add a border
BBox(BBox < 1) = 1; % Clip to avoid errors
BBox(2) = min([BBox(2) size(Mask,2)]); % Clip to avoid errors
BBox(4) = min([BBox(4) size(Mask,3)]); % Clip to avoid errors
end
if ~exist('b0File','var') || isempty(b0File) % Make sure we have a b0 image
b0File = DTIFiles(~DWISel,:);
b0File = b0File(1,:);
end
b0Vol = permute(spm_dilate(spm_read_vols(spm_vol(b0File)), Kernel), tzyx(2:end));
% WCrit(1) is a little bit misused here (may be improved in future version)
if isnan(WCrit(1))
Method = 'GMM';
Thresh = sqrt([0.1 0.1]); % Three times the SD (NB WVox must be scaled to 1)
else
Method = 'PATCH';
end
PathStr = fileparts(VolHdr(1).fname);
if length(PathStr)>60, PathStr = ['...' PathStr(end-57:end)]; end
set(hObject, 'Name', ['DTI artefact detection 4.0 (' Method '): ' PathStr], 'NumberTitle', 'Off')
% Be nice to our RAM
Vol = single(Vol);
WVox = single(WVox);
WLog = single(WLog);
% -- Compute the WLS residuals
disp('Analyzing residuals...')
[handles.CVol WVox WSlc WLog handles.SclF tSNR] = ...
runpatch(Vol, VolHdr(1), Mask, b0Vol, q, WCrit, WVox, WSlc, WLog, Method, IsRecalc, AffM, DTIFiles(DWISel,:));
handles.CVol(:,~Mask) = Vol(:,~Mask); % Restore values outside the mask
handles.PCMask = WVox < Thresh(1);
WMin = min(WVox(:,:,:), [], 3); % Used for detection
% -- Detect the outliers
Outliers = [WMin(:)<Thresh(1) WSlc(:)<Thresh(2)];
if Keep
handles.Outliers = any(Outliers,2)*1; % 1=DWI (Let the user decide to use the new outliers)
handles.Outliers(UsrOutliers>1) = UsrOutliers(UsrOutliers>1); % Restore the user values
else
handles.Outliers = Outliers(:,1)*2; % 2=PCDWI
handles.Outliers(Outliers(:,2)) = 3; % 3=CDWI (overrule PCDWI)
end
NrOutliers = numel(find(handles.Outliers));
fprintf('Detected voxel outliers: %g/%g\n', sum(handles.Outliers==2), numel(handles.Outliers))
fprintf('Detected slicewise outliers: %g/%g\n', sum(handles.Outliers==3), numel(handles.Outliers))
% -- Show the results in the GUI
wplot(handles.axes_MinRes, WMin, Thresh(1), 'b', ' Voxel ')
ylabel(handles.axes_MinRes, 'Minimum weight')
wplot(handles.axes_SumRes, WSlc, Thresh(2), 'r', ' {\Sigma} Slice ')
set(handles.axes_SumRes, 'YTickLabel', '')
% -- Add userdata to handles structure (NB: some have already been assigned above)
handles.Vol = Vol;
handles.Mask = Mask;
handles.MaskFile = MaskFile;
handles.b0File = b0File;
handles.Thresh = Thresh;
handles.WCrit = WCrit;
handles.WVox = WVox;
handles.WMin = WMin;
handles.WSlc = WSlc;
handles.WLog = WLog;
handles.AffM = AffM;
handles.BBox = BBox;
handles.q = q;
handles.input = DTIFiles;
handles.DWISel = DWISel;
handles.tzyx = tzyx;
handles.tSNR = tSNR;
if NrOutliers == 0
% Make image-panels invisible
initimpanels(handles, 'Off')
handles.Ind = 1; % Initialize selected image
set(handles.text_File, 'String', 'No outliers detected...')
end
if NrOutliers <= 1 % There is outlier slider to show
set(handles.slider_Ind, 'Value', 1, 'Min', 1-eps, 'Max', 1, 'SliderStep', [1 1])
else
set(handles.slider_Ind, 'Value', 1, 'Min', 1, 'Max', NrOutliers, ...
'SliderStep', [1 1]/(NrOutliers-1))
end
guidata(hObject, handles);
% Draw first slice in the GUI
if NrOutliers>=1 && ~isfield(handles, 'close')
slider_Ind_Callback(handles.slider_Ind, [], handles)
end
% Stop user from hitting buttons
if isfield(handles, 'close')
set(handles.pushbutton_accept, 'Enable', 'inactive', 'ForegroundColor', [0.5 0.5 0.5])
set(handles.pushbutton_recalc, 'Enable', 'inactive', 'ForegroundColor', [0.5 0.5 0.5])
end
% Remove the added path
if AddPath
rmpath(genpath(xTB(dTB).dir))
end
%%
% --- Executes during object creation, after setting all properties.
function dd_patch_CreateFcn(hObject, eventdata, handles)
% hObject handle to dd_patch (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Check for screensize and licence
Units = get(hObject, 'Units'); % Store the units of the GUI
set(hObject, 'Units', get(0, 'Units')) % Set them the same as root
GUISz = get(hObject, 'OuterPosition'); % Get the size of the GUI
set(hObject, 'Units', Units) % Restore the units of the GUI
ScrSz = get(0, 'ScreenSize');
if ScrSz(4) < GUISz(4) + 30 + 40 % 30 = menubar, 44 = KDE-taskbar
% warndlg(sprintf(['Your screen size may be too small (resolution too low) ' ...
% 'to properly display the gui-window (%g x %g)'], GUISz(3:4)), ...
% 'Warning DD_PATCH', 'modal')
fprintf(['\nWarning: Your screensize may be too small (resolution too low) ' ...
'to properly display the gui-window (%g x %g)\n'], GUISz(3), GUISz(4))
end
% Add a menubar togglebutton to the toolbar
MIcon = repmat(shiftdim([0.92 0.91 0.84],-1), [16 16 1]);
MIcon(2:4,2:15,:) = 0.8; % menubar background
MIcon(3,[4:8 12:15],:) = 0; % menubar text
MIcon([1 5],:,:) = 0.5; % border
MIcon(:,[1 16],:) = 0.5;
MIcon(6:14,[4 11],:) = 0.5;
MIcon(15,4:11,:) = 0.5;
MIcon(6:14,5:10,:) = 1; % menu
MIcon(7,5:8,:) = 0; % menu text
MIcon(9,5:9,:) = 0;
MIcon(11,5:6,:) = 0;
MIcon(13,5:7,:) = 0;
Htb = findall(hObject,'Type','uitoolbar');
uitoggletool(Htb, 'CData', MIcon, 'TooltipString','Show menubar',...
'HandleVisibility','callback', 'Separator','on', ...
'OffCallBack', 'set(gcbf,''MenuBar'',''none'')', ...
'OnCallBack', 'set(gcbf,''MenuBar'',''figure'')');
% % Change the 'Save' button to 'Save As (jpeg)' to avoid overriding dd_patch.fig
Hsv = findall(hObject, 'Tag', 'Standard.SaveFigure');
set(Hsv, 'ClickedCallback', 'filemenufcn(gcbf,''FileSaveAs'')', ...
'TooltipString', 'Save Figure As (NB saving as dd_patch.fig is not recommended')
Types = localexporttypes;
TypeID = find(strcmp(Types(:,4),'jpeg'));
setappdata(hObject, 'FileMenuFcnLastExportedAsType', TypeID)
% % Change the default filename (I presume it is not used otherwise) => causes troubles for GUIDE
% [Dum FigName] = fileparts(get(hObject, 'filename'));
% set(hObject, 'filename', fullfile(pwd, [FigName Types{TypeID,3}]))
% --- Outputs from this function are returned to the command line.
function varargout = dd_patch_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
if ~isfield(handles, 'close')
H = handles.axes_SumRes;
clearvars handles % Release working memory
waitfor(H);
handles = guidata(hObject); % Retrieve latest handles
end
% Return if there was nothing to process (i.e. no DTIFiles)
if ~isfield(handles, 'DWISel')
varargout{1} = [];
varargout{2} = [];
if ishandle(hObject)
close(hObject)
end
return
end
% Find out which are the selected outliers
DWISelI = find(handles.DWISel);
[Regqi Regzi] = ind2sub(size(handles.Vol(:,:,1,1)), find(handles.Outliers==2));
[Slcqi Slczi] = ind2sub(size(handles.Vol(:,:,1,1)), find(handles.Outliers==3));
Output = prepend(handles.input, 'artc_', DWISelI(unique([Regqi' Slcqi'])));
% Correct the voxel and slicewise artefacts
for n = 1:numel(Regqi)
handles.Vol(Regqi(n), Regzi(n), handles.PCMask(Regqi(n), Regzi(n), :)) = ...
handles.CVol(Regqi(n), Regzi(n), handles.PCMask(Regqi(n), Regzi(n), :));
end
for n = 1:numel(Slcqi)
handles.Vol(Slcqi(n), Slczi(n), :) = handles.CVol(Slcqi(n), Slczi(n), :);
end
% Print and save the corrected data & converged voxel and slice weightings
HG = spm_figure('FindWin', 'Graphics');
if ishandle(HG)
LogName = getappdata(HG, 'LogName');
SeriesNr = getappdata(HG, 'SeriesNr');
FIDLog = fopen([LogName(1:end-2) 'tsv'], 'a');
if FIDLog > -1
fprintf(FIDLog, 'S%g\tPATCH:\tVoxel outliers =\t%g\tSlice outliers =\t%g\tNr of slices =\t%g\n', ...
SeriesNr, sum(handles.Outliers==2), sum(handles.Outliers==3), numel(handles.Outliers));
fclose(FIDLog);
else
warning('DIDI:PATCH:OpenFile', 'Could not open: %s', [LogName(1:end-2) 'tsv'])
end
else
SeriesNr = 1;
end
myspm_print(sprintf('S%g: PATCH - estimated weights', SeriesNr), fileparts(handles.input(1,:)))
fprintf('------------------------\n')
fprintf('Accepted voxel outliers: %g/%g\n', sum(handles.Outliers==2), numel(handles.Outliers))
fprintf('Accepted slicewise outliers: %g/%g\n', sum(handles.Outliers==3), numel(handles.Outliers))
fprintf('Saving %g artefact-corrected files\n', numel(unique([Regqi' Slcqi'])))
for q = unique([Regqi' Slcqi'])
if numel(q)==0, break, end % q = 0-by-1 array
Hdr = spm_vol(handles.input(DWISelI(q),:));
Hdr = rmfield(Hdr, 'pinfo');
Hdr.fname = Output(DWISelI(q),:);
spm_write_vol(Hdr, ipermute(handles.Vol(q,:,:,:), handles.tzyx));
[Pth Nme] = fileparts(handles.input(DWISelI(q),:));
if exist(fullfile(Pth, ['artc_' Nme '.mat']), 'file')
delete(fullfile(Pth, ['artc_' Nme '.mat'])) % It seems that copyfile somehow can't always overwrite writable files that it doesn't own???
end
copyfile(fullfile(Pth, [Nme '.mat']), fullfile(Pth, ['artc_' Nme '.mat']), 'f')
end
% Save the WLS weights
PATCH.input = handles.input;
PATCH.MaskFile = handles.MaskFile;
PATCH.b0File = handles.b0File;
PATCH.WCrit = handles.WCrit;
PATCH.WVox = handles.WVox;
PATCH.WSlc = handles.WSlc;
PATCH.WLog = handles.WLog;
PATCH.Thresh = handles.Thresh;
PATCH.Outliers = handles.Outliers;
PATCH.AffM = handles.AffM;
disp(['Saving: ' fullfile(fileparts(handles.input(1,:)), 'PATCH')])
save(fullfile(fileparts(handles.input(1,:)), 'PATCH'), 'PATCH')
% Save the sum of the total weights as a nifti-file
Sz = size(handles.WVox);
Ext = ['.' getfield(spm_get_defaults('images'),'format')];
WT = handles.Mask .* shiftdim(sum(1 - bsxfun(@times, handles.WVox, handles.WSlc)));
Hdr = spm_vol(handles.input(1,:));
Hdr = rmfield(Hdr, 'pinfo');
Hdr.fname = fullfile(fileparts(Hdr.fname), ['PATCH_W' Ext]);
Hdr.dt(1) = spm_type('float32');
disp(['Saving: ' Hdr.fname])
spm_write_vol(Hdr, ipermute(WT, handles.tzyx(2:end))); % NB the 4th dim is always t
% Save the nr of outliers as a nifti-file
WT = zeros(Sz);
for n = 1:numel(Regqi)
WT(Regqi(n), Regzi(n), handles.PCMask(Regqi(n), Regzi(n), :)) = 1;
end
for n = 1:numel(Slcqi)
WT(Slcqi(n), Slczi(n), :) = 1;
end
WT = shiftdim(sum(WT)) .* handles.Mask;
Hdr = spm_vol(handles.input(1,:));
Hdr = rmfield(Hdr, 'pinfo');
Hdr.fname = fullfile(fileparts(Hdr.fname), ['PATCH_N' Ext]);
disp(['Saving: ' Hdr.fname])
spm_write_vol(Hdr, ipermute(WT, handles.tzyx(2:end))); % NB the 4th dim is always t
% Save tSNR map as a nifti-file
Hdr = spm_vol(handles.input(1,:));
Hdr = rmfield(Hdr, 'pinfo');
Hdr.fname = fullfile(fileparts(Hdr.fname), ['tSNR_PATCH' Ext]);
Hdr.dt(1) = spm_type('float32');
tSNR = handles.tSNR(shiftdim(handles.Mask,-1));
MeantSNR = mean(tSNR(~isnan(tSNR)));
disp(['Saving: ' Hdr.fname])
Hdr = spm_write_vol(Hdr, squeeze(ipermute(handles.tSNR, handles.tzyx)));
if ishandle(HG)
LogName = getappdata(HG, 'LogName');
SeriesNr = getappdata(HG, 'SeriesNr');
FIDLog = fopen([LogName(1:end-2) 'tsv'], 'a');
if FIDLog > -1
fprintf(FIDLog, 'S%g\tPATCH:\ttSNR =\t%g\n', SeriesNr, MeantSNR);
fclose(FIDLog);
else
warning('DIDI:PATCH:OpenFile', 'Could not open: %s', [LogName(1:end-2) 'tsv'])
end
set(0,'CurrentFigure',HG)
spm_check_registration(Hdr), colorbar, colormap('hot')
spm_orthviews('Window', 1, [0 3*MeantSNR]) % Make the image brighter
Children = get(HG,'Children');
Position = [get(Children(end), 'Position'); get(Children(end-2), 'Position')];
H = axes('Parent',HG, 'Position', [Position(2,1) Position(1,2) [1 0.9].*Position(1,3:4)]);
hist(H, tSNR(tSNR<3*MeantSNR), 100)
title(H, sprintf('tSNR = %.1f', MeantSNR))
xlabel(H, 'tSNR')
set(H, 'YTick',[], 'box','off')
myspm_print(sprintf('S%g: PATCH - tSNR', SeriesNr), fileparts(handles.input(1,:)))
colormap('gray')
else
SeriesNr = 1;
end
fprintf('tSNR: %g\n', MeantSNR)
% Finish up
varargout{1} = Output;
varargout{2} = PATCH;
if ishandle(hObject)
close(hObject)
end
% --- Executes on key press with focus on figure and of its controls.
function dd_patch_KeyPressFcn(hObject, eventdata, handles)
% hObject handle to dd_patch (see GCBO)
% eventdata structure with the following fields (see FIGURE)
% Key: name of the key that was pressed, in lower case
% Character: character interpretation of the key(s) that was pressed
% Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles structure with handles and user data (see GUIDATA)
if length(handles.Outliers)<=1 && ~isfield(handles, 'close')
return
end
switch [eventdata.Modifier{:} eventdata.Key]
case {'1' 'delete'}
radiobutton_DWI_Callback(handles.radiobutton_DWI, [], handles)
case {'2' 'insert'}
radiobutton_PCDWI_Callback(handles.radiobutton_PCDWI, [], handles)
case '3'
radiobutton_CDWI_Callback(handles.radiobutton_CDWI, [], handles)
case {'leftarrow' 'backspace'}
Ind = get(handles.slider_Ind, 'Value');
if Ind > 1
set(handles.slider_Ind, 'Value', Ind - 1)
slider_Ind_Callback(handles.slider_Ind, [], handles)
end
case {'rightarrow' 'space'}
Ind = get(handles.slider_Ind, 'Value');
if Ind < get(handles.slider_Ind, 'Max')
set(handles.slider_Ind, 'Value', Ind + 1)
slider_Ind_Callback(handles.slider_Ind, [], handles)
end
case {'uparrow' 'controluparrow' 'altuparrow' 'shiftuparrow'}
pushbutton_zplus_Callback(handles.pushbutton_zplus, [], handles)
case {'downarrow' 'controldownarrow' 'altdownarrow' 'shiftdownarrow'}
pushbutton_zmin_Callback(handles.pushbutton_zmin, [], handles)
case {'controlrightarrow' 'altrightarrow' 'shiftrightarrow'}
pushbutton_qplus_Callback(handles.pushbutton_qplus, [], handles)
case {'controlleftarrow' 'altleftarrow' 'shiftleftarrow'}
pushbutton_qmin_Callback(handles.pushbutton_qmin, [], handles)
case 'escape'
set(handles.slider_Ind, 'Value', get(handles.slider_Ind, 'Value'))
slider_Ind_Callback(handles.slider_Ind, [], handles)
case 'home'
set(handles.slider_Ind, 'Value', 1)
slider_Ind_Callback(handles.slider_Ind, [], handles)
case 'end'
set(handles.slider_Ind, 'Value', get(handles.slider_Ind, 'Max'))
slider_Ind_Callback(handles.slider_Ind, [], handles)
case {'controlreturn' 'controlenter'}
pushbutton_accept_Callback(handles.pushbutton_accept, [], handles)
case 'f1'
doc('dd_patch')
end
% --- Executes on button pr1ess in radiobutton_DWI.
function radiobutton_DWI_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton_DWI (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.Outliers(handles.Ind) = 1;
set(handles.radiobutton_DWI, 'Value', 1)
set(handles.radiobutton_PCDWI, 'Value', 0)
set(handles.radiobutton_CDWI, 'Value', 0)
guidata(hObject, handles);
set(findobj(handles.axes_DWI, 'Tag', 'DWIBorder'), 'Visible', 'on')
set(findobj(handles.axes_PCDWI, 'Tag', 'PCDWIBorder'), 'Visible', 'off')
set(findobj(handles.axes_CDWI, 'Tag', 'CDWIBorder'), 'Visible', 'off')
resimplot(handles, true)
% --- Executes on button press in radiobutton_PCDWI.
function radiobutton_PCDWI_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton_PCDWI (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
setslider(handles, 2)
handles.Outliers(handles.Ind) = 2;
set(handles.radiobutton_DWI, 'Value', 0)
set(handles.radiobutton_PCDWI, 'Value', 1)
set(handles.radiobutton_CDWI, 'Value', 0)
guidata(hObject, handles);
set(findobj(handles.axes_DWI, 'Tag', 'DWIBorder'), 'Visible', 'off')
set(findobj(handles.axes_PCDWI, 'Tag', 'PCDWIBorder'), 'Visible', 'on')
set(findobj(handles.axes_CDWI, 'Tag', 'CDWIBorder'), 'Visible', 'off')
resimplot(handles, true)
% --- Executes on button press in radiobutton_CDWI.
function radiobutton_CDWI_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton_CDWI (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
setslider(handles, 3)
handles.Outliers(handles.Ind) = 3;
set(handles.radiobutton_DWI, 'Value', 0)
set(handles.radiobutton_PCDWI, 'Value', 0)
set(handles.radiobutton_CDWI, 'Value', 1)
guidata(hObject, handles);
set(findobj(handles.axes_DWI, 'Tag', 'DWIBorder'), 'Visible', 'off')
set(findobj(handles.axes_PCDWI, 'Tag', 'PCDWIBorder'), 'Visible', 'off')
set(findobj(handles.axes_CDWI, 'Tag', 'CDWIBorder'), 'Visible', 'on')
resimplot(handles, true)
% --- Executes on slider movement.
function slider_Ind_Callback(hObject, eventdata, handles)
% hObject handle to slider_Ind (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if strcmp(get(handles.slider_Ind, 'Visible'), 'off')
initimpanels(handles, 'On')
end
Ind = round(get(hObject,'Value')); % Position of slider
set(hObject, 'Value', Ind) % Use round numbers only (> mouse interaction)
Outliers = find(handles.Outliers);
handles.Ind = Outliers(Ind);
guidata(hObject, handles);
resimplot(handles)
% --- Executes during object creation, after setting all properties.
function slider_Ind_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider_Ind (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
% --- Executes on button press in pushbutton_Help.
function pushbutton_Help_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_Help (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
doc(mfilename)
% --- Executes on button press in pushbutton_Reset.
function pushbutton_Reset_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_Reset (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.Outliers(:) = 0; % Reset the PCDWI settings
handles.Outliers(handles.WMin(:) < handles.Thresh(1)) = 2; % Set the new PCDWI settings
handles.Outliers(handles.WSlc(:) < handles.Thresh(2)) = 3; % Set the new CDWI settings
fprintf('Redetected voxel outliers: %g/%g\n', sum(handles.Outliers==2), numel(handles.WMin))
fprintf('Redetected slicewise outliers: %g/%g\n', sum(handles.Outliers==3), numel(handles.WMin))
% Re-initialize the panels
handles.Ind = 1;
NrOutliers = numel(find(handles.Outliers));
if NrOutliers == 0
initimpanels(handles, 'Off') % Make image-panels invisible
end
if NrOutliers <= 1 % There is outlier slider to show
set(handles.slider_Ind, 'Value', 1, 'Min', 1-eps, 'Max', 1, 'SliderStep', [1 1])
else
set(handles.slider_Ind, 'Value', 1, 'Min', 1, 'Max', NrOutliers, ...
'SliderStep', [1 1]/(NrOutliers-1))
end
guidata(hObject, handles);
% Draw first slice
if NrOutliers >= 1
slider_Ind_Callback(handles.slider_Ind, [], handles)
end
% --- Executes on button press in pushbutton_Threshold.
function pushbutton_Threshold_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_Threshold (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get the mouse input and set the threshold
[Dum y] = ginput(1);
YLim = get(gca, 'YLim');
DWI = handles.Outliers==1; % Store the DWI settings
if strcmp(get(gca, 'Tag'), 'axes_MinRes') && y>=YLim(1) && y<=YLim(2)
handles.Thresh(1) = y;
CDWI = handles.Outliers==3; % Store the CDWI settings
handles.Outliers(handles.Outliers==2) = 0; % Reset the PCDWI settings
handles.Outliers(handles.WMin(:) < y) = 2; % Set the new PCDWI settings
handles.Outliers(CDWI) = 3; % Restore the CDWI settings
set(findobj(handles.axes_MinRes, 'Tag', 'ThresLijn'), 'YData', [y y])
fprintf('New min(slice) threshold: %g\n', y)
handles.PCMask = handles.WVox < y; % Update the PCDWI-mask
handles.PCMask(:,~handles.Mask) = false;
elseif strcmp(get(gca, 'Tag'), 'axes_SumRes') && y>=YLim(1) && y<=YLim(2)
handles.Thresh(2) = y;
PCDWI = handles.Outliers==2; % Store the PCDWI settings
Combi = handles.Outliers==3 & handles.WMin(:)<handles.Thresh(1);
handles.Outliers(handles.Outliers==3) = 0; % Reset the CDWI settings
handles.Outliers(PCDWI | Combi) = 2; % Restore the PCDWI settings
handles.Outliers(handles.WSlc(:) < y) = 3; % Set the new CDWI settings
set(findobj(handles.axes_SumRes, 'Tag', 'ThresLijn'), 'YData', [y y])
fprintf('New sum(slice) threshold: %g\n', y)
else
return
end
handles.Outliers(DWI) = 1; % Restore the DWI settings
fprintf('Redetected voxel outliers: %g/%g\n', sum(handles.Outliers==2), numel(handles.WMin))
fprintf('Redetected slicewise outliers: %g/%g\n', sum(handles.Outliers==3), numel(handles.WMin))
% Re-initialize the panels
handles.Ind = 1;
NrOutliers = numel(find(handles.Outliers));
if NrOutliers == 0
initimpanels(handles, 'Off') % Make image-panels invisible
end
if NrOutliers <= 1 % There is outlier slider to show
set(handles.slider_Ind, 'Value', 1, 'Min', 1-eps, 'Max', 1, 'SliderStep', [1 1])
else
set(handles.slider_Ind, 'Value', 1, 'Min', 1, 'Max', NrOutliers, ...
'SliderStep', [1 1]/(NrOutliers-1))
end
guidata(hObject, handles);
% Draw first slice
if NrOutliers >= 1
slider_Ind_Callback(handles.slider_Ind, [], handles)
end
% --- Executes on button press in pushbutton_recalc.
function pushbutton_recalc_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_recalc (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
WCrit = [];
while numel(WCrit)<1 || numel(WCrit)>5
Ans = inputdlg({'Weighting criteria:' 'Re-use weighting parameters'}, ...
'IRLS recalculation', 1, {sprintf('%g %g %g %g %g',handles.WCrit) 'No'});
if isempty(Ans)
return
else
WCrit = str2num(Ans{1});
end
end
handles.WCrit = WCrit;
if ~strcmp(Ans{2}, 'Yes')
handles.WVox = [];
handles.Slc = [];
end
set(hObject, 'Enable', 'inactive', 'ForegroundColor', [0.5 0.5 0.5])
set(handles.pushbutton_accept, 'Enable', 'inactive', 'ForegroundColor', [0.5 0.5 0.5])
drawnow
dd_patch_OpeningFcn(handles.dd_patch, eventdata, handles, ...
{handles.input}, handles.Mask, handles.WCrit, false, handles.AffM, handles.Outliers)
set(hObject, 'Enable', 'on', 'ForegroundColor', [0 0 0])
set(handles.pushbutton_accept, 'Enable', 'on', 'ForegroundColor', [0 0 0])
% --- Executes on button press in pushbutton_accept.
function pushbutton_accept_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_accept (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Stop user from hitting buttons
set(hObject, 'Enable', 'inactive', 'ForegroundColor', [0.5 0.5 0.5])
set(handles.pushbutton_recalc, 'Enable', 'inactive', 'ForegroundColor', [0.5 0.5 0.5])
drawnow
% Closing this figure resumes the outputfcn
delete(handles.axes_SumRes)
% --- Executes on button press in pushbutton_zplus.
function pushbutton_zplus_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_zplus (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
NewInd = handles.Ind + size(handles.Vol,1);
if NewInd <= length(handles.Outliers)
handles.Ind = NewInd;
end
guidata(hObject, handles);
resimplot(handles)
% --- Executes on button press in pushbutton_zmin.
function pushbutton_zmin_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_zmin (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
NewInd = handles.Ind - size(handles.Vol,1);
if NewInd >= 1
handles.Ind = NewInd;
end
guidata(hObject, handles);
resimplot(handles)
% --- Executes on button press in pushbutton_qplus.
function pushbutton_qplus_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_qplus (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if ~exist('handles', 'var')
handles = guidata(hObject);
end
handles.Ind = min([handles.Ind+1 length(handles.Outliers)]);
guidata(hObject, handles);
resimplot(handles)
% --- Executes on button press in pushbutton_qmin.
function pushbutton_qmin_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_qmin (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.Ind = max([handles.Ind-1 1]);