-
Notifications
You must be signed in to change notification settings - Fork 3
/
svrlsmgui.m
executable file
·1108 lines (1002 loc) · 61.2 KB
/
svrlsmgui.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 = svrlsmgui(varargin)
% SVRLSMGUI MATLAB code for svrlsmgui.fig
% SVRLSMGUI, by itself, creates a new SVRLSMGUI or raises the existing
% singleton*.
%
% H = SVRLSMGUI returns the handle to a new SVRLSMGUI or the handle to
% the existing singleton*.
%
% SVRLSMGUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in SVRLSMGUI.M with the given input arguments.
%
% SVRLSMGUI('Property','Value',...) creates a new SVRLSMGUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before svrlsmgui_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to svrlsmgui_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 svrlsmgui
% Last Modified by GUIDE v2.5 04-Nov-2019 12:48:03
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename,'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @svrlsmgui_OpeningFcn, 'gui_OutputFcn', @svrlsmgui_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 svrlsmgui is made visible.
function svrlsmgui_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject; % Choose default command line output for svrlsmgui
% Do we need to add the functions subdirectory to the path?
pathCell = regexp(path, pathsep, 'split');
myPath = fileparts(mfilename('fullpath'));
if ~any(strcmp(myPath,pathCell))
addpath(myPath)
end
functionsPath = fullfile(myPath,'functions');
if ~any(strcmp(functionsPath,pathCell))
addpath(functionsPath)
end
handles = ConfigureSVRLSMGUIOptions(handles);
handles.details = CheckIfNecessaryFilesAreInstalled(handles);
if handles.details.stats_toolbox && handles.details.spm && handles.details.libsvm
handles = UpdateProgress(handles,'All necessary functions are available...',1);
handles.parameters = GetDefaultParameters(handles);
handles = PopulateGUIFromParameters(handles);
elseif ~handles.details.spm
handles = UpdateProgress(handles,'SPM12 functions not available. Download and/or add SPM12 to the MATLAB path and relaunch the SVRLSMGUI.',1);
handles = DisableAll(handles);
elseif ~handles.details.stats_toolbox && ~handles.details.libsvm
handles = UpdateProgress(handles,'No SVR algorithm available. Install Statistics Toolbox in MATLAB or compile and install libSVM and relaunch the GUI.',1);
handles = DisableAll(handles);
elseif ~handles.details.stats_toolbox && handles.details.libsvm % yes stats toolbox, no libsvm
handles = UpdateProgress(handles,'Only libSVM is available to compute images. MATLAB''s SVM will not be available.',1);
handles.parameters = GetDefaultParameters(handles);
handles = PopulateGUIFromParameters(handles);
elseif handles.details.stats_toolbox && ~handles.details.libsvm % no stats toolbox, yes libsvm
handles = UpdateProgress(handles,'Only MATLAB''s Stats Toolbox is available to compute images. libSVM will not be available.',1);
handles.parameters = GetDefaultParameters(handles);
handles = PopulateGUIFromParameters(handles);
end
handles.parameters.parallelize = handles.details.can_parallelize; % override default
% 0.02 - trying to clean it up to run on a variety of systems - 4/24/17
% 0.03 - first version to be used by other individuals officially - 5/1/17
% 0.04 - 5/2/17
% 0.05 - 7/26/17 - moved to the linux machine, working on improving stability and fixing bugs
% 0.06 - August 2017 - added parallelization, continued development with paper
% 0.07 - September 2017 - summary output, fixed bug in two tail thresholding, public release...
% 0.08 - added diagnostic plot for behavioral nuisance model in summary
% output file (corrplot); added custom support vector scaling
% other than max of the map when backprojecting the analysis
% hyperplane
% 0.10 - January 2018 - fixing reported bugs
% 0.15 - massive code refactoring and implementation of CFWER
handles.parameters.gui_version = 0.15; % version of the the gui
guidata(hObject, handles); % Update handles structure
function handles = DisableAll(handles)
set(get(handles.analysispreferencespanel,'children'),'enable','off')
set(get(handles.covariatespanel,'children'),'enable','off')
set(get(handles.permutationtestingpanel,'children'),'enable','off')
set([handles.viewresultsbutton handles.interrupt_button handles.runanalysisbutton],'Enable','off') % handles.cancelanalysisbutton
set(handles.optionsmenu,'enable','off') % since viewing this menu references parameters that may not be loaded.
msgbox('One or more necessary component is missing from MATLAB''s path. Address the message in the SVRLSMgui window and restart this gui.')
function handles = UpdateCurrentAnalysis(handles,hObject)
changemade = true; % default
switch get(gcbo,'tag') % use gcbo to see what the cbo is and determine what field it goes to -- and to validate
case 'no_map_crossvalidation' % turns off crossvalidation...
handles.parameters.crossval.do_crossval = false;
case 'kfold_map_crossvalidation'
if handles.parameters.useLibSVM
changemade=false;
msgbox('Map crossvalidation not currently supported for libSVM - please switch implementation to MATLAB and try again.')
return
end
answer = inputdlg(sprintf('Enter the numbers of folds for crossvalidation.'), ...
'Number of folds', 1,{num2str(handles.parameters.crossval.nfolds)});
if isempty(answer), return; end % cancel pressed
str = str2num(answer{1});
if isempty(str) || str <= 0 || ~isint(str)
changemade=false;
warndlg('Input must be a positive integer.');
else % update the parameter value.
handles.parameters.crossval.do_crossval = true;
handles.parameters.crossval.method = 'kfold';
handles.parameters.crossval.nfolds = str;
end
case 'hyperparm_quality_report_options'
set(handles.hyperparm_qual_n_folds,'Label',['Folds: ' num2str(handles.parameters.hyperparameter_quality.report.nfolds)])
set(handles.repro_index_subset_percentage,'Label',['Subset %: ' num2str(handles.parameters.hyperparameter_quality.report.repro_ind_subset_pct)])
set(handles.hyperparm_qual_n_replications,'Label',['Replications: ' num2str(handles.parameters.hyperparameter_quality.report.n_replications)])
case 'hyperparm_qual_n_folds'
answer = inputdlg(sprintf('Enter the number of folds for hyperparameter quality testing:'), ...
'Number of folds', 1,{num2str(handles.parameters.hyperparameter_quality.report.nfolds)});
if isempty(answer), return; end % cancel pressed
str = str2num(answer{1});
if isempty(str) || str <= 1 || ~isint(str)
changemade=false;
warndlg('Input must be a positive integer greater than 1.');
else % update the parameter value.
handles.parameters.hyperparameter_quality.report.nfolds = str;
end
case 'repro_index_subset_percentage'
answer = inputdlg('Enter the % of sample to use for computing w-map reproducibility index [0-1]:', ...
'Sample percent', 1,{num2str(handles.parameters.hyperparameter_quality.report.repro_ind_subset_pct)});
if isempty(answer), return; end % cancel pressed
str = str2num(answer{1});
if isempty(str) || str <= 0 || str >= 1 % ~isint(str)
changemade=false;
warndlg('Input must be a value between 0 and 1 (i.e. 0 and 100%).');
else % update the parameter value.
handles.parameters.hyperparameter_quality.report.repro_ind_subset_pct = str;
end
case 'hyperparm_qual_n_replications'
answer = inputdlg(sprintf('Enter the number of replications for hyperparameter quality testing:'), ...
'Number of replications', 1,{num2str(handles.parameters.hyperparameter_quality.report.n_replications)});
if isempty(answer), return; end % cancel pressed
str = str2num(answer{1});
if isempty(str) || str <= 1 || ~isint(str)
changemade=false;
warndlg('Input must be a positive integer greater than 1.');
else % update the parameter value.
handles.parameters.hyperparameter_quality.report.n_replications = str;
end
case 'image_data_options_parent_menu'
set(handles.do_binarize_data_menu_option,'Checked',myif(handles.parameters.imagedata.do_binarize,'on','off'))
case 'do_binarize_data_menu_option'
handles.parameters.imagedata.do_binarize = ~handles.parameters.imagedata.do_binarize;
case 'set_resolution_parent_menu_option'
set(handles.manual_analysis_resolution_menu,'Label',['Manual: ' num2str(handles.parameters.imagedata.resample_to) ' mm'], ...
'checked',myif(handles.parameters.imagedata.do_resample,'on','off'));
set(handles.do_not_resample_images_menu,'Checked',myif(handles.parameters.imagedata.do_resample,'off','on'));
%set(handles.manual_analysis_resolution_menu,'Enable','on') % Until we finish implementation.
case 'do_not_resample_images_menu'
handles.parameters.imagedata.do_resample = false; % turn resampling off.
case 'manual_analysis_resolution_menu'
answer = inputdlg(sprintf('Enter the size in mm for voxels to be resampled to.'), ...
'Resample size (mm)', 1,{num2str(handles.parameters.imagedata.resample_to)});
if isempty(answer), return; end % cancel pressed
str = str2num(answer{1});
if isempty(str) || str <= 0 || ~isint(str)
changemade=false;
warndlg('Input must be a positive integer in millimeters.');
else % update the parameter value.
handles.parameters.imagedata.do_resample = true;
handles.parameters.imagedata.resample_to = str;
end
case 'open_lesion_folder_button'
OpenDirectoryInNativeWindow(handles.parameters.lesion_img_folder)
case 'open_score_file_button'
openFileInSystemViewer(handles.parameters.score_file)
case 'open_output_folder_button'
OpenDirectoryInNativeWindow(handles.parameters.analysis_out_path)
case 'ica_lesion_decompose_option'
handles.parameters.beta.do_ica_on_lesiondata = ~handles.parameters.beta.do_ica_on_lesiondata;
case 'requirements_menu'
case 'search_strategy_options'
set(handles.optimization_iterations_menu_option,'Label',['Iterations: ' num2str(handles.parameters.optimization.iterations)])
set(handles.griddivs_optimization_menu_option,'Label',['Grid Divs: ' num2str(handles.parameters.optimization.grid_divisions)])
return
case 'summary_prediction_menu'
handles.parameters.summary.predictions = ~handles.parameters.summary.predictions;
case 'lsm_method_parent_menu'
set(get(handles.lsm_method_parent_menu,'children'),'checked','off')
if handles.parameters.method.mass_univariate
set(handles.mass_univariate_menu_option,'checked','on')
set(handles.svr_parent_menu,'enable','off')
else
set(handles.multivariate_lsm_option,'checked','on')
set(handles.svr_parent_menu,'enable','on')
end
if handles.details.libsvm || handles.details.stats_toolbox
set(handles.multivariate_lsm_option,'enable','on')
else
handles.parameters.method.mass_univariate = true; % at least...
set(handles.multivariate_lsm_option,'enable','off')
end
case 'mass_univariate_menu_option'
handles.parameters.method.mass_univariate = true;
case 'multivariate_lsm_option'
handles.parameters.method.mass_univariate = false;
case 'svr_parent_menu'
case 'optimization_is_verbose_menu'
handles.parameters.optimization.verbose_during_optimization = ~handles.parameters.optimization.verbose_during_optimization;
case 'summary_lesionoverlap'
handles.parameters.summary.lesion_overlap = ~handles.parameters.summary.lesion_overlap;
case 'summary_paramoptimization'
handles.parameters.summary.hyperparameter_optimization_record = ~handles.parameters.summary.hyperparameter_optimization_record;
case 'summary_create_summary'
handles.parameters.do_make_summary = ~handles.parameters.do_make_summary;
case 'summary_narrative_summary'
handles.parameters.summary.narrative = ~handles.parameters.summary.narrative;
case 'summary_svrbetamap'
handles.parameters.summary.beta_map = ~handles.parameters.summary.beta_map;
case 'summary_voxelwise_thresholded'
handles.parameters.summary.voxelwise_thresholded = ~handles.parameters.summary.voxelwise_thresholded;
case 'summary_clusterwise_thresholded'
handles.parameters.summary.clusterwise_thresholded = ~handles.parameters.summary.clusterwise_thresholded;
case 'summary_cfwerdiagnostics'
handles.parameters.summary.cfwer_diagnostics = ~handles.parameters.summary.cfwer_diagnostics;
case 'model_variablediagnostics'
handles.parameters.summary.variable_diagnostics = ~handles.parameters.summary.variable_diagnostics;
case 'summary_clusterstability'
handles.parameters.summary.cluster_stability = ~handles.parameters.summary.cluster_stability;
case 'summary_parameterassessment'
handles.parameters.summary.parameter_assessment = ~handles.parameters.summary.parameter_assessment;
case 'do_use_cache_menu'
handles.parameters.do_use_cache_when_available = ~handles.parameters.do_use_cache_when_available;
case 'crossval_menu_option_none'
handles.parameters.optimization.crossval.do_crossval = false; % disable crossvalidation.
case 'crossval_menu_option_kfold'
msg = sprintf('Enter the number of folds for cross-validation (default = %d):',handles.parameters.optimization.crossval.nfolds_default);
answer = inputdlg(msg, ...
'Number of folds', 1,{num2str(handles.parameters.optimization.crossval.nfolds)});
warning('bug here - if you click cancel it causes an error - in future, embed the str<=0 and isint within the isempty... and do that with other str2num(answer{1})''s as well')
if isempty(answer), return; end % cancel pressed
str = str2num(answer{1});
if isempty(str) || str <= 0 || ~isint(str)
changemade=false;
warndlg('Input must be a positive integer.');
else % update the parameter value.
handles.parameters.optimization.crossval.do_crossval = true; % enable crossvalidation.
handles.parameters.optimization.crossval.nfolds = str;
end
case 'do_repartition_menu_option' % flip this choice.
handles.parameters.optimization.crossval.repartition = ~handles.parameters.optimization.crossval.repartition;
case 'standardize_menu' % set the value to use if not optimization
vals = {'true','false'};
msg = sprintf('Standardize value (default = %s):',myif(handles.parameters.svr_defaults.standardize,'true','false'));
s = listdlg('PromptString',msg,'SelectionMode','single', ...
'ListString',vals,'InitialValue',myif(handles.parameters.standardize,1,2), ...
'Name','Standardize Parameter','ListSize',[250 80]);
if isempty(s)
changemade=false; % cancelled...
else
handles.parameters.standardize = str2num(vals{s}); % myif(v==1,true,false); % new value.
end
case 'epsilon_menu' % set the value to use if not optimization
msg = sprintf('Enter new value for epsilon (default = %0.2f):',handles.parameters.svr_defaults.epsilon);
% add min and max range - dev1
answer = inputdlg(msg,'Epsilon Parameter',1,{num2str(handles.parameters.epsilon)});
if isempty(answer), return; end % cancel pressed
numval = str2num(answer{1});
if isnumeric(numval) && ~isempty(numval)
handles.parameters.epsilon = numval;
end
% Whether to allow optimization of given hyperparameter
case 'do_optimize_cost_menu'
if ~handles.parameters.optimization.params_to_optimize.cost % then enabling it will prompt for new values...
minmsg = sprintf('Minimum (default = %0.3f):',handles.parameters.optimization.params_to_optimize.cost_range_default(1));
maxmsg = sprintf('Maximum (default = %0.2f):',handles.parameters.optimization.params_to_optimize.cost_range_default(2));
msg = {minmsg,maxmsg};
defaultans = {num2str(handles.parameters.optimization.params_to_optimize.cost_range(1)),num2str(handles.parameters.optimization.params_to_optimize.cost_range(2))};
answer = inputdlg(msg,'Cost Range',1,defaultans);
if isempty(answer), return; end % cancel pressed
if any(cellfun(@isempty,answer)), warndlg('Invalid Cost range.'); return; end
minval = str2num(answer{1}); maxval = str2num(answer{2});
if ~all([isnumeric(minval) isnumeric(maxval)]), warndlg('Cost range values must be numbers.'); return; end
if ~all([minval maxval] > 0), warndlg('Cost range values must be positive.'); return; end
handles.parameters.optimization.params_to_optimize.cost_range = sort([minval maxval]);
end
handles.parameters.optimization.params_to_optimize.cost = ~handles.parameters.optimization.params_to_optimize.cost;
case 'do_optimize_gamma_menu'
if ~handles.parameters.optimization.params_to_optimize.sigma % then enabling it will prompt for new values...
useLibSVM = handles.parameters.useLibSVM; % for convenience.
parmname = myif(useLibSVM,'Gamma','Sigma'); % depending on what algorithm the user is using.
defaultmin = handles.parameters.optimization.params_to_optimize.sigma_range_default(1);
defaultmax = handles.parameters.optimization.params_to_optimize.sigma_range_default(2);
minmsg = sprintf('Minimum (default = %0.3f):',myif(useLibSVM,sigma2gamma(defaultmin),defaultmin)); % convert to gamma if necessary
maxmsg = sprintf('Maximum (default = %0.2f):',myif(useLibSVM,sigma2gamma(defaultmax),defaultmax)); % convert to gamma if necessary
msg = {minmsg,maxmsg};
oldmin = handles.parameters.optimization.params_to_optimize.sigma_range(1);
oldmax = handles.parameters.optimization.params_to_optimize.sigma_range(2);
defaultans = {num2str(myif(useLibSVM,sigma2gamma(oldmin),oldmin)),num2str(myif(useLibSVM,sigma2gamma(oldmax),oldmax))}; % convert to gamma if necessary
answer = inputdlg(msg,[parmname ' Range'],1,defaultans); % display as gamma if necessary
if isempty(answer), return; end % cancel pressed
if any(cellfun(@isempty,answer)), warndlg(['Invalid ' parmname ' range.']); return; end
minval = str2num(answer{1}); maxval = str2num(answer{2});
if ~all([isnumeric(minval) isnumeric(maxval)]), warndlg([parmname ' range values must be numbers.']); return; end % display as gamma if necessary
if ~all([minval maxval] > 0), warndlg([parmname ' range values must be positive.']); return; end % display as gamma if necessary
handles.parameters.optimization.params_to_optimize.sigma_range = sort([myif(useLibSVM,sigma2gamma(minval),minval) myif(useLibSVM,sigma2gamma(maxval),maxval)]); % convert gamma back to sigma if necessary.
end
handles.parameters.optimization.params_to_optimize.sigma = ~handles.parameters.optimization.params_to_optimize.sigma;
case 'do_optimize_epsilon_menu'
if ~handles.parameters.optimization.params_to_optimize.epsilon % then enabling it will prompt for new values...
minmsg = sprintf('Minimum (default = %0.3f):',handles.parameters.optimization.params_to_optimize.epsilon_range_default(1));
maxmsg = sprintf('Maximum (default = %0.2f):',handles.parameters.optimization.params_to_optimize.epsilon_range_default(2));
msg = {minmsg,maxmsg};
defaultans = {num2str(handles.parameters.optimization.params_to_optimize.epsilon_range(1)),num2str(handles.parameters.optimization.params_to_optimize.epsilon_range(2))};
answer = inputdlg(msg,'Epsilon Range',1,defaultans);
if isempty(answer), return; end % cancel pressed
if any(cellfun(@isempty,answer)), warndlg('Invalid Epsilon range.'); return; end
minval = str2num(answer{1}); maxval = str2num(answer{2});
if ~all([isnumeric(minval) isnumeric(maxval)]), warndlg('Epsilon range values must be numbers.'); return; end
if ~all([minval maxval] > 0), warndlg('Epsilon range values must be positive.'); return; end
handles.parameters.optimization.params_to_optimize.epsilon_range = sort([minval maxval]);
end
handles.parameters.optimization.params_to_optimize.epsilon = ~handles.parameters.optimization.params_to_optimize.epsilon;
case 'do_optimize_standardize_menu'
handles.parameters.optimization.params_to_optimize.standardize = ~handles.parameters.optimization.params_to_optimize.standardize;
% Optimization misc choices
case 'optimization_iterations_menu_option'
answer = inputdlg('Enter a new number of iterations:','Number of optimization iterations',1,{num2str(handles.parameters.optimization.iterations)});
if isempty(answer), return; end % cancel pressed
str = str2num(answer{1});
if isempty(str) || str <= 0 || ~isint(str)
changemade=false;
warndlg('Input must be a positive integer.');
else % update the parameter value.
handles.parameters.optimization.iterations = str;
end
case 'griddivs_optimization_menu_option'
answer = inputdlg('Enter a new number of grid divisions:','Number of optimization grid divisions',1,{num2str(handles.parameters.optimization.grid_divisions)});
if isempty(answer), return; end % cancel pressed
str = str2num(answer{1});
if isempty(str) || str <= 0 || ~isint(str)
changemade=false;
warndlg('Input must be a positive integer.');
else % update the parameter value.
handles.parameters.optimization.grid_divisions = str;
end
% Optimization search strategy choice
case 'random_search_menu_option'
handles.parameters.optimization.search_strategy = 'Random Search';
case 'bayes_optimization_menu_choice'
handles.parameters.optimization.search_strategy = 'Bayes Optimization';
case 'gridsearch_option'
handles.parameters.optimization.search_strategy = 'Grid Search';
% Optimization objective function choice
case 'predictbehavior_optimize_menu_choice' % bayes opt predict behavior
handles.parameters.optimization.objective_function = 'Predict Behavior';
case 'correlation_optimize_menu_choice' % maximum correlation w behavior
handles.parameters.optimization.objective_function = 'Maximum Correlation';
case 'resubloss_optimize_menu_choice'
handles.parameters.optimization.objective_function = 'Resubstitution Loss';
% Whether or not to optimize hyperparameters
case 'no_optimize_menu_choice'
handles.parameters.optimization.do_optimize = false;
case 'current_optimization_menu_option'
handles.parameters.optimization.do_optimize = true; % will use whatever setting is configured.
% Which SVR algorithm to use
case 'use_lib_svm'
handles.parameters.useLibSVM = 1;
handles.parameters.crossval.do_crossval = false; % not currently supported for libsvm...
case 'use_matlab_svr'
handles.parameters.useLibSVM = 0;
case 'save_pre_thresh'
handles.parameters.SavePreThresholdedPermutations = ~handles.parameters.SavePreThresholdedPermutations;
case 'retain_big_binary_file'
handles.parameters.SavePermutationData = ~handles.parameters.SavePermutationData;
case 'save_post_vox_thresh'
handles.parameters.SavePostVoxelwiseThresholdedPermutations = ~handles.parameters.SavePostVoxelwiseThresholdedPermutations;
case 'save_post_clusterwise_thresholded'
handles.parameters.SavePostClusterwiseThresholdedPermutations= ~handles.parameters.SavePostClusterwiseThresholdedPermutations;
case 'save_unthresholded_pmaps_cfwer'
handles.parameters.SaveNullPMapsPreThresholding = ~handles.parameters.SaveNullPMapsPreThresholding;
case 'save_thresholded_pmaps_cfwer'
handles.parameters.SaveNullPMapsPostThresholding = ~handles.parameters.SaveNullPMapsPostThresholding;
case 'retain_big_binary_pval_file'
handles.parameters.SavePermutationPData = ~handles.parameters.SavePermutationPData;
case 'parallelizemenu'
handles.parameters.parallelize = ~handles.parameters.parallelize;
case 'applycovariatestobehaviorcheckbox'
handles.parameters.apply_covariates_to_behavior = get(gcbo,'value');
case 'applycovariatestolesioncheckbox'
handles.parameters.apply_covariates_to_lesion = get(gcbo,'value');
case 'lesionvolumecorrectiondropdown'
contents = get(handles.lesionvolumecorrectiondropdown,'string');
newval = contents{get(handles.lesionvolumecorrectiondropdown,'value')};
handles.parameters.lesionvolcorrection = newval;
case 'hypodirectiondropdown'
contents = get(handles.hypodirectiondropdown,'string');
newval = contents{get(handles.hypodirectiondropdown,'value')};
if find(strcmp(newval,handles.options.hypodirection)) == 3 % Disable two-tails from the GUI
warndlg('Two-tailed hypothesis tests are not available in this version of SVRLSMGUI.')
changemade = false;
else
handles.parameters.tails = newval;
end
case 'addcovariate'
% first, what are we trying to add?
contents = get(handles.potentialcovariateslist,'String');
newcovariate = contents{get(handles.potentialcovariateslist,'Value')};
if strcmp(newcovariate,handles.parameters.score_name) % check if it's our main score name...
warndlg('This variable is already chosen as the main outcome in the analysis. If you''d like to add it as a covariate, remove it from "Score Name."')
changemade = false;
elseif any(strcmp(newcovariate,handles.parameters.control_variable_names)) % only if it's not on our list of covariates already.
warndlg('This variable is already on the list of covariates. You may not add it twice.')
changemade = false;
else % it's new
handles.parameters.control_variable_names{end+1} = newcovariate;
end
case 'removecovariate'
contents = get(handles.potentialcovariateslist,'String'); % what are we trying to remove?
newcovariate = contents{get(handles.potentialcovariateslist,'Value')};
if any(strcmp(newcovariate,handles.parameters.control_variable_names)) % only if it IS on our list!
index_to_remove = strcmp(newcovariate,handles.parameters.control_variable_names);
handles.parameters.control_variable_names(index_to_remove) = [];
else
changemade = false;
end
case 'chooselesionfolderbutton'
folder_name = uigetdir(handles.parameters.lesion_img_folder,'Choose a folder containing lesion files for this analysis.');
if folder_name % if folder_name == 0 then cancel was clicked.
[~,attribs] = fileattrib(folder_name); % we need read access from here.
if attribs.UserRead
handles.parameters.lesion_img_folder = folder_name;
else
warndlg('You do not have read access to the directory you selected for the lesion files. Adjust the permissions and try again.')
changemade = false;
end
else
changemade = false;
end
case 'choosescorefilebutton'
[FileName,PathName] = uigetfile(fullfile(fileparts(handles.parameters.score_file),'*.csv'),'Select a file with behavioral scores.');
if FileName
scorefile_name = fullfile(PathName,FileName);
handles.parameters.score_file = scorefile_name;
handles.parameters.control_variable_names = {}; % also clear covariates...
else % cancel was clicked.
changemade = false;
end
case 'chooseoutputfolderbutton'
folder_name = uigetdir(handles.parameters.analysis_out_path,'Choose a folder in which to save this analysis.');
if folder_name
[~,attribs] = fileattrib(folder_name); % we need read/write access from here.
if attribs.UserRead && attribs.UserWrite
handles.parameters.analysis_out_path = folder_name;
else
warndlg('You do not have read and write access to the directory you selected to save your output. Adjust the permissions and try again.')
changemade = false;
end
else
changemade = false;
end
case 'scorenamepopupmenu' % User has changed the one_score in question...
contents = get(gcbo,'string');
newval = contents{get(gcbo,'value')};
if any(strcmp(newval,handles.parameters.control_variable_names))
warndlg('This variable is already chosen as a covariate. If you''d like to use it as the outcome of interest, remove it as a covariate.')
changemade = false;
else
handles.parameters.score_name = newval;
end
case 'analysisnameeditbox'
handles.parameters.analysis_name = get(gcbo,'string');
case 'lesionthresholdeditbox'
str = str2num(get(gcbo,'string')); %TO ADD: also make sure this doesn''t exceed the number of lesions available in the data
if isempty(str) || ~isint(str)
warndlg('Input must be a positive integer.');
changemade = false;
else % update the parameter value.
handles.parameters.lesion_thresh = str;
end
case 'computebetamapcheckbox'
handles.parameters.beta_map = get(gcbo,'value');
case 'computesensitivitymapcheckbox'
handles.parameters.sensitivity_map = get(gcbo,'value');
case 'cluster_voxelwise_p_editbox'
str = str2num(get(gcbo,'string'));
if isempty(str) || str <= 0 || str >= 1
changemade = false;
warndlg('Input must be a number between 0 and 1.');
else % update the parameter value.
handles.parameters.voxelwise_p = str;
end
case 'clusterwisepeditbox'
str = str2num(get(gcbo,'string'));
if isempty(str) || str <= 0 || str >= 1
warndlg('Input must be a number between 0 and 1.');
changemade = false;
else % update the parameter value.
handles.parameters.clusterwise_p = str;
end
case 'sv_scaling_95th_percentile'
handles.parameters.svscaling = 95;
case 'sv_scaling_99th_percentile'
handles.parameters.svscaling = 99;
case 'maxsvscaling'
handles.parameters.svscaling = 100; % default
case 'npermutationseditbox' % This is voxelwise permutations
str = str2num(get(gcbo,'string'));
if isempty(str) || str<=0 || ~isint(str)
changemade = false;
warndlg('Input must be a positive integer.');
else % update the parameter value.
handles.parameters.PermNumVoxelwise = str;
end
case 'permutationtestingcheckbox' % enable/disable permutation testing.
handles.parameters.DoPerformPermutationTesting = get(gcbo,'value');
case 'do_cfwer_checkbox'
handles.parameters.do_CFWER = get(gcbo,'value');
case 'cfwer_v_value_editbox'
str = str2num(get(gcbo,'string'));
if isempty(str) || str <= 0 || ~isint(str)
changemade=false;
warndlg('Input must be a positive integer.');
else % update the parameter value.
handles.parameters.cfwer_v_value = str; % note that this is cubic millimeters and will later be converted into # voxels (in read_lesioned_images)
end
case 'cfwer_p_value_editbox'
str = str2num(get(gcbo,'string'));
if isempty(str) || str<=0 || str >= 1 % not a valid p value...
changemade=false;
warndlg('Input must be a positive number less than 1.');
else % update the parameter value.
handles.parameters.cfwer_p_value = str;
end
case 'analysismask_menu_option_parent'
if strcmp(handles.parameters.analysis_mask_file,'')
maskstring = 'Select mask...';
else
maskstring = handles.parameters.analysis_mask_file;
end
handles.datamask_to_use_menu_option.Text = maskstring;
if handles.parameters.use_analysis_mask % then populate the menu item and set the checkbox...
handles.do_not_apply_datamask_menu_option.Checked = false;
handles.datamask_to_use_menu_option.Checked = true;
else % don't use mask.
handles.do_not_apply_datamask_menu_option.Checked = true;
handles.datamask_to_use_menu_option.Checked = false;
end
case 'do_not_apply_datamask_menu_option'
handles.parameters.use_analysis_mask = false;
changemade = true;
case 'datamask_to_use_menu_option'
disp('a')
handles.parameters.use_analysis_mask = true;
[FileName,PathName] = uigetfile('*.nii','Select a mask file within which to run the analysis.');
filepath = fullfile(PathName,FileName);
if ~exist(filepath,'file'), return; end
handles.parameters.analysis_mask_file = filepath;
changemade = true;
otherwise
warndlg(['Unknown callback object ' get(gcbo,'tag') ' - has someone modified the code?'])
end
if changemade % then set to not saved...
handles.parameters.is_saved = 0;
end
if ~handles.parameters.is_saved % then the analysis configuration was modified, so it hasn't been completed in its current state.
handles.parameters.analysis_is_completed = 0; % set "is completed" to 0 (in its current state) so the user can click run button, and cannot click show output button.
handles = PopulateGUIFromParameters(handles);
end
guidata(hObject, handles); % Update handles structure
UpdateTitleBar(handles); % update title bar to show if we have any changes made.
function doignore = IgnoreUnsavedChanges(handles)
if ~isfield(handles,'parameters') % something bad probably happened with gui initiation.
doignore = 1;
elseif isfield(handles.parameters,'is_saved') && ~handles.parameters.is_saved % then prompt if the user wants to continue or cancel.
choice = questdlg('If you continue you will lose unsaved changes to this analysis configuration.', 'Unsaved Changes', 'Continue Anyway','Cancel','Cancel');
switch choice
case 'Continue Anyway', doignore = 1;
case 'Cancel', doignore = 0;
end
else % don't hang
doignore = 1;
end
% --- Outputs from this function are returned to the command line.
function varargout = svrlsmgui_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function newmenu_Callback(hObject, eventdata, handles) %#ok<*DEFNU>
if IgnoreUnsavedChanges(handles)
handles.parameters = GetDefaultParameters(handles);
handles = PopulateGUIFromParameters(handles);
end
function openmenu_Callback(hObject, eventdata, handles)
if IgnoreUnsavedChanges(handles)
[FileName,PathName] = uigetfile('*.mat','Select an SVRLSMGUI parameters file.');
filepath = fullfile(PathName,FileName);
if ~exist(filepath,'file'), return; end
handles = LoadParametersFromSVRLSMFile(handles,hObject,filepath);
end
function closemenu_Callback(hObject, eventdata, handles)
if IgnoreUnsavedChanges(handles)
delete(gcf)
end
function savemenu_Callback(hObject, eventdata, handles)
if exist(handles.parameters.parameter_file_name,'file')
handles = SaveSVRLSMGUIFile(handles,hObject); % do the actual save.
else
saveasmenu_Callback(hObject, eventdata, handles)
end
function saveasmenu_Callback(hObject, eventdata, handles)
if exist(handles.parameters.parameter_file_name,'file')
defaultsavename = handles.parameters.parameter_file_name; % fileparts(handles.parameters.parameter_file_name);
else
defaultsavename = fullfile(pwd,'Unnamed.mat');
end
[file,path] = uiputfile('*.mat','Save SVRLSM GUI parameter file as...',defaultsavename);
if file == 0 % then cancel was pressed
return;
end
handles.parameters.parameter_file_name = fullfile(path,file);
handles = SaveSVRLSMGUIFile(handles,hObject); % do the actual save.
function quitmenu_Callback(hObject, eventdata, handles)
close(gcf) % to trigger close request fcn which handles unsaved changes...
function onlinehelpmenu_Callback(hObject, eventdata, handles)
web('https://github.com/atdemarco/svrlsmgui/wiki')
function figure1_CreateFcn(hObject, eventdata, handles)
function aboutmenu_Callback(hObject, eventdata, handles)
helpstr = ['SVRLSM GUI ' num2str(handles.parameters.gui_version) ', Andrew DeMarco 2017-2018, based on Zhang et al. (2014)'];
helpdlg(helpstr,'About');
function runanalysisbutton_Callback(hObject, eventdata, handles)
[success,handles] = RunAnalysis(hObject,eventdata,handles); % now returns handles 10/26/17
set(handles.runanalysisbutton,'Enable','on') %set(handles.cancelanalysisbutton,'visible','off')
% Re-enable interface...
set(get(handles.permutationtestingpanel,'children'),'enable','on')
set(get(handles.analysispreferencespanel,'children'),'enable','on')
set(get(handles.covariatespanel,'children'),'enable','on')
switch success
case 1 % success
handles.parameters.analysis_is_completed = 1; % Completed...
handles = UpdateProgress(handles,'Analysis has completed successfully.',1);
case 0 % failure
handles.parameters.analysis_is_completed = 2; % Error...
handles = UpdateProgress(handles,'Analysis encountered an error and did not complete...',1);
set(handles.interrupt_button,'enable','off') % disable.
rethrow(handles.error)
case 2 % interrupted
handles.parameters.analysis_is_completed = 2; % Error...
handles = UpdateProgress(handles,'Analysis was interrupted by user...',1);
end
guidata(hObject, handles); % Update handles structure
handles = PopulateGUIFromParameters(handles); % refresh gui so we can enable/disable control variable as necessary.
% Select in the dropdown list the selected item.
function realcovariateslistbox_Callback(hObject, eventdata, handles)
if isempty(get(hObject,'String')), return; end % hack for error
contents = cellstr(get(hObject,'String'));
val = contents{get(hObject,'Value')};
dropdownoptions = get(handles.potentialcovariateslist,'string');
set(handles.potentialcovariateslist,'value',find(strcmp(val,dropdownoptions)))
function optionsmenu_Callback(hObject, eventdata, handles)
yn = {'off','on'};
set(handles.parallelizemenu,'Checked',yn{1+handles.parameters.parallelize}) % is parallelization selected by user?
set(handles.parallelizemenu,'Enable',yn{1+handles.details.can_parallelize}) % can we parallelize on this platform?
function SVscalingmenu_Callback(hObject, eventdata, handles)
children = get(handles.SVscalingmenu,'children');
set(children,'Checked','off')
switch handles.parameters.svscaling
case 100 % these are ordered "backward" seeming, so 3rd is top in list
set(children(3),'Checked','on')
case 99
set(children(2),'Checked','on')
case 95
set(children(1),'Checked','on')
end
function save_perm_data_Callback(hObject, eventdata, handles) % update the subitems with checkboxes
yn = {'off','on'};
set(handles.save_post_clusterwise_thresholded,'Checked',yn{1+handles.parameters.SavePostClusterwiseThresholdedPermutations})
set(handles.save_post_vox_thresh,'Checked',yn{1+handles.parameters.SavePostVoxelwiseThresholdedPermutations})
set(handles.save_pre_thresh,'Checked',yn{1+handles.parameters.SavePreThresholdedPermutations})
% the cfwer files...
set(handles.save_unthresholded_pmaps_cfwer,'Checked',yn{1+handles.parameters.SaveNullPMapsPreThresholding})
set(handles.save_thresholded_pmaps_cfwer,'Checked',yn{1+handles.parameters.SaveNullPMapsPostThresholding})
function svrmenu_Callback(hObject, eventdata, handles)
if handles.parameters.useLibSVM
set(handles.use_lib_svm,'checked','on')
set(handles.use_matlab_svr,'checked','off')
else
set(handles.use_lib_svm,'checked','off')
set(handles.use_matlab_svr,'checked','on')
end
if handles.details.stats_toolbox
set(handles.use_matlab_svr,'enable','on')
else
set(handles.use_matlab_svr,'enable','off')
end
if handles.details.libsvm
set(handles.use_lib_svm,'enable','on')
else
set(handles.use_lib_svm,'enable','off')
end
function cost_menu_Callback(hObject, eventdata, handles)
msg = sprintf('Enter new parameter value for Cost/BoxConstraint (default = %0.1f)',handles.parameters.svr_defaults.cost);
answer = inputdlg(msg,'Cost Parameter',1,{num2str(handles.parameters.cost)});
if isempty(answer), return; end % cancel pressed
numval = str2num(answer{1}); %#ok<*ST2NM>
if isnumeric(numval) && ~isempty(numval)
handles.parameters.cost = numval;
handles.parameters.is_saved = 0;
guidata(hObject, handles);
handles = PopulateGUIFromParameters(handles);
end
function gamma_menu_Callback(hObject, eventdata, handles)
useLibSVM = handles.parameters.useLibSVM; % for convenience.
parmname = myif(useLibSVM,'Gamma','Sigma'); % depending on what algorithm the user is using.
defaultval = handles.parameters.svr_defaults.sigma;
msg = sprintf('Enter new parameter value for %s (default = %0.1f)',parmname,myif(useLibSVM,sigma2gamma(defaultval),defaultval)); % convert to gamma if necessary
oldval = handles.parameters.sigma;
answer = inputdlg(msg,[parmname ' Parameter'],1,{num2str(myif(useLibSVM,sigma2gamma(oldval),oldval))}); % convert to gamma if necessary
if isempty(answer), return; end % cancel pressed
numval = str2num(answer{1});
if isnumeric(numval) && ~isempty(numval)
handles.parameters.sigma = myif(useLibSVM,gamma2sigma(numval),numval); % store as sigma, so convert input gamma to sigma if necessary...
handles.parameters.is_saved = 0;
guidata(hObject, handles);
handles = PopulateGUIFromParameters(handles);
end
function open_batch_job_Callback(hObject, eventdata, handles)
folder_name = uigetdir(pwd,'Choose a folder containing .mat config files of your analyses.');
if ~folder_name, return; end % if folder_name == 0 then cancel was clicked.
files = dir(fullfile(folder_name,'*.mat'));
fname = {files.name};
[s,v] = listdlg('PromptString','Choose the analyses to run:','SelectionMode','multi','ListString',fname);
if ~v, return; end % cancelled..
for f = 1:numel(s)
curs=s(f);
curfname = fname{curs};
curfile = fullfile(folder_name,curfname);
% try % so one or more can fail without stopping them all.
handles = UpdateProgress(handles,['Batch: Starting file ' curfname '...'],1);
[success,handles] = RunAnalysisNoGUI(curfile,handles); % second parm, handles, allows access to gui elements, etc.
handles = UpdateProgress(handles,['Batch: Finished file ' curfname '.'],1);
switch success
case 1 % success
handles.parameters.analysis_is_completed = 1; % Completed...
handles = UpdateProgress(handles,['Batch: Finished file successfully ' curfname '.'],1);
case 0 % failure
handles.parameters.analysis_is_completed = 2; % Error...
%handles = UpdateProgress(handles,'Analysis encountered an error and did not complete...',1);
handles = UpdateProgress(handles,['Batch: Analysis encountered an error and did not complete: ' curfname '.'],1);
if isfield(handles,'interrupt_button')
set(handles.interrupt_button,'enable','off') % disable.
end
rethrow(handles.error)
end
% catch
% disp('return from open_batch_job in svrlsmgui() with error')
% msg = ['A batch job specified by file ' fname{curs} ' encountered an error and was aborted.'];
% warning(msg)
% end
end
handles = UpdateProgress(handles,'Batch: All batch jobs done.',1);
function figure1_CloseRequestFcn(hObject, eventdata, handles)
if IgnoreUnsavedChanges(handles), delete(hObject); end
function checkforupdates_Callback(hObject, eventdata, handles)
update_available = check_for_updates;
if ~update_available
msgbox('There are no updates available.')
return
end
choice = questdlg('New updates are available, would you like to download them?','Update SVRLSMGUI','Not now','Update now','Update now');
if strcmp(choice,'Not now'), return, end
get_new_version(handles)
%% callbacks -- replace these in the future.
function controlvariablepopupmenu_Callback(hObject, eventdata, handles)
handles = UpdateCurrentAnalysis(handles,hObject);
function computebetamapcheckbox_Callback(hObject, eventdata, handles)
handles = UpdateCurrentAnalysis(handles,hObject);
function computesensitivitymapcheckbox_Callback(hObject, eventdata, handles)
handles = UpdateCurrentAnalysis(handles,hObject);
function analysisnameeditbox_Callback(hObject, eventdata, handles)
handles = UpdateCurrentAnalysis(handles,hObject);
function permutation_unthresholded_checkbox_Callback(hObject, eventdata, handles)
handles = UpdateCurrentAnalysis(handles,hObject);
function permutation_voxelwise_checkbox_Callback(hObject, eventdata, handles)
handles = UpdateCurrentAnalysis(handles,hObject);
function permutation_largest_cluster_Callback(hObject, eventdata, handles)
handles = UpdateCurrentAnalysis(handles,hObject);
function progresslistbox_Callback(hObject, eventdata, handles)
function maxsvscaling_Callback(hObject, eventdata, handles)
handles = UpdateCurrentAnalysis(handles,hObject);
function potentialcovariateslist_Callback(hObject, eventdata, handles)
function viewresultsbutton_Callback(hObject, eventdata, handles)
LaunchResultsDirectory(hObject,eventdata,handles);
function npermutationsclustereditbox_Callback(hObject, eventdata, handles)
handles = UpdateCurrentAnalysis(handles,hObject);
function parallelizemenu_Callback(hObject, eventdata, handles)
handles = UpdateCurrentAnalysis(handles,hObject);
function sv_scaling_99th_percentile_Callback(hObject, eventdata, handles)
handles = UpdateCurrentAnalysis(handles,hObject);
function sv_scaling_95th_percentile_Callback(hObject, eventdata, handles)
handles = UpdateCurrentAnalysis(handles,hObject);
function debug_menu_Callback(hObject, eventdata, handles)
function use_lib_svm_Callback(hObject, eventdata, handles)
handles = UpdateCurrentAnalysis(handles,hObject);
function use_matlab_svr_Callback(hObject, eventdata, handles)
handles = UpdateCurrentAnalysis(handles,hObject);
function interrupt_button_Callback(hObject, eventdata, handles) % attempt to interrupt an ongoing analysis
set(hObject,'enable','off') % so user doesn't click a bunch...
% poolobj = gcp('nocreate'); % < this doesn't stop, it just relaunches the parpool...
% delete(poolobj); % try to stop what's happening if there's parallelization happening
set(gcf,'userdata','cancel')
guidata(hObject, handles); % Update handles structure so it saves...
function no_optimize_menu_choice_Callback(hObject, eventdata, handles)
handles = UpdateCurrentAnalysis(handles,hObject);
function correlation_optimize_menu_choice_Callback(hObject, eventdata, handles)
handles = UpdateCurrentAnalysis(handles,hObject);
function resubloss_optimize_menu_choice_Callback(hObject, eventdata, handles)
handles = UpdateCurrentAnalysis(handles,hObject);
function predictbehavior_optimize_menu_choice_Callback(hObject, eventdata, handles)
handles = UpdateCurrentAnalysis(handles,hObject);
function optimize_menu_Callback(hObject, eventdata, handles)
set(get(hObject,'Children'),'Checked','off') % uncheck all child menus
cur_optim_string = CurrentOptimString(handles.parameters);
set(handles.current_optimization_menu_option,'Label',cur_optim_string)
opts = [handles.parameters_to_optimize_menu handles.search_strategy_menu_option handles.objective_function_menu_option handles.crossvalidation_parent_menu handles.optimization_is_verbose_menu];
if ~handles.parameters.optimization.do_optimize % then no optimization...
set(handles.no_optimize_menu_choice,'Checked','on')
set(opts,'enable','off') % Visual cue that these don't apply when optimization is off
else
set(handles.current_optimization_menu_option,'Checked','on')
set(opts,'enable','on') % Visual cue that these don't apply when optimization is off
end
if handles.parameters.optimization.verbose_during_optimization
set(handles.optimization_is_verbose_menu,'Checked','on')
end
function current_optimization_menu_option_Callback(hObject, eventdata, handles)
handles = UpdateCurrentAnalysis(handles,hObject);
function parameters_menu_Callback(hObject, eventdata, handles)
do_opt = handles.parameters.optimization.do_optimize; % for convenience
if do_opt && handles.parameters.optimization.params_to_optimize.cost
label = ['Cost: optimize (' num2str(handles.parameters.optimization.params_to_optimize.cost_range(1)) ' - ' num2str(handles.parameters.optimization.params_to_optimize.cost_range(2)) ')'];
set(handles.cost_menu,'label',label,'enable','off');
else
set(handles.cost_menu,'label',['Cost: ' num2str(handles.parameters.cost) myif(handles.parameters.svr_defaults.cost == handles.parameters.cost,' (default)','')],'enable','on');
end
useLibSVM = handles.parameters.useLibSVM; % for convenience.
parmname = myif(useLibSVM,'Gamma','Sigma'); % depending on what algorithm the user is using.
if do_opt && handles.parameters.optimization.params_to_optimize.sigma
oldmin = handles.parameters.optimization.params_to_optimize.sigma_range(1);
oldmax = handles.parameters.optimization.params_to_optimize.sigma_range(2);
label = [parmname ': optimize (' num2str(myif(useLibSVM,sigma2gamma(oldmin),oldmin)) ' - ' num2str(myif(useLibSVM,sigma2gamma(oldmax),oldmax)) ')'];
set(handles.gamma_menu,'label',label,'enable','off');
else
cursigma = handles.parameters.sigma; % Display as gamma if use libSVM
cursigma = myif(useLibSVM,sigma2gamma(cursigma),cursigma); % Display as gamma if use libSVM
set(handles.gamma_menu,'label',[parmname ': ' num2str(cursigma) myif(handles.parameters.svr_defaults.sigma == handles.parameters.sigma,' (default)','')],'enable','on'); % Display as gamma if use libSVM
end
if do_opt && handles.parameters.optimization.params_to_optimize.epsilon
label = ['Epsilon: optimize (' num2str(handles.parameters.optimization.params_to_optimize.epsilon_range(1)) ' - ' num2str(handles.parameters.optimization.params_to_optimize.epsilon_range(2)) ')'];
set(handles.epsilon_menu,'label',label,'enable','off');
else
set(handles.epsilon_menu,'label',['Epsilon: ' num2str(handles.parameters.epsilon) myif(handles.parameters.svr_defaults.epsilon == handles.parameters.epsilon,' (default)','')],'enable','on');
end
if do_opt && handles.parameters.optimization.params_to_optimize.standardize
set(handles.standardize_menu,'label','Standardize: optimize (yes/no)','enable','off');
else
set(handles.standardize_menu,'label',['Standardize: ' myif(handles.parameters.standardize,'true','false') myif(handles.parameters.svr_defaults.standardize == handles.parameters.standardize,' (default)','')],'enable','on');
end
function epsilon_menu_Callback(hObject, eventdata, handles)
handles = UpdateCurrentAnalysis(handles,hObject);
function standardize_menu_Callback(hObject, eventdata, handles)
handles = UpdateCurrentAnalysis(handles,hObject);
%% Objective function...
function objective_function_menu_option_Callback(hObject, eventdata, handles)
set(get(hObject,'Children'),'Checked','off') % uncheck all child menus
set([handles.predictbehavior_optimize_menu_choice handles.correlation_optimize_menu_choice],'enable','off')
switch handles.parameters.optimization.objective_function
case 'Predict Behavior'
set(handles.predictbehavior_optimize_menu_choice,'Checked','on')
case 'Maximum Correlation'
set(handles.correlation_optimize_menu_choice,'Checked','on')
case 'Resubstitution Loss'
set(handles.resubloss_optimize_menu_choice,'Checked','on')
otherwise
error('Unknown optimization objective function.')
end
%% Search strategy ...
function search_strategy_menu_option_Callback(hObject, eventdata, handles)
set(get(hObject,'Children'),'Checked','off') % uncheck all child menus
switch handles.parameters.optimization.search_strategy
case 'Bayes Optimization'
set(handles.bayes_optimization_menu_choice,'Checked','on')
case 'Grid Search'
set(handles.gridsearch_option,'Checked','on')
case 'Random Search'
set(handles.random_search_menu_option,'Checked','on')
otherwise
error('Unknown optimization objective function.')
end
function parameters_to_optimize_menu_Callback(hObject, eventdata, handles)
set(get(hObject,'children'),'checked','off')
if handles.parameters.optimization.params_to_optimize.cost
label = ['Cost (' num2str(handles.parameters.optimization.params_to_optimize.cost_range(1)) ' - ' num2str(handles.parameters.optimization.params_to_optimize.cost_range(2)) ')'];
set(handles.do_optimize_cost_menu,'label',label,'checked','on')
end
useLibSVM = handles.parameters.useLibSVM; % for convenience.
parmname = myif(useLibSVM,'Gamma','Sigma'); % depending on what algorithm the user is using, show gamma vs sigma...