Home > . > prt_ui_results.m

prt_ui_results

PURPOSE ^

PRT_UI_RESULTS MATLAB code for prt_ui_results.fig

SYNOPSIS ^

function varargout = prt_ui_results(varargin)

DESCRIPTION ^

 PRT_UI_RESULTS MATLAB code for prt_ui_results.fig
 
 PRT_UI_RESULTS, by itself, creates a new PRT_UI_RESULTS or raises the 
 existing singleton*.

 H = PRT_UI_RESULTS returns the handle to a new PRT_UI_RESULTS or the 
 handle to the existing singleton*.

 PRT_UI_RESULTS('CALLBACK',hObject,eventData,handles,...) calls the local
 function named CALLBACK in PRT_UI_RESULTS.M with the given input arguments.

 PRT_UI_RESULTS('Property','Value',...) creates a new PRT_UI_RESULTS or 
 raises the existing singleton*.  Starting from the left, property value 
 pairs are applied to the GUI before prt_ui_results_OpeningFcn gets called.
 An unrecognized property name or invalid value makes property application
 stop.  All inputs are passed to prt_ui_results_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
__________________________________________________________________________
 Copyright (C) 2011 Machine Learning & Neuroimaging Laboratory

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varargout = prt_ui_results(varargin)
0002 % PRT_UI_RESULTS MATLAB code for prt_ui_results.fig
0003 %
0004 % PRT_UI_RESULTS, by itself, creates a new PRT_UI_RESULTS or raises the
0005 % existing singleton*.
0006 %
0007 % H = PRT_UI_RESULTS returns the handle to a new PRT_UI_RESULTS or the
0008 % handle to the existing singleton*.
0009 %
0010 % PRT_UI_RESULTS('CALLBACK',hObject,eventData,handles,...) calls the local
0011 % function named CALLBACK in PRT_UI_RESULTS.M with the given input arguments.
0012 %
0013 % PRT_UI_RESULTS('Property','Value',...) creates a new PRT_UI_RESULTS or
0014 % raises the existing singleton*.  Starting from the left, property value
0015 % pairs are applied to the GUI before prt_ui_results_OpeningFcn gets called.
0016 % An unrecognized property name or invalid value makes property application
0017 % stop.  All inputs are passed to prt_ui_results_OpeningFcn via varargin.
0018 %
0019 % *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
0020 % instance to run (singleton)".
0021 %
0022 % See also: GUIDE, GUIDATA, GUIHANDLES
0023 %__________________________________________________________________________
0024 % Copyright (C) 2011 Machine Learning & Neuroimaging Laboratory
0025 
0026 % Written by M. J. Rosa
0027 % $Id: prt_ui_results.m 570 2012-08-13 23:17:50Z mjrosa $
0028 
0029 % Edit the above text to modify the response to help prt_ui_results
0030 
0031 % Last Modified by GUIDE v2.5 08-Apr-2012 10:35:42
0032 
0033 % Begin initialization code - DO NOT EDIT
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 % End initialization code - DO NOT EDIT
0051 
0052 
0053 % --- Executes just before prt_ui_results is made visible.
0054 function prt_ui_results_OpeningFcn(hObject, eventdata, handles, varargin)
0055 % This function has no output args, see OutputFcn.
0056 % hObject    handle to figure
0057 % eventdata  reserved - to be defined in a future version of MATLAB
0058 % handles    structure with handles and user data (see GUIDATA)
0059 % varargin   command line arguments to prt_ui_results (see VARARGIN)
0060 
0061 %if window already exists, just put it as the current figure
0062 Tag='Results';
0063 F = findall(allchild(0),'Flat','Tag',Tag);
0064 if length(F) > 1
0065     % Multiple Graphics windows - close all but most recent
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 %set size of the window, taking screen resolution and platform into account
0077 %--------------------------------------------------------------------------
0078 S0= spm('WinSize','0',1);   %-Screen size (of the current monitor)
0079 if ispc
0080     PF='MS Sans Serif';
0081 else
0082     PF= spm_platform('fonts');     %-Font names (for this platform)
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);  %factor to scale the fonts
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                         if ispc
0139                             set(cc(k),'FontSize',ceil(FS*xf),'FontName',PF,...
0140                                 'FontUnits','normalized','Units','normalized')
0141                         else
0142                             set(cc(k),'FontSize',ceil(FS*xf),'FontName',PF,...
0143                                 'Units','normalized')
0144                         end
0145                     end
0146                 elseif strcmpi(get(bb(j),'type'),'uicontrol') && ...
0147                         ~isempty(find(strcmpi(get(bb(j),'Style'),{'text',...
0148                         'radiobutton','checkbox'})))
0149                     set(bb(j),'BackgroundColor',color.bg2)
0150                 elseif strcmpi(get(bb(j),'type'),'uicontrol') && ...
0151                         ~isempty(find(strcmpi(get(bb(j),'Style'),'pushbutton')))
0152                     set(bb(j),'BackgroundColor',color.fr)
0153                 end
0154                 set(bb(j),'FontUnits','pixel')
0155                 xf=get(bb(j),'FontSize');
0156                 if ispc
0157                     set(bb(j),'FontSize',ceil(FS*xf),'FontName',PF,...
0158                         'FontUnits','normalized','Units','normalized')
0159                 else
0160                     set(bb(j),'FontSize',ceil(FS*xf),'FontName',PF,...
0161                         'Units','normalized')
0162                 end
0163             end
0164         end
0165     elseif strcmpi(get(aa(i),'type'),'uicontrol')
0166         if ~isempty(find(strcmpi(get(aa(i),'Style'),{'text',...
0167                 'radiobutton','checkbox'})))
0168             set(aa(i),'BackgroundColor',color.bg1)
0169         elseif ~isempty(find(strcmpi(get(aa(i),'Style'),'pushbutton')))
0170             set(aa(i),'BackgroundColor',color.fr)
0171         end
0172     end
0173     if ~strcmpi(get(aa(i),'type'),'uimenu')
0174         set(aa(i),'FontUnits','pixel')
0175         xf=get(aa(i),'FontSize');
0176         if ispc
0177             set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0178                 'FontUnits','normalized','Units','normalized')
0179         else
0180             set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0181                 'Units','normalized')
0182         end
0183     end
0184 end
0185 
0186 
0187 % Initialize window
0188 % -------------------------------------------------------------------------
0189 if ~isfield(handles,'notinit')
0190     
0191     % Load PRT.mat
0192     PRT     = spm_select(1,'mat','Select PRT.mat',[],pwd,'PRT.mat');
0193     pathdir = regexprep(PRT,'PRT.mat', '');
0194     handles.pathdir = pathdir;
0195     handles.prtdir=fileparts(PRT);
0196     load(PRT);
0197     
0198     % Save PRT
0199     handles.PRT = PRT;
0200     
0201     % Flag to load new weights
0202     handles.noloadw = 0;
0203     
0204     % Load model names
0205     if ~isfield(PRT,'model')
0206         beep
0207         disp('No models found in PRT.mat!')
0208         delete(handles.figure1)
0209         return
0210     end
0211     nmodels = length(PRT.model);
0212     mi  = [];
0213     nmi = 0;
0214     for m = 1:nmodels
0215         if isfield(PRT.model(m),'input') && ~isempty(PRT.model(m).input)
0216             if isfield(PRT.model(m),'output') && ~isempty(PRT.model(m).output)
0217                 nmi = nmi +1;
0218                 model_name{nmi} = PRT.model(m).model_name;
0219                 mi = [mi, m];
0220             else
0221                 beep;
0222                 disp(sprintf('Model %s not estimated! It will not be displayed',PRT.model(m).model_name));
0223             end
0224         else
0225             beep;
0226             disp(sprintf('Model %s not properly specified! It will not be displayed',PRT.model(m).model_name));
0227         end
0228         
0229     end
0230     if ~nmi, error('There are no estimated/good models in this PRT!'); end
0231     
0232     handles.mi = mi;
0233     
0234     % Set model pulldown menu
0235     handles.mnames = model_name;
0236     set(handles.classmenu,'String',handles.mnames);
0237     
0238     % Get folds pulldown menu
0239     m             = get(handles.classmenu,'Value');
0240     handles.nfold = length(PRT.model(mi(m)).output.fold);
0241     folds{1}      = 'All folds / Average';
0242     for f = 1:handles.nfold
0243         folds{f+1} = num2str(f);
0244     end
0245     handles.folds = folds;
0246     set(handles.foldmenu,'String',handles.folds);
0247     
0248     % Set plots menu for first model
0249     if strcmp(PRT.model(mi(m)).input.type,'classification');
0250         if length(PRT.model(mi(m)).output.stats.c_acc) <= 2 ;
0251             plots = {'Predictions','ROC','Histogram','Confusion Matrix'};
0252         else
0253             plots = {'Confusion Matrix'};
0254         end
0255     else
0256         plots = {'Predictions (scatter)', 'Predictions (bar)'};
0257     end
0258     set(handles.plotmenu,'String',plots); 
0259     
0260     % Initialize model utton
0261     handles.model_button = 0;
0262     
0263     % Clear axes
0264     cla(handles.axes5);     
0265 end
0266 end
0267 
0268 % Choose default command line output for prt_ui_results
0269 handles.output = hObject;
0270 
0271 % Update handles structure
0272 guidata(hObject, handles);
0273 
0274 % UIWAIT makes prt_ui_results wait for user response (see UIRESUME)
0275 % uiwait(handles.figure1);
0276 
0277 
0278 % --- Outputs from this function are returned to the command line.
0279 function varargout = prt_ui_results_OutputFcn(hObject, eventdata, handles) 
0280 % varargout  cell array for returning output args (see VARARGOUT);
0281 % hObject    handle to figure
0282 % eventdata  reserved - to be defined in a future version of MATLAB
0283 % handles    structure with handles and user data (see GUIDATA)
0284 
0285 % Get default command line output from handles structure
0286 varargout{1} = handles.output;
0287 
0288 
0289 % --- Executes on button press in originbutton.
0290 function originbutton_Callback(hObject, eventdata, handles)
0291 % hObject    handle to originbutton (see GCBO)
0292 % eventdata  reserved - to be defined in a future version of MATLAB
0293 % handles    structure with handles and user data (see GUIDATA)
0294 
0295 % Reset the crosshairs position
0296 % -------------------------------------------------------------------------
0297 if isfield(handles,'img')
0298     spm_orthviews('Reposition',[0 0 0]);
0299 end
0300 
0301 function mmedit_Callback(hObject, eventdata, handles)
0302 % hObject    handle to mmedit (see GCBO)
0303 % eventdata  reserved - to be defined in a future version of MATLAB
0304 % handles    structure with handles and user data (see GUIDATA)
0305 
0306 % Hints: get(hObject,'String') returns contents of mmedit as text
0307 %        str2double(get(hObject,'String')) returns contents of mmedit as a double
0308 
0309 % Move crosshairs position in mm
0310 % -------------------------------------------------------------------------
0311 if isfield(handles,'img')
0312     mp    = handles.mmedit;
0313     posmm = get(mp,'String');
0314     pos = sscanf(posmm, '%g %g %g');
0315     if length(pos)~=3
0316         pos = spm_orthviews('Pos');
0317     end
0318     spm_orthviews('Reposition',pos);
0319 end
0320 
0321 % --- Executes during object creation, after setting all properties.
0322 function mmedit_CreateFcn(hObject, eventdata, handles)
0323 % hObject    handle to mmedit (see GCBO)
0324 % eventdata  reserved - to be defined in a future version of MATLAB
0325 % handles    empty - handles not created until after all CreateFcns called
0326 
0327 % Hint: edit controls usually have a white background on Windows.
0328 %       See ISPC and COMPUTER.
0329 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0330     set(hObject,'BackgroundColor','white');
0331 end
0332 
0333 
0334 function vxedit_Callback(hObject, eventdata, handles)
0335 % hObject    handle to vxedit (see GCBO)
0336 % eventdata  reserved - to be defined in a future version of MATLAB
0337 % handles    structure with handles and user data (see GUIDATA)
0338 
0339 % Hints: get(hObject,'String') returns contents of vxedit as text
0340 %        str2double(get(hObject,'String')) returns contents of vxedit as a double
0341 
0342 % Move crosshairs position in vx
0343 % -------------------------------------------------------------------------
0344 if isfield(handles,'img')
0345     mp    = handles.vxedit;
0346     posvx = get(mp,'String');
0347     pos   = sscanf(posvx, '%g %g %g');
0348     if length(pos)~=3
0349         pos = spm_orthviews('pos',1);
0350     end
0351     tmp = handles.vols{1}.mat;
0352     pos = tmp(1:3,:)*[pos ; 1];
0353     spm_orthviews('Reposition',pos);
0354 end
0355 
0356 
0357 % --- Executes during object creation, after setting all properties.
0358 function vxedit_CreateFcn(hObject, eventdata, handles)
0359 % hObject    handle to vxedit (see GCBO)
0360 % eventdata  reserved - to be defined in a future version of MATLAB
0361 % handles    empty - handles not created until after all CreateFcns called
0362 
0363 % Hint: edit controls usually have a white background on Windows.
0364 %       See ISPC and COMPUTER.
0365 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0366     set(hObject,'BackgroundColor','white');
0367 end
0368 
0369 
0370 
0371 % --- Executes on button press in helpbutton.
0372 function helpbutton_Callback(hObject, eventdata, handles)
0373 % hObject    handle to helpbutton (see GCBO)
0374 % eventdata  reserved - to be defined in a future version of MATLAB
0375 % handles    structure with handles and user data (see GUIDATA)
0376 
0377 disp('Help window for PRoNTo results has been launched.')
0378 prt_ui_results_help;
0379 
0380 % --- Executes on button press in quitbutton.
0381 function quitbutton_Callback(hObject, eventdata, handles)
0382 % hObject    handle to quitbutton (see GCBO)
0383 % eventdata  reserved - to be defined in a future version of MATLAB
0384 % handles    structure with handles and user data (see GUIDATA)
0385 
0386 % Close and clear figure
0387 % -------------------------------------------------------------------------
0388 close(handles.figure1);
0389 
0390 
0391 function loadweight_Callback(hObject, eventdata, handles)
0392 % hObject    handle to loadweight (see GCBO)
0393 % eventdata  reserved - to be defined in a future version of MATLAB
0394 % handles    structure with handles and user data (see GUIDATA)
0395 
0396 % Hints: get(hObject,'String') returns contents of loadweight as text
0397 %        str2double(get(hObject,'String')) returns contents of loadweight as a double
0398 
0399 
0400 % --- Executes during object creation, after setting all properties.
0401 function loadweight_CreateFcn(hObject, eventdata, handles)
0402 % hObject    handle to loadweight (see GCBO)
0403 % eventdata  reserved - to be defined in a future version of MATLAB
0404 % handles    empty - handles not created until after all CreateFcns called
0405 
0406 % Hint: edit controls usually have a white background on Windows.
0407 %       See ISPC and COMPUTER.
0408 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0409     set(hObject,'BackgroundColor','white');
0410 end
0411 
0412 
0413 % --- Executes on button press in weightbutton.
0414 function weightbutton_Callback(hObject, eventdata, handles)
0415 % hObject    handle to weightbutton (see GCBO)
0416 % eventdata  reserved - to be defined in a future version of MATLAB
0417 % handles    structure with handles and user data (see GUIDATA)
0418 
0419 disp('Loading weights...>>')
0420 % Select results (.img) for weight map
0421 % -------------------------------------------------------------------------
0422 if ~isfield(handles,'wmap') || ~handles.noloadw
0423     wmap            = spm_select(1,'image','Select weight map.');
0424     % Remove number in file name
0425     if strcmp(wmap(end-1),',')
0426         wmap = wmap(1:end-2);
0427     end
0428     V               = spm_vol(wmap);
0429     handles.vols{1} = V;
0430     handles.wmap    = wmap;
0431    
0432 end
0433 
0434 spm_orthviews('Reset');
0435 if isfield(handles,'aimg')
0436     anatomicalbutton_Callback(hObject, eventdata, handles);
0437 end
0438 
0439 % Image dimensions
0440 % -------------------------------------------------------------------------
0441 fold          = get(handles.foldmenu,'Value')-1;
0442 Vfolds        = handles.vols{1};
0443 V             = Vfolds(1);
0444 M             = V.mat;
0445 DIM           = V.dim(1:3)'; 
0446 xdim          = DIM(1); ydim  = DIM(2); zdim  = DIM(3);
0447 fdim          = V.private.dat.dim(4);
0448 [xords,yords] = ndgrid(1:xdim,1:ydim);
0449 xords         = xords(:)';  yords = yords(:)';
0450 I             = 1:xdim*ydim;
0451 zords_init    = ones(1,xdim*ydim);
0452 
0453 % Get image values above zero for each fold and all folds
0454 % -------------------------------------------------------------------------
0455 xyz_above = [];
0456 z_above   = [];
0457 if fold == 0,
0458     fold_coord = fdim*ones(1,xdim*ydim);
0459     V = Vfolds(fdim);
0460 else
0461     fold_coord = fold*ones(1,xdim*ydim);
0462     V = Vfolds(fold);
0463 end
0464 
0465 for z = 1:zdim,
0466     zords = z*zords_init;
0467     xyz   = [xords(I); yords(I); zords(I); fold_coord];
0468     zvals = spm_get_data(V,xyz);     
0469     above = find(zvals~=0);
0470     if ~isempty(above)
0471         xyz_above = [xyz_above,xyz(:,above)];
0472         z_above   = [z_above,zvals(above)];
0473     end
0474 end
0475 XYZ   = xyz_above(1:3,:);
0476 Z     = z_above;
0477 
0478 % Set spm_orthviews properties
0479 % -------------------------------------------------------------------------
0480 rotate3d off
0481 global st
0482 
0483 handles.notinit = 1;
0484 handles.img     = 1;
0485 
0486 st.handles  = handles;
0487 st.fig      = handles.figure1;
0488 st.V        = V;
0489 st.callback = 'prt_ui_results(''showpos'')';
0490 
0491 % Display maps
0492 % -------------------------------------------------------------------------
0493 h  = spm_orthviews('Image', handles.wmap,[0.0619 0.0859 0.40 0.4196]);
0494 handles.wimgh = h;
0495 spm_orthviews('AddContext', h);
0496 spm_orthviews('MaxBB');
0497 spm_orthviews('AddBlobs', h, XYZ, Z, M);
0498 cmap = get(gcf,'Colormap');
0499 if size(cmap,1)~=128
0500       spm_figure('Colormap','jet');
0501 end
0502 spm_orthviews('Redraw');
0503 
0504 % Show positions
0505 % -------------------------------------------------------------------------
0506 prt_ui_results('showpos');
0507 
0508 disp('Done');
0509 
0510 % Reset flag to load weights
0511 handles.noloadw = 1;
0512 
0513 % Show file name
0514 % -------------------------------------------------------------------------
0515 set(handles.loadweight,'String',handles.wmap);
0516 guidata(hObject, handles);
0517 
0518 function loadanatomical_Callback(hObject, eventdata, handles)
0519 % hObject    handle to loadanatomical (see GCBO)
0520 % eventdata  reserved - to be defined in a future version of MATLAB
0521 % handles    structure with handles and user data (see GUIDATA)
0522 
0523 % Hints: get(hObject,'String') returns contents of loadanatomical as text
0524 %        str2double(get(hObject,'String')) returns contents of loadanatomical as a double
0525 
0526 
0527 % --- Executes during object creation, after setting all properties.
0528 function loadanatomical_CreateFcn(hObject, eventdata, handles)
0529 % hObject    handle to loadanatomical (see GCBO)
0530 % eventdata  reserved - to be defined in a future version of MATLAB
0531 % handles    empty - handles not created until after all CreateFcns called
0532 
0533 % Hint: edit controls usually have a white background on Windows.
0534 %       See ISPC and COMPUTER.
0535 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0536     set(hObject,'BackgroundColor','white');
0537 end
0538 
0539 
0540 % --- Executes on button press in anatomicalbutton.
0541 function anatomicalbutton_Callback(hObject, eventdata, handles)
0542 % hObject    handle to anatomicalbutton (see GCBO)
0543 % eventdata  reserved - to be defined in a future version of MATLAB
0544 % handles    structure with handles and user data (see GUIDATA)
0545 
0546 % Check if weight map and anatomical image exist and reset orthviews
0547 % -------------------------------------------------------------------------
0548 if ~isfield(handles,'wmap')
0549     spm_orthviews('Reset');
0550 end
0551 global st
0552 st.fig = handles.figure1;
0553 if ~isfield(handles,'aimg') || ~handles.noloadi
0554     img    = spm_select(1,'image','Select anatomical image.');
0555 else
0556     img = handles.aimg;
0557 end
0558 
0559 % Show anatomical image
0560 % -------------------------------------------------------------------------
0561 rotate3d off
0562 st.fig = handles.figure1;
0563 handle = spm_orthviews('Image', img, [0.5295 0.0859 0.4196 0.4196]);
0564 cmap   = get(gcf,'Colormap');
0565 if size(cmap,1)~=128
0566       spm_figure('Colormap','gray')
0567 end
0568 
0569 handles.aimgh   = handle;
0570 handles.aimg    = img;
0571 handles.img     = 1;
0572 handles.noloadi = 1;
0573 
0574 % Show file name
0575 % -------------------------------------------------------------------------
0576 set(handles.loadanatomical,'String',handles.aimg);
0577 
0578 guidata(hObject, handles);
0579 
0580 
0581 % --- Executes on selection change in foldmenu.
0582 function foldmenu_Callback(hObject, eventdata, handles)
0583 % hObject    handle to foldmenu (see GCBO)
0584 % eventdata  reserved - to be defined in a future version of MATLAB
0585 % handles    structure with handles and user data (see GUIDATA)
0586 
0587 % Hints: contents = cellstr(get(hObject,'String')) returns foldmenu contents as cell array
0588 %        contents{get(hObject,'Value')} returns selected item from foldmenu
0589 
0590 % Change weight map
0591 % -------------------------------------------------------------------------
0592 if ~handles.model_button
0593     if isfield(handles,'vols')
0594         handles.noloadw = 1;
0595         weightbutton_Callback(hObject, eventdata, handles);
0596     end
0597 end
0598 
0599 % Change plot
0600 % -------------------------------------------------------------------------
0601 if isfield(handles,'plot')
0602    plotmenu_Callback(hObject, eventdata, handles); 
0603 end
0604 
0605 % Change stats
0606 % -------------------------------------------------------------------------
0607 if isfield(handles,'stats')
0608     statsbutton_Callback(hObject, eventdata, handles);
0609 end
0610 
0611 % --- Executes during object creation, after setting all properties.
0612 function foldmenu_CreateFcn(hObject, eventdata, handles)
0613 % hObject    handle to foldmenu (see GCBO)
0614 % eventdata  reserved - to be defined in a future version of MATLAB
0615 % handles    empty - handles not created until after all CreateFcns called
0616 
0617 % Hint: popupmenu controls usually have a white background on Windows.
0618 %       See ISPC and COMPUTER.
0619 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0620     set(hObject,'BackgroundColor','white');
0621 end
0622 
0623 
0624 % --- Executes on selection change in plotmenu.
0625 function plotmenu_Callback(hObject, eventdata, handles)
0626 % hObject    handle to plotmenu (see GCBO)
0627 % eventdata  reserved - to be defined in a future version of MATLAB
0628 % handles    structure with handles and user data (see GUIDATA)
0629 
0630 % Hints: contents = cellstr(get(hObject,'String')) returns plotmenu contents as cell array
0631 %        contents{get(hObject,'Value')} returns selected item from plotmenu
0632 
0633 plotm         = get(handles.plotmenu,'Value');
0634 plotchosen    = num2str(plotm);
0635 fold          = get(handles.foldmenu,'Value');
0636 model         = get(handles.classmenu,'Value');
0637 mi            = handles.mi;
0638 model         = mi(model);
0639 PRT           = handles.PRT;
0640 handles.plot  = 1;
0641 nms           = 7;
0642 isyc1         = 0;
0643 isyc2         = 0;
0644 c1            = 0;
0645 c2            = 0;
0646 rotate3d off
0647 
0648 if strcmp(PRT.model(model).input.type,'classification')
0649     mclass        = length(handles.PRT.model(model).output.stats.c_acc);
0650     if mclass == 2
0651         
0652         % All folds
0653         % -----------------------------------------------------------------
0654         classNames{1} = handles.PRT.model(model).input.class(1).class_name;
0655         classNames{2} = handles.PRT.model(model).input.class(2).class_name;
0656         myColours     = {'k','r'};
0657         
0658     else
0659      
0660         multiplot  = 4;
0661         plotchosen = num2str(multiplot(plotm));
0662         
0663     end
0664     
0665     if fold == 1
0666         fVals   = [];
0667         targets = [];
0668         
0669         for f = 1:handles.nfold,
0670             targets = [targets;handles.PRT.model(model).output.fold(f).targets];
0671             if isfield(handles.PRT.model(model).output.fold(f),'func_val')
0672                 fVvals_exist = 1;
0673                 fVals  = [fVals;handles.PRT.model(model).output.fold(f).func_val];
0674             else
0675                 fVvals_exist = 0;
0676                 fVals  = [fVals;...
0677                     handles.PRT.model(model).output.fold(f).predictions];
0678             end
0679         end
0680         targpos = targets == 1;
0681         
0682     else
0683         % if folds wise
0684         targets = handles.PRT.model(model).output.fold(fold-1).targets;
0685         targpos = targets == 1;
0686         if isfield(handles.PRT.model(model).output.fold(fold-1),'func_val')
0687             fVals  = handles.PRT.model(model).output.fold(fold-1).func_val;
0688             fVvals_exist = 1;
0689         else
0690             fVvals_exist = 0;
0691             fVals  = handles.PRT.model(model).output.fold(fold-1).predictions;
0692         end
0693     end
0694     
0695     % Plot
0696     % ---------------------------------------------------------------------
0697     switch plotchosen
0698         
0699         % Predictions
0700         % -----------------------------------------------------------------
0701         case '1'
0702             cla(handles.axes5);
0703             rotate3d off
0704             colorbar('peer',handles.axes5,'off')
0705             set(handles.axes5,'Color',[1,1,1])
0706             % predictions
0707             if fVvals_exist
0708                 if fold == 1
0709                     foldlabels = 1:handles.nfold;
0710                     for f = 2:handles.nfold+1
0711                         targets = handles.PRT.model(model).output.fold(f-1).targets;
0712                         targpos = targets == 1;
0713                         fVals   = handles.PRT.model(model).output.fold(f-1).func_val;
0714                         func_valsc1 = fVals(targpos);
0715                         func_valsc2 = fVals(~targpos);
0716                         yc1 = (f-1)*ones(length(func_valsc1),1);
0717                         yc2 = (f-1)*ones(length(func_valsc2),1);
0718                         if f==2
0719                             maxfv = max(abs([func_valsc1;func_valsc2]));
0720                         else
0721                             maxtmp = max(abs([func_valsc1;func_valsc2]));
0722                             if maxfv < maxtmp, maxfv = maxtmp; end
0723                         end
0724                         pl1 = plot(handles.axes5,func_valsc1,yc1,'kx','MarkerSize',nms);
0725                         hold(handles.axes5,'on');
0726                         if ~isempty(yc1), isyc1 = 1; plot1 = pl1; end
0727                         pl2 = plot(handles.axes5,func_valsc2,yc2,'ro','MarkerSize',nms);
0728                         hold(handles.axes5,'on');
0729                         if ~isempty(yc2), isyc2 = 1; plot2 = pl2; end
0730                     end
0731                 else
0732                     foldlabels  = fold-1;
0733                     func_valsc1 = fVals(targpos);
0734                     func_valsc2 = fVals(~targpos);
0735                     yc1 = (fold-1)*ones(length(func_valsc1),1);
0736                     yc2 = (fold-1)*ones(length(func_valsc2),1);
0737                     maxfv = max(abs([func_valsc1;func_valsc2]));
0738                     pl1 = plot(handles.axes5,func_valsc1,yc1,'kx','MarkerSize',nms);
0739                     hold(handles.axes5,'on');
0740                     if ~isempty(yc1), isyc1 = 1; plot1 = pl1; end
0741                     pl2 = plot(handles.axes5,func_valsc2,yc2,'ro','MarkerSize',nms);
0742                     hold(handles.axes5,'on');
0743                     if ~isempty(yc2), isyc2 = 1; plot2 = pl2; end
0744                 end
0745                 % Change the x axis for gaussian process - change in
0746                 % the future
0747                 y = [0:handles.nfold+1]';
0748                 if strcmp(PRT.model(model).input.machine.function,'prt_machine_gpml');
0749                     x = 0.5*ones(handles.nfold+2,1);
0750                     plot(handles.axes5,x,y,'--','Color',[1 1 1]*.6);
0751                     xlim(handles.axes5,[0 1]);
0752                 else
0753                     x = zeros(handles.nfold+2,1);
0754                     plot(handles.axes5,x,y,'--','Color',[1 1 1]*.6);
0755                     xlim(handles.axes5,[-maxfv-0.5 maxfv+0.5]);
0756                 end
0757                 ylim(handles.axes5,[0 handles.nfold+1.3]);
0758                 xlabel(handles.axes5,'function value','FontWeight','bold');
0759                 h=ylabel(handles.axes5,'fold','FontWeight','bold');
0760                 set(h,'Rotation',90)
0761                 if isyc1 && isyc2
0762                     legend([plot1,plot2],classNames,'Color',[1,1,1]);
0763                 else
0764                     if isyc1
0765                         legend(plot1,classNames{1},'Color',[1,1,1]);
0766                     else
0767                         legend(plot2,classNames{2},'Color',[1,1,1]);
0768                     end
0769                 end
0770                 set(handles.axes5,'YTick',foldlabels)
0771                 hold(handles.axes5,'off');
0772                 set(handles.axes5,'Color',[1,1,1],'Visible','on')
0773 %                 axis normal
0774 %                 axis xy
0775                 title(handles.axes5,'')
0776             else
0777                 set(handles.axes5,'Color',[1,1,1])
0778                 beep
0779                 disp('No function values to display!')
0780             end
0781             
0782             % ROC / AUC
0783             % -------------------------------------------------------------
0784         case '2'
0785             % ROC curve
0786                 rotate3d off
0787                 cla(handles.axes5);
0788                 [y,idx] = sort(fVals);
0789                 targpos = targpos(idx);
0790                 
0791                 fp      = cumsum(single(targpos))/sum(single(targpos));
0792                 tp      = cumsum(single(~targpos))/sum(single(~targpos));
0793                 
0794                 tp      = [0 ; tp ; 1];
0795                 fp      = [0 ; fp ; 1];
0796                 
0797                 n       = size(tp, 1);
0798                 A       = sum((fp(2:n) - fp(1:n-1)).*(tp(2:n)+tp(1:n-1)))/2;
0799 %
0800 %                 axis xy
0801                 plot(handles.axes5,fp,tp,'--ks','LineWidth',1, 'MarkerEdgeColor','k',...
0802                     'MarkerFaceColor','k',...
0803                     'MarkerSize',2);
0804                 title(handles.axes5,sprintf('Receiver Operator Curve / Area Under Curve = %3.2f',A));
0805                 xlabel(handles.axes5,'False positives','FontWeight','bold')
0806                 ylabel(handles.axes5,'True positives','FontWeight','bold')
0807                 set(handles.axes5,'Color',[1,1,1])
0808                 
0809             
0810             % Histograms
0811             % -------------------------------------------------------------
0812         case '3'
0813                 cla(handles.axes5);
0814                 rotate3d off
0815 %                 axis xy
0816                 set(handles.axes5,'Color',[1,1,1])
0817                 % func_val distributions
0818                 if fVvals_exist
0819                     for cl=1:2
0820                         func_vals = fVals(targpos);
0821                         if cl == 2, func_vals=fVals(~targpos); end
0822                         if ~isempty(func_vals)
0823                             if cl==1, c1 = 1; else c2 = 1; end
0824                             if exist('ksdensity','file')==2
0825                                 [f,x] = ksdensity(func_vals,'width',[]);
0826                                 plot(handles.axes5,x,f,myColours{cl},'LineWidth',2);
0827                                 hold(handles.axes5,'on')
0828                             else
0829                                 % can't plot density, be happy with a histogram
0830                                 [myHist,myX]=hist(func_vals,100);
0831                                 bar(handles.axes5,myX,myHist,myColours{cl});
0832                                 hold(handles.axes5,'on')
0833                             end
0834                             if cl == 2, hold(handles.axes5,'off'); end
0835                         end
0836                     end
0837                     if c1 && c2
0838                     legend(handles.axes5,classNames{1},classNames{2});
0839                     else 
0840                         if c1
0841                             legend(handles.axes5,classNames{1});
0842                         else
0843                             legend(handles.axes5,classNames{2});
0844                         end
0845                     end
0846                       xlabel(handles.axes5,'function value','FontWeight','bold');      
0847                 else
0848                     % do nothing, no func_val available
0849                 end
0850             
0851             % Confusion matrix
0852             % -------------------------------------------------------------
0853         case '4'
0854             % confusion matrix
0855                 cla(handles.axes5);
0856                 if fold == 1
0857                     mconmat(:,:) = PRT.model(model).output.stats.con_mat;
0858                 else
0859                     mconmat(:,:) = PRT.model(model).output.fold(fold-1).stats.con_mat;
0860                 end
0861                 myH=bar3(handles.axes5,mconmat,'detached','w');
0862                 nclass = size(mconmat,1);
0863                 for j = 1:nclass,
0864                     conLabels{j} = num2str(j);
0865                 end
0866                 rotate3d on
0867                 if fold == 1
0868                     title(handles.axes5,sprintf('Confusion matrix: all folds'),'FontWeight','bold');
0869                 else
0870                     title(handles.axes5,sprintf('Confusion matrix: fold %d',fold-1),'FontWeight','bold');
0871                 end
0872                 xlabel(handles.axes5,'True','FontWeight','bold');
0873                 ylabel(handles.axes5,'Predicted','FontWeight','bold');
0874                 set(handles.axes5,'XTick',1:nclass);
0875                 set(handles.axes5,'XTickLabel',conLabels);
0876                 set(handles.axes5,'YTick',1:nclass);
0877                 set(handles.axes5,'YTickLabel',conLabels);
0878                 grid(handles.axes5,'on');
0879                 set(handles.axes5,'Color',[0.8 0.8 0.8]);
0880                 axis square; axis vis3d; axis tight;
0881                 % add values
0882                 for foo_row=1:size(mconmat,1)
0883                     for foo_col=1:size(mconmat,2)
0884                         foo_zval=mconmat(foo_row,foo_col);
0885                         if foo_row==foo_col, foo_color='g'; else foo_color='r';end
0886                         text(foo_col,foo_row,foo_zval,num2str(foo_zval),...
0887                             'Color',foo_color);
0888                     end
0889                 end
0890     end
0891     
0892 else
0893     nfolds = length(PRT.model(model).output.fold);
0894     switch plotchosen
0895         case '1'
0896             cla(handles.axes5);
0897             preds = zeros(nfolds,2);
0898             for f = 1:nfolds
0899                 preds(f,1) = PRT.model(model).output.fold(f).targets;
0900                 preds(f,2) = PRT.model(model).output.fold(f).predictions;
0901                 scatter(handles.axes5,preds(:,2),preds(:,1),'filled');
0902                 xlabel(handles.axes5,'predictions','FontWeight','bold');
0903                 ylabel(handles.axes5,'targets','FontWeight','bold');
0904             end
0905         case '2'
0906             cla(handles.axes5);
0907             preds = zeros(nfolds,2);
0908             for f = 1:nfolds
0909                 preds(f,1) = PRT.model(model).output.fold(f).targets;
0910                 preds(f,2) = PRT.model(model).output.fold(f).predictions;
0911                 bar(handles.axes5,preds);
0912                 xlabel(handles.axes5,'subjects','FontWeight','bold');
0913                 ylabel(handles.axes5,'targets and predictions','FontWeight','bold');
0914             end
0915             legend(handles.axes5,{'Target', 'Predicted'});
0916     end
0917 end
0918 
0919 guidata(hObject, handles);
0920 
0921 
0922 % --- Executes during object creation, after setting all properties.
0923 function plotmenu_CreateFcn(hObject, eventdata, handles)
0924 % hObject    handle to plotmenu (see GCBO)
0925 % eventdata  reserved - to be defined in a future version of MATLAB
0926 % handles    empty - handles not created until after all CreateFcns called
0927 
0928 % Hint: popupmenu controls usually have a white background on Windows.
0929 %       See ISPC and COMPUTER.
0930 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0931     set(hObject,'BackgroundColor','white');
0932 end
0933 
0934 
0935 % --- Executes on selection change in classmenu.
0936 function classmenu_Callback(hObject, eventdata, handles)
0937 % hObject    handle to classmenu (see GCBO)
0938 % eventdata  reserved - to be defined in a future version of MATLAB
0939 % handles    structure with handles and user data (see GUIDATA)
0940 
0941 % Hints: contents = cellstr(get(hObject,'String')) returns classmenu contents as cell array
0942 %        contents{get(hObject,'Value')} returns selected item from classmenu
0943 
0944 % Hints: contents = cellstr(get(hObject,'String')) returns classmenu contents as cell array
0945 %        contents{get(hObject,'Value')} returns selected item from classmenu
0946 
0947 % Get folds
0948 m  = get(handles.classmenu,'Value');
0949 mi = handles.mi;
0950 
0951 handles.nfold = length(handles.PRT.model(mi(m)).output.fold);
0952 folds{1}      = 'All folds / Average';
0953 for f = 1:handles.nfold
0954     folds{f+1} = num2str(f);
0955 end
0956 
0957 % Set plots menu for first model
0958 if strcmp(handles.PRT.model(mi(m)).input.type,'classification');
0959     if length(handles.PRT.model(mi(m)).output.stats.c_acc) <= 2 ;
0960         plots = {'Predictions','ROC','Histogram','Confusion Matrix'};
0961     else
0962         plots = {'Confusion Matrix'};
0963     end
0964 else
0965     plots = {'Predictions (scatter)', 'Predictions (bar)'};
0966 end
0967 set(handles.plotmenu,'String',plots);
0968 
0969 % Set folds and call fold function to change plot/stats
0970 handles.folds = folds;
0971 set(handles.foldmenu,'String',handles.folds);
0972 handles.model_button = 1;
0973 
0974 foldmenu_Callback(hObject, eventdata, handles);
0975 
0976 % Update stats if they are being shown
0977 if isfield(handles, 'stats')
0978    statsbutton_Callback(hObject, eventdata, handles);
0979 end
0980 
0981 handles.model_button = 0;
0982 guidata(hObject, handles);
0983 
0984 
0985 % --- Executes during object creation, after setting all properties.
0986 function classmenu_CreateFcn(hObject, eventdata, handles)
0987 % hObject    handle to classmenu (see GCBO)
0988 % eventdata  reserved - to be defined in a future version of MATLAB
0989 % handles    empty - handles not created until after all CreateFcns called
0990 
0991 % Hint: popupmenu controls usually have a white background on Windows.
0992 %       See ISPC and COMPUTER.
0993 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0994     set(hObject,'BackgroundColor','white');
0995 end
0996 
0997 
0998 function repedit_Callback(hObject, eventdata, handles)
0999 % hObject    handle to repedit (see GCBO)
1000 % eventdata  reserved - to be defined in a future version of MATLAB
1001 % handles    structure with handles and user data (see GUIDATA)
1002 
1003 % Hints: get(hObject,'String') returns contents of repedit as text
1004 %        str2double(get(hObject,'String')) returns contents of repedit as a double
1005 
1006 
1007 % --- Executes during object creation, after setting all properties.
1008 function repedit_CreateFcn(hObject, eventdata, handles)
1009 % hObject    handle to repedit (see GCBO)
1010 % eventdata  reserved - to be defined in a future version of MATLAB
1011 % handles    empty - handles not created until after all CreateFcns called
1012 
1013 % Hint: edit controls usually have a white background on Windows.
1014 %       See ISPC and COMPUTER.
1015 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1016     set(hObject,'BackgroundColor','white');
1017 end
1018 
1019 
1020 % --- Executes on button press in permutbutton.
1021 function permutbutton_Callback(hObject, eventdata, handles)
1022 % hObject    handle to permutbutton (see GCBO)
1023 % eventdata  reserved - to be defined in a future version of MATLAB
1024 % handles    structure with handles and user data (see GUIDATA)
1025 
1026 m    = get(handles.classmenu,'Value');
1027 mi   = handles.mi;
1028 reps = str2num(get(handles.repedit,'String'));
1029 if  ~isempty(reps)
1030     if length(reps) ==1
1031         reps = round(reps);
1032         disp('Performing permutation test.........>>')
1033         prt_permutation(handles.PRT, reps, mi(m), handles.pathdir);
1034         % Load new PRT.mat
1035         PRTmat = fullfile(handles.pathdir,'PRT.mat');
1036         load(PRTmat);
1037         perm     = PRT.model(mi(m)).output.stats.permutation;
1038         stats.perm      = perm;
1039         stats.show_perm = 1;
1040         if strcmp(handles.PRT.model(mi(m)).input.type,'classification');
1041             stats.type = 'class';
1042         else
1043             stats.type = 'reg';
1044         end
1045         handles.stats = stats;
1046         
1047         % Update GUI
1048         guidata(hObject, handles);
1049        
1050         % Call stats button
1051         statsbutton_Callback(hObject, eventdata, handles);
1052     else
1053         beep;
1054         disp('Please enter only one value for the number of repetitions!');
1055     end
1056 else
1057     beep;
1058     disp('Repetitions should be a number!');
1059 end
1060 
1061 % --- Executes on button press in statsbutton.
1062 function statsbutton_Callback(hObject, eventdata, handles)
1063 % hObject    handle to statsbutton (see GCBO)
1064 % eventdata  reserved - to be defined in a future version of MATLAB
1065 % handles    structure with handles and user data (see GUIDATA)
1066 
1067 % Reads model and fold
1068 % -------------------------------------------------------------------------
1069 fold  = get(handles.foldmenu,'Value');
1070 mi    = handles.mi;
1071 m     = get(handles.classmenu,'Value');
1072 PRT   = handles.PRT;
1073 
1074 % Check if stats exist
1075 % -------------------------------------------------------------------------
1076 if isfield(handles, 'stats')
1077     stats = handles.stats;
1078 end
1079 
1080 % Read stats
1081 % -------------------------------------------------------------------------
1082 if strcmp(PRT.model(mi(m)).input.type,'classification')
1083     if fold == 1
1084         macc  = PRT.model(mi(m)).output.stats.acc;  % overall acc
1085         mbacc = PRT.model(mi(m)).output.stats.b_acc;
1086         mcacc = PRT.model(mi(m)).output.stats.c_acc;
1087         mcpv  = PRT.model(mi(m)).output.stats.c_pv;
1088         if isfield(PRT.model(mi(m)).output.stats,'permutation') && ...
1089                 ~isempty(PRT.model(mi(m)).output.stats.permutation)
1090             stats.show_perm=1;
1091             stats.perm.pvalue_b_acc=PRT.model(mi(m)).output.stats.permutation.pvalue_b_acc;
1092             stats.perm.pvalue_c_acc=PRT.model(mi(m)).output.stats.permutation.pvalue_c_acc;
1093         end
1094     else
1095         macc  = PRT.model(mi(m)).output.fold(fold-1).stats.acc;
1096         mbacc = PRT.model(mi(m)).output.fold(fold-1).stats.b_acc;
1097         mcacc = PRT.model(mi(m)).output.fold(fold-1).stats.c_acc;
1098         mcpv  = PRT.model(mi(m)).output.fold(fold-1).stats.c_pv;
1099     end
1100 
1101     stats.macc  = macc;
1102     stats.mbacc = mbacc;
1103     stats.mcacc = mcacc;
1104     stats.mcpv  = mcpv;
1105     stats.type  = 'class';
1106 
1107     prt_ui_stats(stats,handles.prtdir);
1108     
1109 else
1110     if fold == 1
1111         corr  = PRT.model(mi(m)).output.stats.corr;  % overall correlation
1112         mse   = PRT.model(mi(m)).output.stats.mse;  % overall mse
1113         if isfield(PRT.model(mi(m)).output.stats,'permutation') && ...
1114                 ~isempty(PRT.model(mi(m)).output.stats.permutation)
1115             stats.show_perm=1;
1116             stats.perm.pval_corr=PRT.model(mi(m)).output.stats.permutation.pval_corr;
1117             stats.perm.pval_mse=PRT.model(mi(m)).output.stats.permutation.pval_mse;
1118         end
1119     else
1120         corr  = PRT.model(mi(m)).output.fold(fold-1).stats.corr;  % overall correlation
1121         mse   = PRT.model(mi(m)).output.fold(fold-1).stats.mse;  % overall mse
1122     end
1123 
1124     stats.corr = corr;
1125     stats.mse  = mse;
1126     stats.type = 'reg';
1127     
1128     prt_ui_stats(stats,handles.prtdir);
1129     
1130 end
1131     
1132 stats.show_perm = 0;
1133 handles.stats = stats;
1134 guidata(hObject, handles);
1135 
1136 % Show crosshairs position
1137 % -------------------------------------------------------------------------
1138 function showpos()
1139  
1140 global st
1141 
1142 mp13 = st.handles.mmedit;
1143 mp14 = st.handles.vxedit;
1144 tx20 = st.handles.posintensitytext;
1145 
1146 set(mp13,'String',sprintf('%.1f %.1f %.1f',spm_orthviews('Pos')));
1147 pos = spm_orthviews('Pos',1);
1148 set(mp14,'String',sprintf('%.1f %.1f %.1f',pos));
1149 set(tx20,'String',sprintf('%g',spm_sample_vol(st.V,pos(1),pos(2),pos(3),st.hld)));
1150 
1151 cmap = get(gcf,'Colormap');
1152 if size(cmap,1)~=128
1153       spm_figure('Colormap','gray-jet');
1154 end
1155 
1156 
1157 % --- Executes on button press in resetbutton.
1158 function resetbutton_Callback(hObject, eventdata, handles)
1159 % hObject    handle to resetbutton (see GCBO)
1160 % eventdata  reserved - to be defined in a future version of MATLAB
1161 % handles    structure with handles and user data (see GUIDATA)
1162 spm_orthviews('Reset');
1163 if isfield(handles, 'wmap'), handles = rmfield(handles, 'wmap'); end
1164 if isfield(handles, 'aimg'), handles = rmfield(handles,'aimg'); end
1165 handles.noloadw = 0;
1166 guidata(hObject, handles);
1167 
1168 
1169 % Save menu
1170 % -------------------------------------------------------------------------
1171 function savemenu_Callback(hObject, eventdata, handles)
1172 % hObject    handle to savemenu (see GCBO)
1173 % eventdata  reserved - to be defined in a future version of MATLAB
1174 % handles    structure with handles and user data (see GUIDATA)
1175 wd=cd;
1176 cd(handles.prtdir)
1177 [filename, pathname] = uiputfile( ...
1178 {'*.png','Portable Network Graphics (*.png)';...
1179  '*.jpeg','JPEG figure (*.jpeg)';...
1180  '*.tiff','Compressed TIFF figure (*.tiff)';... 
1181  '*.fig','Matlab figure (*.fig)';...
1182  '*.pdf','Color PDF file (*.pdf)';...
1183  '*.epsc',  'Encapsulated PostScript (*.eps)'},...
1184  'Save figure as','.png');
1185 [a,b,c]=fileparts(filename);
1186 ext=['-d',c(2:end)];
1187 
1188 % Set the color of the different backgrounds and figure parameters to white
1189 cf=get(handles.figure1,'Color');
1190 set(handles.figure1,'Color',[1,1,1])
1191 aa=get(handles.figure1,'children');
1192 xc=[];
1193 for i=1:length(aa)
1194     if strcmpi(get(aa(i),'type'),'uipanel')
1195         try
1196             xc=[xc;get(aa(i),'BackgroundColor')];
1197             set(aa(i),'BackgroundColor',[1 1 1])
1198         end
1199         bb=get(aa(i),'children');
1200         if ~isempty(bb)
1201             for j=1:length(bb)
1202                 try
1203                     xc=[xc;get(bb(j),'BackgroundColor')];
1204                     set(bb(j),'BackgroundColor',[1 1 1])
1205                 end
1206                 if strcmpi(get(bb(j),'type'),'uipanel')
1207                     cc=get(bb(j),'children');
1208                     if ~isempty(cc)
1209                         for k=1:length(cc)
1210                             try
1211                                 xc=[xc;get(cc(k),'BackgroundColor')];
1212                                 set(cc(k),'BackgroundColor',[1 1 1])
1213                             end
1214                             if strcmpi(get(cc(k),'type'),'uipanel')
1215                                 dd=get(cc(k),'children');
1216                                 if ~isempty(dd)
1217                                     for l=1:length(dd)
1218                                         try
1219                                             xc=[xc;get(dd(l),'BackgroundColor')];
1220                                             set(dd(l),'BackgroundColor',[1 1 1])
1221                                         end
1222                                     end
1223                                 end
1224                             end
1225                         end
1226                     end
1227                 end
1228             end
1229         end
1230     end
1231     if ~strcmpi(get(aa(i),'type'),'uimenu')
1232         try
1233             xc=[xc;get(aa(i),'BackgroundColor')];
1234             set(aa(i),'BackgroundColor',[1 1 1])
1235         end
1236     end
1237 end
1238 
1239 print(handles.figure1,ext,[pathname,filesep,b],'-r500')
1240 
1241 % Set the color of the different backgrounds and figure parameters to white
1242 set(handles.figure1,'Color',cf)
1243 scount=1;
1244 for i=1:length(aa)
1245     if strcmpi(get(aa(i),'type'),'uipanel')
1246         try
1247             set(aa(i),'BackgroundColor',xc(scount,:))
1248             scount=scount+1;
1249         end
1250         bb=get(aa(i),'children');
1251         if ~isempty(bb)
1252             for j=1:length(bb)
1253                 try
1254                     set(bb(j),'BackgroundColor',xc(scount,:))
1255                     scount=scount+1;
1256                 end
1257                 if strcmpi(get(bb(j),'type'),'uipanel')
1258                     cc=get(bb(j),'children');
1259                     if ~isempty(cc)
1260                         for k=1:length(cc)
1261                             try
1262                                 set(cc(k),'BackgroundColor',xc(scount,:))
1263                                 scount=scount+1;
1264                             end
1265                             if strcmpi(get(cc(k),'type'),'uipanel')
1266                                 dd=get(cc(k),'children');
1267                                 if ~isempty(dd)
1268                                     for l=1:length(dd)
1269                                         try
1270                                             set(dd(l),'BackgroundColor',xc(scount,:))
1271                                             scount=scount+1;
1272                                         end
1273                                     end
1274                                 end
1275                             end
1276                         end
1277                     end
1278                 end
1279             end
1280         end
1281     elseif ~strcmpi(get(aa(i),'type'),'uimenu')
1282         try
1283             set(aa(i),'BackgroundColor',xc(scount,:))
1284             scount=scount+1;
1285         end
1286     end
1287 end
1288 
1289 cd(wd)

Generated on Mon 03-Sep-2012 18:07:18 by m2html © 2005