0001 function varargout = prt_ui_results(varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 gui_Singleton = 1;
0035 gui_State = struct('gui_Name', mfilename, ...
0036 'gui_Singleton', gui_Singleton, ...
0037 'gui_OpeningFcn', @prt_ui_results_OpeningFcn, ...
0038 'gui_OutputFcn', @prt_ui_results_OutputFcn, ...
0039 'gui_LayoutFcn', [] , ...
0040 'gui_Callback', []);
0041 if nargin && ischar(varargin{1})
0042 gui_State.gui_Callback = str2func(varargin{1});
0043 end
0044
0045 if nargout
0046 [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0047 else
0048 gui_mainfcn(gui_State, varargin{:});
0049 end
0050
0051
0052
0053
0054 function prt_ui_results_OpeningFcn(hObject, eventdata, handles, varargin)
0055
0056
0057
0058
0059
0060
0061
0062 Tag='Results';
0063 F = findall(allchild(0),'Flat','Tag',Tag);
0064 if length(F) > 1
0065
0066 close(F(2:end))
0067 F = F(1);
0068 uistack(F,'top')
0069 elseif length(F)==1
0070 uistack(F,'top')
0071 else
0072 set(handles.figure1,'Tag',Tag)
0073 set(handles.figure1,'Name','PRoNTo :: Results')
0074 set(handles.figure1,'MenuBar','figure','WindowStyle','normal');
0075
0076
0077
0078 S0= spm('WinSize','0',1);
0079 if ispc
0080 PF='MS Sans Serif';
0081 else
0082 PF= spm_platform('fonts');
0083 PF=PF.helvetica;
0084 end
0085 tmp = [S0(3)/1280 (S0(4))/800];
0086 ratio=min(tmp)*[1 1 1 1];
0087 FS = 1 + 0.85*(min(ratio)-1);
0088 x=get(handles.figure1,'Position');
0089 set(handles.figure1,'Position',ratio.*x)
0090 set(handles.figure1,'Resize','on')
0091
0092
0093 color=prt_get_defaults('color');
0094 set(handles.figure1,'Color',color.bg1)
0095 aa=get(handles.figure1,'children');
0096 for i=1:length(aa)
0097 if strcmpi(get(aa(i),'type'),'uipanel')
0098 set(aa(i),'BackgroundColor',color.bg2)
0099 bb=get(aa(i),'children');
0100 if ~isempty(bb)
0101 for j=1:length(bb)
0102 if strcmpi(get(bb(j),'type'),'uipanel')
0103 cc=get(bb(j),'children');
0104 set(bb(j),'BackgroundColor',color.bg2)
0105 for k=1:length(cc)
0106 if strcmpi(get(cc(k),'type'),'uipanel')
0107 dd=get(cc(k),'children');
0108 set(cc(k),'BackgroundColor',color.bg2)
0109 for l=1:length(dd)
0110 if strcmpi(get(dd(l),'type'),'uicontrol')
0111 if ~isempty(find(strcmpi(get(dd(l),'Style'),{'text',...
0112 'radiobutton','checkbox'})))
0113 set(dd(l),'BackgroundColor',color.bg2)
0114 elseif ~isempty(find(strcmpi(get(dd(l),'Style'),'pushbutton')))
0115 set(dd(l),'BackgroundColor',color.fr)
0116 end
0117 end
0118 set(dd(l),'FontUnits','pixel')
0119 xf=get(dd(l),'FontSize');
0120 if ispc
0121 set(dd(l),'FontSize',ceil(FS*xf),'FontName',PF,...
0122 'FontUnits','normalized','Units','normalized')
0123 else
0124 set(dd(l),'FontSize',ceil(FS*xf),'FontName',PF,...
0125 'Units','normalized')
0126 end
0127 end
0128 elseif strcmpi(get(cc(k),'type'),'uicontrol') && ...
0129 ~isempty(find(strcmpi(get(cc(k),'Style'),{'text',...
0130 'radiobutton','checkbox'})))
0131 set(cc(k),'BackgroundColor',color.bg2)
0132 elseif strcmpi(get(cc(k),'type'),'uicontrol')&& ...
0133 ~isempty(find(strcmpi(get(cc(k),'Style'),'pushbutton')))
0134 set(cc(k),'BackgroundColor',color.fr)
0135 end
0136 set(cc(k),'FontUnits','pixel')
0137 xf=get(cc(k),'FontSize');
0138 set(cc(k),'FontSize',ceil(FS*xf),'FontName',PF,...
0139 'Units','normalized')
0140 end
0141 elseif strcmpi(get(bb(j),'type'),'uicontrol') && ...
0142 ~isempty(find(strcmpi(get(bb(j),'Style'),{'text',...
0143 'radiobutton','checkbox'})))
0144 set(bb(j),'BackgroundColor',color.bg2)
0145 elseif strcmpi(get(bb(j),'type'),'uicontrol') && ...
0146 ~isempty(find(strcmpi(get(bb(j),'Style'),'pushbutton')))
0147 set(bb(j),'BackgroundColor',color.fr)
0148 end
0149 set(bb(j),'FontUnits','pixel')
0150 xf=get(bb(j),'FontSize');
0151 set(bb(j),'FontSize',ceil(FS*xf),'FontName',PF,...
0152 'Units','normalized')
0153 end
0154 end
0155 elseif strcmpi(get(aa(i),'type'),'uicontrol')
0156 if ~isempty(find(strcmpi(get(aa(i),'Style'),{'text',...
0157 'radiobutton','checkbox'})))
0158 set(aa(i),'BackgroundColor',color.bg1)
0159 elseif ~isempty(find(strcmpi(get(aa(i),'Style'),'pushbutton')))
0160 set(aa(i),'BackgroundColor',color.fr)
0161 end
0162 end
0163 if ~strcmpi(get(aa(i),'type'),'uimenu')
0164 set(aa(i),'FontUnits','pixel')
0165 xf=get(aa(i),'FontSize');
0166 set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0167 'Units','normalized')
0168 end
0169 end
0170
0171
0172
0173
0174
0175 if ~isfield(handles,'notinit')
0176
0177
0178 PRT = spm_select(1,'mat','Select PRT.mat',[],pwd,'PRT.mat');
0179 pathdir = regexprep(PRT,'PRT.mat', '');
0180 handles.pathdir = pathdir;
0181 handles.prtdir=fileparts(PRT);
0182 load(PRT);
0183
0184
0185 handles.PRT = PRT;
0186
0187
0188 handles.noloadw = 0;
0189
0190
0191 if ~isfield(PRT,'model')
0192 error('No models found in PRT.mat!')
0193 end
0194 nmodels = length(PRT.model);
0195 mi = [];
0196 nmi = 0;
0197 for m = 1:nmodels
0198 if isfield(PRT.model(m),'input') && ~isempty(PRT.model(m).input)
0199 if isfield(PRT.model(m),'output') && ~isempty(PRT.model(m).output)
0200 nmi = nmi +1;
0201 model_name{nmi} = PRT.model(m).model_name;
0202 mi = [mi, m];
0203 else
0204 beep;
0205 disp(sprintf('Model %s not estimated! It will not be displayed',PRT.model(m).model_name));
0206 end
0207 else
0208 beep;
0209 disp(sprintf('Model %s not properly specified! It will not be displayed',PRT.model(m).model_name));
0210 end
0211
0212 end
0213 if ~nmi, error('There are no estimated/good models in this PRT!'); end
0214
0215 handles.mi = mi;
0216
0217
0218 handles.mnames = model_name;
0219 set(handles.classmenu,'String',handles.mnames);
0220
0221
0222 m = get(handles.classmenu,'Value');
0223 handles.nfold = length(PRT.model(mi(m)).output.fold);
0224 folds{1} = 'All folds / Average';
0225 for f = 1:handles.nfold
0226 folds{f+1} = num2str(f);
0227 end
0228 handles.folds = folds;
0229 set(handles.foldmenu,'String',handles.folds);
0230
0231
0232 if strcmp(PRT.model(mi(m)).input.type,'classification');
0233 if length(PRT.model(mi(m)).output.stats.c_acc) <= 2 ;
0234 plots = {'Histogram','Confusion Matrix','Predictions','ROC'};
0235 else
0236 plots = {'Histogram','Confusion Matrix','Predictions'};
0237 end
0238 else
0239 plots = {'Predictions (scatter)', 'Predictions (bar)', 'Predictions (line)'};
0240 end
0241 if isfield(PRT.model(mi(m)).input,'use_nested_cv')
0242 if PRT.model(mi(m)).input.use_nested_cv
0243 plots{length(plots)+1} = 'Influence of the hyper-parameter on performance';
0244 end
0245 end
0246 set(handles.plotmenu,'String',plots);
0247
0248
0249 handles.model_button = 0;
0250
0251
0252 handles.save_weights = 0;
0253 set(handles.save_perm_weights,'Value',0);
0254
0255
0256
0257
0258 cla(handles.axes5);
0259 end
0260 end
0261
0262
0263 handles.output = hObject;
0264
0265
0266 guidata(hObject, handles);
0267
0268
0269
0270
0271
0272
0273 function varargout = prt_ui_results_OutputFcn(hObject, eventdata, handles)
0274
0275
0276
0277
0278
0279
0280 varargout{1} = handles.output;
0281
0282
0283
0284 function originbutton_Callback(hObject, eventdata, handles)
0285
0286
0287
0288
0289
0290
0291 if isfield(handles,'img')
0292 spm_orthviews('Reposition',[0 0 0]);
0293 end
0294
0295 function mmedit_Callback(hObject, eventdata, handles)
0296
0297
0298
0299
0300
0301
0302
0303
0304
0305 if isfield(handles,'img')
0306 mp = handles.mmedit;
0307 posmm = get(mp,'String');
0308 pos = sscanf(posmm, '%g %g %g');
0309 if length(pos)~=3
0310 pos = spm_orthviews('Pos');
0311 end
0312 spm_orthviews('Reposition',pos);
0313 end
0314
0315
0316 function mmedit_CreateFcn(hObject, eventdata, handles)
0317
0318
0319
0320
0321
0322
0323 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0324 set(hObject,'BackgroundColor','white');
0325 end
0326
0327
0328 function vxedit_Callback(hObject, eventdata, handles)
0329
0330
0331
0332
0333
0334
0335
0336
0337
0338 if isfield(handles,'img')
0339 mp = handles.vxedit;
0340 posvx = get(mp,'String');
0341 pos = sscanf(posvx, '%g %g %g');
0342 if length(pos)~=3
0343 pos = spm_orthviews('pos',1);
0344 end
0345 tmp = handles.vols{1}.mat;
0346 pos = tmp(1:3,:)*[pos ; 1];
0347 spm_orthviews('Reposition',pos);
0348 end
0349
0350
0351
0352 function vxedit_CreateFcn(hObject, eventdata, handles)
0353
0354
0355
0356
0357
0358
0359 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0360 set(hObject,'BackgroundColor','white');
0361 end
0362
0363
0364
0365
0366 function helpbutton_Callback(hObject, eventdata, handles)
0367
0368
0369
0370
0371 disp('Help window for PRoNTo results has been launched.')
0372 prt_ui_results_help;
0373
0374
0375 function quitbutton_Callback(hObject, eventdata, handles)
0376
0377
0378
0379
0380
0381
0382 close(handles.figure1);
0383
0384
0385 function loadweight_Callback(hObject, eventdata, handles)
0386
0387
0388
0389
0390
0391
0392
0393
0394
0395 function loadweight_CreateFcn(hObject, eventdata, handles)
0396
0397
0398
0399
0400
0401
0402 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0403 set(hObject,'BackgroundColor','white');
0404 end
0405
0406
0407
0408 function weightbutton_Callback(hObject, eventdata, handles)
0409
0410
0411
0412
0413 disp('Loading weights...>>')
0414
0415
0416 if ~isfield(handles,'wmap') || ~handles.noloadw
0417 wmap = spm_select(1,'image','Select weight map.');
0418
0419 if strcmp(wmap(end-1),',')
0420 wmap = wmap(1:end-2);
0421 end
0422 V = spm_vol(wmap);
0423 handles.vols{1} = V;
0424 handles.wmap = wmap;
0425
0426 end
0427
0428 spm_orthviews('Reset');
0429 if isfield(handles,'aimg')
0430 anatomicalbutton_Callback(hObject, eventdata, handles);
0431 end
0432
0433
0434
0435 fold = get(handles.foldmenu,'Value')-1;
0436 Vfolds = handles.vols{1};
0437 V = Vfolds(1);
0438 M = V.mat;
0439 DIM = V.dim(1:3)';
0440 xdim = DIM(1); ydim = DIM(2); zdim = DIM(3);
0441 if length(V.private.dat.dim) < 4
0442 fdim = 1;
0443 else
0444 fdim = V.private.dat.dim(4);
0445 end
0446 [xords,yords] = ndgrid(1:xdim,1:ydim);
0447 xords = xords(:)'; yords = yords(:)';
0448 I = 1:xdim*ydim;
0449 zords_init = ones(1,xdim*ydim);
0450
0451
0452
0453 xyz_above = [];
0454 z_above = [];
0455 if fold == 0,
0456 fold_coord = fdim*ones(1,xdim*ydim);
0457 V = Vfolds(fdim);
0458 else
0459 fold_coord = fold*ones(1,xdim*ydim);
0460 V = Vfolds(fold);
0461 end
0462
0463 for z = 1:zdim,
0464 zords = z*zords_init;
0465 xyz = [xords(I); yords(I); zords(I); fold_coord];
0466 zvals = spm_get_data(V,xyz);
0467 above = find(~isnan(zvals));
0468 if length(above)==length(zvals)
0469 above = find(zvals~=0);
0470 end
0471 if ~isempty(above)
0472 xyz_above = [xyz_above,xyz(:,above)];
0473 z_above = [z_above,zvals(above)];
0474 end
0475 end
0476 XYZ = xyz_above(1:3,:);
0477 Z = z_above;
0478
0479
0480
0481 rotate3d off
0482 global st
0483
0484 handles.notinit = 1;
0485 handles.img = 1;
0486
0487 st.handles = handles;
0488 st.fig = handles.figure1;
0489 st.V = V;
0490 st.callback = 'prt_ui_results(''showpos'')';
0491
0492
0493
0494 h = spm_orthviews('Image', handles.wmap,[0.0619 0.0859 0.40 0.4196]);
0495 handles.wimgh = h;
0496 spm_orthviews('AddContext', h);
0497 spm_orthviews('MaxBB');
0498 spm_orthviews('AddBlobs', h, XYZ, Z, M);
0499 cmap = get(gcf,'Colormap');
0500 if size(cmap,1)~=128
0501 spm_figure('Colormap','jet');
0502 end
0503 spm_orthviews('Redraw');
0504
0505
0506
0507 prt_ui_results('showpos');
0508
0509 disp('Done');
0510
0511
0512 handles.noloadw = 1;
0513
0514
0515
0516 set(handles.loadweight,'String',handles.wmap);
0517 guidata(hObject, handles);
0518
0519 function loadanatomical_Callback(hObject, eventdata, handles)
0520
0521
0522
0523
0524
0525
0526
0527
0528
0529 function loadanatomical_CreateFcn(hObject, eventdata, handles)
0530
0531
0532
0533
0534
0535
0536 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0537 set(hObject,'BackgroundColor','white');
0538 end
0539
0540
0541
0542 function anatomicalbutton_Callback(hObject, eventdata, handles)
0543
0544
0545
0546
0547
0548
0549 if ~isfield(handles,'wmap')
0550 spm_orthviews('Reset');
0551 end
0552 global st
0553 st.fig = handles.figure1;
0554 if ~isfield(handles,'aimg') || ~handles.noloadi
0555 img = spm_select(1,'image','Select anatomical image.');
0556 else
0557 img = handles.aimg;
0558 end
0559
0560
0561
0562 rotate3d off
0563 st.fig = handles.figure1;
0564 handle = spm_orthviews('Image', img, [0.5295 0.0859 0.4196 0.4196]);
0565 cmap = get(gcf,'Colormap');
0566 if size(cmap,1)~=128
0567 spm_figure('Colormap','gray')
0568 end
0569
0570 handles.aimgh = handle;
0571 handles.aimg = img;
0572 handles.img = 1;
0573 handles.noloadi = 1;
0574
0575
0576
0577 set(handles.loadanatomical,'String',handles.aimg);
0578
0579 guidata(hObject, handles);
0580
0581
0582
0583 function foldmenu_Callback(hObject, eventdata, handles)
0584
0585
0586
0587
0588
0589
0590
0591
0592
0593 if ~handles.model_button
0594 if isfield(handles,'vols')
0595 handles.noloadw = 1;
0596 weightbutton_Callback(hObject, eventdata, handles);
0597 end
0598 end
0599
0600
0601
0602 if isfield(handles,'plot')
0603 plotmenu_Callback(hObject, eventdata, handles);
0604 end
0605
0606
0607
0608 if isfield(handles,'stats')
0609 statsbutton_Callback(hObject, eventdata, handles);
0610 end
0611
0612
0613 function foldmenu_CreateFcn(hObject, eventdata, handles)
0614
0615
0616
0617
0618
0619
0620 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0621 set(hObject,'BackgroundColor','white');
0622 end
0623
0624
0625
0626 function plotmenu_Callback(hObject, eventdata, handles)
0627
0628
0629
0630
0631
0632
0633
0634 plotm = get(handles.plotmenu,'Value');
0635 plotchosen = num2str(plotm);
0636 fold = get(handles.foldmenu,'Value');
0637 model = get(handles.classmenu,'Value');
0638 mi = handles.mi;
0639 model = mi(model);
0640 PRT = handles.PRT;
0641 handles.plot = 1;
0642 nms = 7;
0643 isyc1 = 0;
0644 isyc2 = 0;
0645 c1 = 0;
0646 c2 = 0;
0647 rotate3d off
0648
0649 if strcmp(PRT.model(model).input.type,'classification')
0650
0651
0652
0653
0654
0655
0656
0657 if (~isfield(handles.PRT.model(model).input,'use_nested_cv') || ...
0658 ~handles.PRT.model(model).input.use_nested_cv) && plotchosen == '4'
0659 plotchosen = '1';
0660 end
0661
0662
0663
0664 switch plotchosen
0665
0666
0667
0668
0669 case '1'
0670 prt_plot_histograms(handles.PRT, model, fold, handles.axes5);
0671
0672
0673
0674 case '2'
0675 prt_plot_confusion_matrix(handles.PRT, model, fold, handles.axes5);
0676
0677
0678
0679 case '3'
0680 prt_plot_prediction(handles.PRT, model, fold, nms, handles.axes5);
0681
0682
0683
0684 case '4'
0685 prt_plot_ROC(handles.PRT, model, fold, handles.axes5);
0686
0687
0688
0689 case '5'
0690 prt_plot_nested_cv(handles.PRT, model, fold, handles.axes5);
0691
0692 end
0693
0694 else
0695
0696
0697
0698 switch plotchosen
0699 case '1'
0700 prt_plot_prediction_reg_scatter(handles.PRT, model, handles.axes5);
0701
0702 case '2'
0703 prt_plot_prediction_reg_bar(handles.PRT, model, handles.axes5);
0704
0705 case '3'
0706 prt_plot_prediction_reg_line(handles.PRT, model, handles.axes5);
0707
0708
0709
0710 case '4'
0711 prt_plot_nested_cv(handles.PRT, model, fold, handles.axes5);
0712
0713 end
0714 end
0715
0716 guidata(hObject, handles);
0717
0718
0719
0720 function plotmenu_CreateFcn(hObject, eventdata, handles)
0721
0722
0723
0724
0725
0726
0727 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0728 set(hObject,'BackgroundColor','white');
0729 end
0730
0731
0732
0733 function classmenu_Callback(hObject, eventdata, handles)
0734
0735
0736
0737
0738
0739
0740
0741
0742
0743
0744
0745 m = get(handles.classmenu,'Value');
0746 mi = handles.mi;
0747 if length(handles.PRT.model(mi(m)).output)>1
0748 beep
0749 disp('Cannot display results per kernel in results window')
0750 return
0751 end
0752 handles.nfold = length(handles.PRT.model(mi(m)).output.fold);
0753
0754
0755 folds{1} = 'All folds / Average';
0756 for f = 1:handles.nfold
0757 folds{f+1} = num2str(f);
0758 end
0759
0760
0761 if strcmp(handles.PRT.model(mi(m)).input.type,'classification');
0762 if length(handles.PRT.model(mi(m)).output(1).stats.c_acc) <= 2 ;
0763 plots = {'Histogram','Confusion Matrix','Predictions','ROC'};
0764 else
0765 plots = {'Histogram', 'Confusion Matrix'};
0766 end
0767 else
0768 plots = {'Predictions (scatter)', 'Predictions (bar)', 'Predictions (line)'};
0769 end
0770 if isfield(handles.PRT.model(mi(m)).input,'use_nested_cv')
0771 if handles.PRT.model(mi(m)).input.use_nested_cv
0772 plots{length(plots)+1} = 'Influence of the hyper-parameter on performance';
0773 end
0774 end
0775
0776 set(handles.plotmenu,'String',plots);
0777
0778
0779 handles.folds = folds;
0780 set(handles.foldmenu,'String',handles.folds);
0781 handles.model_button = 1;
0782
0783 foldmenu_Callback(hObject, eventdata, handles);
0784
0785
0786 if isfield(handles, 'stats')
0787 statsbutton_Callback(hObject, eventdata, handles);
0788 end
0789
0790 handles.model_button = 0;
0791 guidata(hObject, handles);
0792
0793
0794
0795 function classmenu_CreateFcn(hObject, eventdata, handles)
0796
0797
0798
0799
0800
0801
0802 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0803 set(hObject,'BackgroundColor','white');
0804 end
0805
0806
0807 function repedit_Callback(hObject, eventdata, handles)
0808
0809
0810
0811
0812
0813
0814
0815
0816
0817 function repedit_CreateFcn(hObject, eventdata, handles)
0818
0819
0820
0821
0822
0823
0824 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0825 set(hObject,'BackgroundColor','white');
0826 end
0827
0828
0829
0830 function permutbutton_Callback(hObject, eventdata, handles)
0831
0832
0833
0834
0835 m = get(handles.classmenu,'Value');
0836 mi = handles.mi;
0837 reps = str2num(get(handles.repedit,'String'));
0838 if ~isempty(reps)
0839 if length(reps) ==1
0840 reps = round(reps);
0841 disp('Performing permutation test.........>>')
0842 prt_permutation(handles.PRT, reps, mi(m), handles.pathdir,...
0843 handles.save_weights);
0844
0845 PRTmat = fullfile(handles.pathdir,'PRT.mat');
0846 load(PRTmat);
0847 perm = PRT.model(mi(m)).output.stats.permutation;
0848 stats.perm = perm;
0849 stats.show_perm = 1;
0850 if strcmp(handles.PRT.model(mi(m)).input.type,'classification');
0851 stats.type = 'class';
0852 else
0853 stats.type = 'reg';
0854 end
0855 handles.stats = stats;
0856 handles.PRT = PRT;
0857
0858
0859 guidata(hObject, handles);
0860
0861
0862 statsbutton_Callback(hObject, eventdata, handles);
0863 else
0864 beep;
0865 disp('Please enter only one value for the number of repetitions!');
0866 end
0867 else
0868 beep;
0869 disp('Repetitions should be a number!');
0870 end
0871
0872
0873 function save_perm_weights_Callback(hObject, eventdata, handles)
0874
0875
0876
0877
0878
0879
0880 flag=get(handles.save_perm_weights,'Value');
0881 if flag
0882 handles.save_weights=1;
0883 else
0884 handles.save_weights=0;
0885 end
0886 guidata(hObject, handles);
0887
0888
0889
0890 function statsbutton_Callback(hObject, eventdata, handles)
0891
0892
0893
0894
0895
0896
0897 fold = get(handles.foldmenu,'Value');
0898 mi = handles.mi;
0899 m = get(handles.classmenu,'Value');
0900 PRT = handles.PRT;
0901
0902
0903
0904 if isfield(handles, 'stats')
0905 stats = handles.stats;
0906 end
0907
0908
0909
0910 if strcmp(PRT.model(mi(m)).input.type,'classification')
0911 if fold == 1
0912 macc = PRT.model(mi(m)).output.stats.acc;
0913 mbacc = PRT.model(mi(m)).output.stats.b_acc;
0914 mcacc = PRT.model(mi(m)).output.stats.c_acc;
0915 mcpv = PRT.model(mi(m)).output.stats.c_pv;
0916 if isfield(PRT.model(mi(m)).output.stats,'permutation') && ...
0917 ~isempty(PRT.model(mi(m)).output.stats.permutation)
0918 stats.show_perm=1;
0919 stats.perm.pvalue_b_acc=PRT.model(mi(m)).output.stats.permutation.pvalue_b_acc;
0920 stats.perm.pvalue_c_acc=PRT.model(mi(m)).output.stats.permutation.pvalue_c_acc;
0921 end
0922 else
0923 macc = PRT.model(mi(m)).output.fold(fold-1).stats.acc;
0924 mbacc = PRT.model(mi(m)).output.fold(fold-1).stats.b_acc;
0925 mcacc = PRT.model(mi(m)).output.fold(fold-1).stats.c_acc;
0926 mcpv = PRT.model(mi(m)).output.fold(fold-1).stats.c_pv;
0927 end
0928
0929 stats.macc = macc;
0930 stats.mbacc = mbacc;
0931 stats.mcacc = mcacc;
0932 stats.mcpv = mcpv;
0933 stats.type = 'class';
0934
0935 prt_ui_stats(stats,handles.prtdir);
0936
0937 else
0938 if fold == 1
0939 corr = PRT.model(mi(m)).output.stats.corr;
0940 if isfield(PRT.model(mi(m)).output.stats,'r2')
0941 r2 = PRT.model(mi(m)).output.stats.r2;
0942 end
0943 mse = PRT.model(mi(m)).output.stats.mse;
0944 if isfield(PRT.model(mi(m)).output.stats,'nmse')
0945 nmse = PRT.model(mi(m)).output.stats.nmse;
0946 end
0947 if isfield(PRT.model(mi(m)).output.stats,'permutation') && ...
0948 ~isempty(PRT.model(mi(m)).output.stats.permutation)
0949 stats.show_perm=1;
0950 stats.perm.pval_corr = PRT.model(mi(m)).output.stats.permutation.pval_corr;
0951 stats.perm.pval_mse = PRT.model(mi(m)).output.stats.permutation.pval_mse;
0952
0953 if isfield(PRT.model(mi(m)).output.stats.permutation, 'pval_r2'),...
0954 stats.perm.pval_r2 = PRT.model(mi(m)).output.stats.permutation.pval_r2; end
0955 if isfield(PRT.model(mi(m)).output.stats.permutation, 'pval_nmse'),...
0956 stats.perm.pval_nmse = PRT.model(mi(m)).output.stats.permutation.pval_nmse; end
0957
0958 end
0959 else
0960 corr = PRT.model(mi(m)).output.fold(fold-1).stats.corr;
0961 if isfield(PRT.model(mi(m)).output.stats,'r2')
0962 r2 = PRT.model(mi(m)).output.fold(fold-1).stats.r2;
0963 end
0964 mse = PRT.model(mi(m)).output.fold(fold-1).stats.mse;
0965 if isfield(PRT.model(mi(m)).output.stats,'nmse')
0966 nmse = PRT.model(mi(m)).output.fold(fold-1).stats.nmse;
0967 end
0968 end
0969
0970 stats.corr = corr;
0971 if isfield(PRT.model(mi(m)).output.stats,'r2'), stats.r2 = r2; end
0972 stats.mse = mse;
0973 if isfield(PRT.model(mi(m)).output.stats,'nmse'), stats.nmse = nmse; end
0974 stats.type = 'reg';
0975
0976 prt_ui_stats(stats,handles.prtdir);
0977
0978 end
0979
0980 stats.show_perm = 0;
0981 handles.stats = stats;
0982 guidata(hObject, handles);
0983
0984
0985
0986 function showpos()
0987
0988 global st
0989
0990 mp13 = st.handles.mmedit;
0991 mp14 = st.handles.vxedit;
0992 tx20 = st.handles.posintensitytext;
0993
0994 set(mp13,'String',sprintf('%.1f %.1f %.1f',spm_orthviews('Pos')));
0995 pos = spm_orthviews('Pos',1);
0996 set(mp14,'String',sprintf('%.1f %.1f %.1f',pos));
0997 set(tx20,'String',sprintf('%g',spm_sample_vol(st.V,pos(1),pos(2),pos(3),st.hld)));
0998
0999 cmap = get(gcf,'Colormap');
1000 if size(cmap,1)~=128
1001 spm_figure('Colormap','gray-jet');
1002 end
1003
1004
1005
1006 function resetbutton_Callback(hObject, eventdata, handles)
1007
1008
1009
1010 spm_orthviews('Reset');
1011 if isfield(handles, 'wmap'), handles = rmfield(handles, 'wmap'); end
1012 if isfield(handles, 'aimg'), handles = rmfield(handles,'aimg'); end
1013 handles.noloadw = 0;
1014 guidata(hObject, handles);
1015
1016
1017
1018 function savemenu_Callback(hObject, eventdata, handles)
1019
1020
1021
1022 wd=cd;
1023 cd(handles.prtdir)
1024 [filename, pathname] = uiputfile( ...
1025 {'*.png','Portable Network Graphics (*.png)';...
1026 '*.jpeg','JPEG figure (*.jpeg)';...
1027 '*.tiff','Compressed TIFF figure (*.tiff)';...
1028 '*.fig','Matlab figure (*.fig)';...
1029 '*.pdf','Color PDF file (*.pdf)';...
1030 '*.epsc', 'Encapsulated PostScript (*.eps)'},...
1031 'Save figure as','.png');
1032 [a,b,c]=fileparts(filename);
1033 ext=['-d',c(2:end)];
1034
1035
1036 cf=get(handles.figure1,'Color');
1037 set(handles.figure1,'Color',[1,1,1])
1038 aa=get(handles.figure1,'children');
1039 xc=[];
1040 for i=1:length(aa)
1041 if strcmpi(get(aa(i),'type'),'uipanel')
1042 try
1043 xc=[xc;get(aa(i),'BackgroundColor')];
1044 set(aa(i),'BackgroundColor',[1 1 1])
1045 end
1046 bb=get(aa(i),'children');
1047 if ~isempty(bb)
1048 for j=1:length(bb)
1049 try
1050 xc=[xc;get(bb(j),'BackgroundColor')];
1051 set(bb(j),'BackgroundColor',[1 1 1])
1052 end
1053 if strcmpi(get(bb(j),'type'),'uipanel')
1054 cc=get(bb(j),'children');
1055 if ~isempty(cc)
1056 for k=1:length(cc)
1057 try
1058 xc=[xc;get(cc(k),'BackgroundColor')];
1059 set(cc(k),'BackgroundColor',[1 1 1])
1060 end
1061 if strcmpi(get(cc(k),'type'),'uipanel')
1062 dd=get(cc(k),'children');
1063 if ~isempty(dd)
1064 for l=1:length(dd)
1065 try
1066 xc=[xc;get(dd(l),'BackgroundColor')];
1067 set(dd(l),'BackgroundColor',[1 1 1])
1068 end
1069 end
1070 end
1071 end
1072 end
1073 end
1074 end
1075 end
1076 end
1077 end
1078 if ~strcmpi(get(aa(i),'type'),'uimenu')
1079 try
1080 xc=[xc;get(aa(i),'BackgroundColor')];
1081 set(aa(i),'BackgroundColor',[1 1 1])
1082 end
1083 end
1084 end
1085
1086 if ~strcmp(ext, '-dfig')
1087 print(handles.figure1,ext,[pathname,filesep,b],'-r500')
1088 else
1089 saveas(handles.figure1,[pathname,filesep,b],'fig')
1090 end
1091
1092
1093
1094 set(handles.figure1,'Color',cf)
1095 scount=1;
1096 for i=1:length(aa)
1097 if strcmpi(get(aa(i),'type'),'uipanel')
1098 try
1099 set(aa(i),'BackgroundColor',xc(scount,:))
1100 scount=scount+1;
1101 end
1102 bb=get(aa(i),'children');
1103 if ~isempty(bb)
1104 for j=1:length(bb)
1105 try
1106 set(bb(j),'BackgroundColor',xc(scount,:))
1107 scount=scount+1;
1108 end
1109 if strcmpi(get(bb(j),'type'),'uipanel')
1110 cc=get(bb(j),'children');
1111 if ~isempty(cc)
1112 for k=1:length(cc)
1113 try
1114 set(cc(k),'BackgroundColor',xc(scount,:))
1115 scount=scount+1;
1116 end
1117 if strcmpi(get(cc(k),'type'),'uipanel')
1118 dd=get(cc(k),'children');
1119 if ~isempty(dd)
1120 for l=1:length(dd)
1121 try
1122 set(dd(l),'BackgroundColor',xc(scount,:))
1123 scount=scount+1;
1124 end
1125 end
1126 end
1127 end
1128 end
1129 end
1130 end
1131 end
1132 end
1133 elseif ~strcmpi(get(aa(i),'type'),'uimenu')
1134 try
1135 set(aa(i),'BackgroundColor',xc(scount,:))
1136 scount=scount+1;
1137 end
1138 end
1139 end
1140
1141 cd(wd)