Home > . > prt_ui_results_stats.m

prt_ui_results_stats

PURPOSE ^

PRT_UI_RESULTS_STATS MATLAB code for prt_ui_results_stats.fig

SYNOPSIS ^

function varargout = prt_ui_results_stats(varargin)

DESCRIPTION ^

 PRT_UI_RESULTS_STATS MATLAB code for prt_ui_results_stats.fig

 PRT_UI_RESULTS_STATS, by itself, creates a new PRT_UI_RESULTS_STATS or raises the
 existing singleton*.

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

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

 PRT_UI_RESULTS_STATS('Property','Value',...) creates a new PRT_UI_RESULTS_STATS or
 raises the existing singleton*.  Starting from the left, property value
 pairs are applied to the GUI before prt_ui_results_stats_OpeningFcn gets called.
 An unrecognized property name or invalid value makes property application
 stop.  All inputs are passed to prt_ui_results_stats_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_stats(varargin)
0002 % PRT_UI_RESULTS_STATS MATLAB code for prt_ui_results_stats.fig
0003 %
0004 % PRT_UI_RESULTS_STATS, by itself, creates a new PRT_UI_RESULTS_STATS or raises the
0005 % existing singleton*.
0006 %
0007 % H = PRT_UI_RESULTS_STATS returns the handle to a new PRT_UI_RESULTS_STATS or the
0008 % handle to the existing singleton*.
0009 %
0010 % PRT_UI_RESULTS_STATS('CALLBACK',hObject,eventData,handles,...) calls the local
0011 % function named CALLBACK in PRT_UI_RESULTS_STATS.M with the given input arguments.
0012 %
0013 % PRT_UI_RESULTS_STATS('Property','Value',...) creates a new PRT_UI_RESULTS_STATS or
0014 % raises the existing singleton*.  Starting from the left, property value
0015 % pairs are applied to the GUI before prt_ui_results_stats_OpeningFcn gets called.
0016 % An unrecognized property name or invalid value makes property application
0017 % stop.  All inputs are passed to prt_ui_results_stats_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: $
0028 
0029 % Edit the above text to modify the response to help prt_ui_results_stats
0030 
0031 % Last Modified by GUIDE v2.5 26-Jan-2015 17:01:29
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_stats_OpeningFcn, ...
0038     'gui_OutputFcn',  @prt_ui_results_stats_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_stats is made visible.
0054 function prt_ui_results_stats_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_stats (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                             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     % Initialize window
0173     % -------------------------------------------------------------------------
0174     
0175     if ~isfield(handles,'notinit')
0176         
0177         % Load PRT.mat
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         % Save PRT
0185         handles.PRT = PRT;
0186         
0187         % Flag to load new weights
0188         handles.noloadw = 0;
0189         
0190         % Load model names
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         % Set model pulldown menu
0218         handles.mnames = model_name;
0219         set(handles.classmenu,'String',handles.mnames);
0220         
0221         % Get folds pulldown menu
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         % Set plots menu for first model
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         % Initialize model button
0249         handles.model_button = 0;
0250         
0251         % Set the 'save permutations' weights' chackbox to 0
0252         handles.save_weights = 0;
0253         set(handles.save_perm_weights,'Value',0);
0254         %         set(handles.save_perm_weights,'Visible','off');
0255         %         set(handles.save_perm_weights,'Enable','off');
0256         
0257         % Clear axes
0258         cla(handles.axes5);
0259     end
0260 end
0261 set(handles.save_perm_weights,'Visible','off')
0262 % Choose default command line output for prt_ui_results_stats
0263 handles.output = hObject;
0264 
0265 % Update handles structure
0266 guidata(hObject, handles);
0267 
0268 % UIWAIT makes prt_ui_results_stats wait for user response (see UIRESUME)
0269 % uiwait(handles.figure1);
0270 
0271 
0272 % --- Outputs from this function are returned to the command line.
0273 function varargout = prt_ui_results_stats_OutputFcn(hObject, eventdata, handles)
0274 % varargout  cell array for returning output args (see VARARGOUT);
0275 % hObject    handle to figure
0276 % eventdata  reserved - to be defined in a future version of MATLAB
0277 % handles    structure with handles and user data (see GUIDATA)
0278 
0279 % Get default command line output from handles structure
0280 varargout{1} = handles.output;
0281 
0282 % --- Executes on button press in helpbutton.
0283 function helpbutton_Callback(hObject, eventdata, handles)
0284 % hObject    handle to helpbutton (see GCBO)
0285 % eventdata  reserved - to be defined in a future version of MATLAB
0286 % handles    structure with handles and user data (see GUIDATA)
0287 
0288 disp('Help window for PRoNTo results has been launched.')
0289 prt_ui_results_help;
0290 
0291 % --- Executes on button press in quitbutton.
0292 function quitbutton_Callback(hObject, eventdata, handles)
0293 % hObject    handle to quitbutton (see GCBO)
0294 % eventdata  reserved - to be defined in a future version of MATLAB
0295 % handles    structure with handles and user data (see GUIDATA)
0296 
0297 % Close and clear figure
0298 % -------------------------------------------------------------------------
0299 close(handles.figure1);
0300 
0301 % --- Executes on selection change in foldmenu.
0302 function foldmenu_Callback(hObject, eventdata, handles)
0303 % hObject    handle to foldmenu (see GCBO)
0304 % eventdata  reserved - to be defined in a future version of MATLAB
0305 % handles    structure with handles and user data (see GUIDATA)
0306 
0307 % Hints: contents = cellstr(get(hObject,'String')) returns foldmenu contents as cell array
0308 %        contents{get(hObject,'Value')} returns selected item from foldmenu
0309 
0310 % Change weight map
0311 % -------------------------------------------------------------------------
0312 if ~handles.model_button
0313     if isfield(handles,'vols')
0314         handles.noloadw = 1;
0315         weightbutton_Callback(hObject, eventdata, handles);
0316     end
0317 end
0318 
0319 % Change plot
0320 % -------------------------------------------------------------------------
0321 if isfield(handles,'plot')
0322     plotmenu_Callback(hObject, eventdata, handles);
0323 end
0324 
0325 % Change stats
0326 % -------------------------------------------------------------------------
0327 statsbutton_Callback(hObject, eventdata, handles);
0328 
0329 % --- Executes during object creation, after setting all properties.
0330 function foldmenu_CreateFcn(hObject, eventdata, handles)
0331 % hObject    handle to foldmenu (see GCBO)
0332 % eventdata  reserved - to be defined in a future version of MATLAB
0333 % handles    empty - handles not created until after all CreateFcns called
0334 
0335 % Hint: popupmenu controls usually have a white background on Windows.
0336 %       See ISPC and COMPUTER.
0337 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0338     set(hObject,'BackgroundColor','white');
0339 end
0340 
0341 
0342 % --- Executes on selection change in plotmenu.
0343 function plotmenu_Callback(hObject, eventdata, handles)
0344 % hObject    handle to plotmenu (see GCBO)
0345 % eventdata  reserved - to be defined in a future version of MATLAB
0346 % handles    structure with handles and user data (see GUIDATA)
0347 
0348 % Hints: contents = cellstr(get(hObject,'String')) returns plotmenu contents as cell array
0349 %        contents{get(hObject,'Value')} returns selected item from plotmenu
0350 
0351 nplot         = get(handles.plotmenu,'String');
0352 plotm         = get(handles.plotmenu,'Value');
0353 plotchosen    = num2str(plotm);
0354 if plotm>length(nplot)  % reset to 1 if list of available plot smaller than chosen plot
0355     set(handles.plotmenu,'Value',1);
0356     plotm = 1;
0357     plotchosen    = num2str(plotm);
0358 end
0359 fold          = get(handles.foldmenu,'Value');
0360 model         = get(handles.classmenu,'Value');
0361 mi            = handles.mi;
0362 model         = mi(model);
0363 PRT           = handles.PRT;
0364 handles.plot  = 1;
0365 nms           = 7;
0366 isyc1         = 0;
0367 isyc2         = 0;
0368 c1            = 0;
0369 c2            = 0;
0370 rotate3d off
0371 pos = [0.108 0.1101 0.8543 0.8165];
0372 set(handles.axes5,'Position',pos);
0373 
0374 
0375 if strcmp(PRT.model(model).input.type,'classification')
0376     %     mclass        = length(handles.PRT.model(model).output.stats.c_acc);
0377     %     if mclass ~= 2
0378     %         multiplot  = 4;
0379     %         plotchosen = num2str(multiplot(plotm));
0380     %     end
0381     
0382     % Plot
0383     % ---------------------------------------------------------------------
0384     switch plotchosen
0385         
0386         
0387         % Histograms
0388         % -----------------------------------------------------------------
0389         case '1'
0390             prt_plot_histograms(handles.PRT, model, fold, handles.axes5);
0391             
0392             % Confusion matrix
0393             % -------------------------------------------------------------
0394         case '2'
0395             prt_plot_confusion_matrix(handles.PRT, model, fold, handles.axes5);
0396             
0397             % Predictions
0398             % -------------------------------------------------------------
0399         case '3'
0400             prt_plot_prediction(handles.PRT, model, fold, nms, handles.axes5);
0401             
0402             % ROC / AUC
0403             % -------------------------------------------------------------
0404         case '4'
0405             prt_plot_ROC(handles.PRT, model, fold, handles.axes5);
0406             
0407             % TODO: Check if this does not cause problems when the
0408             % Influence of the hyper-parameter on performance was not used
0409         case '5'
0410             prt_plot_nested_cv(handles.PRT, model, fold, handles.axes5);
0411             
0412     end
0413     
0414 else
0415     
0416     % Plot
0417     % ---------------------------------------------------------------------
0418     switch plotchosen
0419         case '1'
0420             prt_plot_prediction_reg_scatter(handles.PRT, model, handles.axes5);
0421             
0422         case '2'
0423             prt_plot_prediction_reg_bar(handles.PRT, model, handles.axes5);
0424             
0425         case '3'
0426             prt_plot_prediction_reg_line(handles.PRT, model, handles.axes5);
0427             
0428             % TODO: Check if this does not cause problems when the
0429             % nested CV was not used
0430         case '4'
0431             prt_plot_nested_cv(handles.PRT, model, fold, handles.axes5);
0432             
0433     end
0434 end
0435 
0436 guidata(hObject, handles);
0437 
0438 
0439 % --- Executes during object creation, after setting all properties.
0440 function plotmenu_CreateFcn(hObject, eventdata, handles)
0441 % hObject    handle to plotmenu (see GCBO)
0442 % eventdata  reserved - to be defined in a future version of MATLAB
0443 % handles    empty - handles not created until after all CreateFcns called
0444 
0445 % Hint: popupmenu controls usually have a white background on Windows.
0446 %       See ISPC and COMPUTER.
0447 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0448     set(hObject,'BackgroundColor','white');
0449 end
0450 
0451 
0452 % --- Executes on selection change in classmenu.
0453 function classmenu_Callback(hObject, eventdata, handles)
0454 % hObject    handle to classmenu (see GCBO)
0455 % eventdata  reserved - to be defined in a future version of MATLAB
0456 % handles    structure with handles and user data (see GUIDATA)
0457 
0458 % Hints: contents = cellstr(get(hObject,'String')) returns classmenu contents as cell array
0459 %        contents{get(hObject,'Value')} returns selected item from classmenu
0460 
0461 % Hints: contents = cellstr(get(hObject,'String')) returns classmenu contents as cell array
0462 %        contents{get(hObject,'Value')} returns selected item from classmenu
0463 
0464 % Get folds
0465 m  = get(handles.classmenu,'Value');
0466 mi = handles.mi;
0467 if length(handles.PRT.model(mi(m)).output)>1
0468     beep
0469     disp('Cannot display results per kernel in results window')
0470     return
0471 end
0472 handles.nfold = length(handles.PRT.model(mi(m)).output.fold);
0473 
0474 
0475 folds{1}      = 'All folds / Average';
0476 for f = 1:handles.nfold
0477     folds{f+1} = num2str(f);
0478 end
0479 
0480 % Set plots menu for first model
0481 if strcmp(handles.PRT.model(mi(m)).input.type,'classification');
0482     if length(handles.PRT.model(mi(m)).output(1).stats.c_acc) <= 2 ;
0483         plots = {'Histogram','Confusion Matrix','Predictions','ROC'};
0484     else
0485         plots = {'Histogram', 'Confusion Matrix'};
0486     end
0487 else
0488     plots = {'Predictions (scatter)', 'Predictions (bar)', 'Predictions (line)'};
0489 end
0490 if isfield(handles.PRT.model(mi(m)).input,'use_nested_cv')
0491     if handles.PRT.model(mi(m)).input.use_nested_cv
0492         plots{length(plots)+1} = 'Influence of the hyper-parameter on performance';
0493     end
0494 end
0495 
0496 
0497 set(handles.plotmenu,'String',plots);
0498 
0499 % Set folds and call fold function to change plot/stats
0500 handles.folds = folds;
0501 set(handles.foldmenu,'String',handles.folds);
0502 handles.model_button = 1;
0503 
0504 foldmenu_Callback(hObject, eventdata, handles);
0505 
0506 % Update stats if they are being shown
0507 if isfield(handles, 'stats')
0508     statsbutton_Callback(hObject, eventdata, handles);
0509 end
0510 
0511 handles.model_button = 0;
0512 guidata(hObject, handles);
0513 
0514 
0515 % --- Executes during object creation, after setting all properties.
0516 function classmenu_CreateFcn(hObject, eventdata, handles)
0517 % hObject    handle to classmenu (see GCBO)
0518 % eventdata  reserved - to be defined in a future version of MATLAB
0519 % handles    empty - handles not created until after all CreateFcns called
0520 
0521 % Hint: popupmenu controls usually have a white background on Windows.
0522 %       See ISPC and COMPUTER.
0523 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0524     set(hObject,'BackgroundColor','white');
0525 end
0526 
0527 
0528 function repedit_Callback(hObject, eventdata, handles)
0529 % hObject    handle to repedit (see GCBO)
0530 % eventdata  reserved - to be defined in a future version of MATLAB
0531 % handles    structure with handles and user data (see GUIDATA)
0532 
0533 % Hints: get(hObject,'String') returns contents of repedit as text
0534 %        str2double(get(hObject,'String')) returns contents of repedit as a double
0535 
0536 
0537 % --- Executes during object creation, after setting all properties.
0538 function repedit_CreateFcn(hObject, eventdata, handles)
0539 % hObject    handle to repedit (see GCBO)
0540 % eventdata  reserved - to be defined in a future version of MATLAB
0541 % handles    empty - handles not created until after all CreateFcns called
0542 
0543 % Hint: edit controls usually have a white background on Windows.
0544 %       See ISPC and COMPUTER.
0545 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0546     set(hObject,'BackgroundColor','white');
0547 end
0548 
0549 
0550 % --- Executes on button press in permutbutton.
0551 function permutbutton_Callback(hObject, eventdata, handles)
0552 % hObject    handle to permutbutton (see GCBO)
0553 % eventdata  reserved - to be defined in a future version of MATLAB
0554 % handles    structure with handles and user data (see GUIDATA)
0555 
0556 m    = get(handles.classmenu,'Value');
0557 mi   = handles.mi;
0558 reps = str2num(get(handles.repedit,'String'));
0559 if  ~isempty(reps)
0560     if length(reps) ==1
0561         reps = round(reps);
0562         disp('Performing permutation test.........>>')
0563         prt_permutation(handles.PRT, reps, mi(m), handles.pathdir,...
0564             handles.save_weights);
0565         % Load new PRT.mat
0566         PRTmat = fullfile(handles.pathdir,'PRT.mat');
0567         load(PRTmat);
0568         perm     = PRT.model(mi(m)).output.stats.permutation;
0569         stats.perm      = perm;
0570         stats.show_perm = 1;
0571         if strcmp(handles.PRT.model(mi(m)).input.type,'classification');
0572             stats.type = 'class';
0573         else
0574             stats.type = 'reg';
0575         end
0576         handles.stats = stats;
0577         handles.PRT   = PRT;
0578         
0579         % Update GUI
0580         guidata(hObject, handles);
0581         
0582         % Call stats button
0583         statsbutton_Callback(hObject, eventdata, handles);
0584     else
0585         beep;
0586         disp('Please enter only one value for the number of repetitions!');
0587     end
0588 else
0589     beep;
0590     disp('Repetitions should be a number!');
0591 end
0592 
0593 % --- Executes on button press in save_perm_weights.
0594 function save_perm_weights_Callback(hObject, eventdata, handles)
0595 % hObject    handle to save_perm_weights (see GCBO)
0596 % eventdata  reserved - to be defined in a future version of MATLAB
0597 % handles    structure with handles and user data (see GUIDATA)
0598 
0599 % Hint: get(hObject,'Value') returns toggle state of save_perm_weights
0600 % Save the weights and predictions for each permutation if required
0601 flag=get(handles.save_perm_weights,'Value');
0602 if flag
0603     handles.save_weights=1;
0604 else
0605     handles.save_weights=0;
0606 end
0607 guidata(hObject, handles);
0608 
0609 
0610 % --- Executes on button press in statsbutton.
0611 function statsbutton_Callback(hObject, eventdata, handles)
0612 % hObject    handle to statsbutton (see GCBO)
0613 % eventdata  reserved - to be defined in a future version of MATLAB
0614 % handles    structure with handles and user data (see GUIDATA)
0615 
0616 % Reads model and fold
0617 % -------------------------------------------------------------------------
0618 fold  = get(handles.foldmenu,'Value');
0619 mi    = handles.mi;
0620 m     = get(handles.classmenu,'Value');
0621 PRT   = handles.PRT;
0622 
0623 % % Check if stats exist
0624 % % -------------------------------------------------------------------------
0625 % if isfield(handles, 'stats')
0626 %     stats = handles.stats;
0627 % end
0628 
0629 % Read stats
0630 % -------------------------------------------------------------------------
0631 if strcmp(PRT.model(mi(m)).input.type,'classification')
0632     if fold == 1
0633         macc  = PRT.model(mi(m)).output.stats.acc;  % overall acc
0634         mbacc = PRT.model(mi(m)).output.stats.b_acc;
0635         mcacc = PRT.model(mi(m)).output.stats.c_acc;
0636         mcpv  = PRT.model(mi(m)).output.stats.c_pv;
0637         if isfield(PRT.model(mi(m)).output.stats,'permutation') && ...
0638                 ~isempty(PRT.model(mi(m)).output.stats.permutation)
0639             stats.show_perm=1;
0640             stats.perm.pvalue_b_acc=PRT.model(mi(m)).output.stats.permutation.pvalue_b_acc;
0641             stats.perm.pvalue_c_acc=PRT.model(mi(m)).output.stats.permutation.pvalue_c_acc;
0642         end
0643     else
0644         macc  = PRT.model(mi(m)).output.fold(fold-1).stats.acc;
0645         mbacc = PRT.model(mi(m)).output.fold(fold-1).stats.b_acc;
0646         mcacc = PRT.model(mi(m)).output.fold(fold-1).stats.c_acc;
0647         mcpv  = PRT.model(mi(m)).output.fold(fold-1).stats.c_pv;
0648     end
0649     
0650     stats.macc  = macc;
0651     stats.mbacc = mbacc;
0652     stats.mcacc = mcacc;
0653     stats.mcpv  = mcpv;
0654     stats.type  = 'class';
0655     
0656 else
0657     if fold == 1
0658         corr  = PRT.model(mi(m)).output.stats.corr;  % overall correlation
0659         if isfield(PRT.model(mi(m)).output.stats,'r2')
0660             r2  = PRT.model(mi(m)).output.stats.r2;  % squared correlation
0661         end
0662         mse   = PRT.model(mi(m)).output.stats.mse;  % overall mse
0663         if isfield(PRT.model(mi(m)).output.stats,'nmse')
0664             nmse  = PRT.model(mi(m)).output.stats.nmse;  % normalised mse
0665         end
0666         if isfield(PRT.model(mi(m)).output.stats,'permutation') && ...
0667                 ~isempty(PRT.model(mi(m)).output.stats.permutation)
0668             stats.show_perm=1;
0669             stats.perm.pval_corr = PRT.model(mi(m)).output.stats.permutation.pval_corr;
0670             stats.perm.pval_mse = PRT.model(mi(m)).output.stats.permutation.pval_mse;
0671             
0672             if isfield(PRT.model(mi(m)).output.stats.permutation, 'pval_r2'),...
0673                     stats.perm.pval_r2 = PRT.model(mi(m)).output.stats.permutation.pval_r2; end
0674             if isfield(PRT.model(mi(m)).output.stats.permutation, 'pval_nmse'),...
0675                     stats.perm.pval_nmse = PRT.model(mi(m)).output.stats.permutation.pval_nmse; end
0676             
0677         end
0678     else
0679         corr  = PRT.model(mi(m)).output.fold(fold-1).stats.corr;  % overall correlation
0680         if isfield(PRT.model(mi(m)).output.stats,'r2')
0681             r2  = PRT.model(mi(m)).output.fold(fold-1).stats.r2;  % overall correlation
0682         end
0683         mse   = PRT.model(mi(m)).output.fold(fold-1).stats.mse;  % overall mse
0684         if isfield(PRT.model(mi(m)).output.stats,'nmse')
0685             nmse  = PRT.model(mi(m)).output.fold(fold-1).stats.nmse;  % normalised mse
0686         end
0687     end
0688     
0689     stats.corr = corr;
0690     if isfield(PRT.model(mi(m)).output.stats,'r2'), stats.r2 = r2; end
0691     stats.mse  = mse;
0692     if isfield(PRT.model(mi(m)).output.stats,'nmse'), stats.nmse = nmse; end
0693     stats.type = 'reg';
0694     
0695 end
0696 
0697 %%% SHOW STATS
0698     
0699 switch stats.type
0700        
0701     case 'class'
0702         
0703         % Disable regression
0704         set(handles.corrtext,'Visible','off');
0705         set(handles.corrvaltext,'Visible','off');        
0706         set(handles.r2text,'Visible','off');
0707         set(handles.r2valtext,'Visible','off');
0708         set(handles.msetext,'Visible','off');
0709         set(handles.msevaltext,'Visible','off');
0710         set(handles.nmsetext,'Visible','off');
0711         set(handles.nmsevaltext,'Visible','off');
0712         set(handles.pcorr,'Visible','off');
0713         set(handles.pr2,'Visible','off');
0714         set(handles.pmse,'Visible','off');
0715         set(handles.pnmse,'Visible','off');
0716         
0717         set(handles.accuracytext,'String','Total accuracy:','Visible','on');
0718         set(handles.baccuracytext,'String','Balanced accuracy (BA):','Visible','on');
0719         set(handles.classaccuracytext,'String','Class accuracy (CA):','Visible','on');
0720         set(handles.ppvtext,'String','Class predictive value: ','Visible','on');
0721         
0722         set(handles.acctext,'String',sprintf('%3.2f %%',stats.macc*100),'Visible','on');
0723         set(handles.bacctext,'String',sprintf('%3.2f %%',stats.mbacc*100),'Visible','on');
0724         set(handles.cacctext,'String',sprintf('  %3.2f %%',stats.mcacc*100),'Visible','on');
0725         set(handles.cpvval,'String',sprintf('  %3.2f %%',...
0726             stats.mcpv*100),'Visible','on');
0727         
0728         set(handles.pvalbacc,'String','BA p-value:','Visible','on');
0729         set(handles.pvalcacc,'String','CA p-value:','Visible','on');
0730         set(handles.pbacc,'String','N. A.','Visible','on');
0731         set(handles.pcacc,'String','N. A.','Visible','on');
0732         
0733         if isfield(stats,'show_perm')
0734             
0735             if stats.show_perm
0736 
0737                 set(handles.pbacc,'String',sprintf(' %3.4f',stats.perm.pvalue_b_acc));
0738                 set(handles.pcacc,'String',sprintf(' %3.4f',stats.perm.pvalue_c_acc));
0739                 
0740             end
0741             
0742         end
0743          
0744     case 'reg'
0745         
0746         set(handles.accuracytext,'Visible','off');
0747         set(handles.baccuracytext,'Visible','off');
0748         set(handles.classaccuracytext,'Visible','off');
0749         set(handles.ppvtext,'Visible','off');
0750         set(handles.acctext,'Visible','off');
0751         set(handles.bacctext,'Visible','off');
0752         set(handles.cacctext,'Visible','off');
0753         set(handles.cpvval,'Visible','off');
0754         set(handles.pvalbacc,'Visible','off');
0755         set(handles.pvalcacc,'Visible','off');
0756         set(handles.pbacc,'Visible','off');
0757         set(handles.pcacc,'Visible','off');
0758         
0759         set(handles.corrtext,'String','Correlation:','Visible','on');
0760         set(handles.corrvaltext,'String',sprintf('%3.2f',stats.corr),'Visible','on');
0761         
0762         if isfield(stats,'r2')
0763             set(handles.r2text,'String','Coeff. of determination (R2):','Visible','on');
0764             set(handles.r2valtext,'String',sprintf('%3.2f',stats.r2),'Visible','on');
0765             set(handles.pr2,'Visible','on','String','R2 p-value: N. A.');
0766         end
0767         
0768         set(handles.msetext,'String','MSE:','Visible','on');
0769         set(handles.msevaltext,'String',sprintf('%3.2f',stats.mse),'Visible','on');
0770         
0771         if isfield(stats,'nmse')
0772             set(handles.nmsetext,'String','Norm. MSE:','Visible','on');
0773             set(handles.nmsevaltext,'String',sprintf('%3.2f',stats.nmse),'Visible','on');
0774             set(handles.pnmse,'Visible','on','String','Norm. MSE p-value: N. A.');
0775         end
0776         
0777         set(handles.pcorr,'Visible','on','String','Correlation p-value: N. A.');   
0778         set(handles.pmse,'Visible','on','String','MSE p-value: N. A.');
0779 
0780         
0781         if isfield(stats,'show_perm')
0782             
0783             if stats.show_perm
0784                 
0785                 set(handles.pcorr,'Visible','on','String',sprintf('Correlation p-value: %3.4f',stats.perm.pval_corr));
0786                 if isfield(stats.perm,'pval_r2'), set(handles.pr2,'Visible','on','String',sprintf('R2 p-value: %3.4f',stats.perm.pval_r2)); end
0787                 set(handles.pmse,'Visible','on','String',sprintf('MSE p-value: %3.4f',stats.perm.pval_mse));
0788                 if isfield(stats.perm,'pval_nmse'), set(handles.pnmse,'Visible','on','String',sprintf('Norm. MSE p-value: %3.4f',stats.perm.pval_nmse));end
0789                 
0790             end
0791         end
0792 end
0793     
0794 
0795 stats.show_perm = 0;
0796 handles.stats = stats;
0797 guidata(hObject, handles);
0798 
0799 % Save menu
0800 % -------------------------------------------------------------------------
0801 function savemenu_Callback(hObject, eventdata, handles)
0802 % hObject    handle to savemenu (see GCBO)
0803 % eventdata  reserved - to be defined in a future version of MATLAB
0804 % handles    structure with handles and user data (see GUIDATA)
0805 wd=cd;
0806 cd(handles.prtdir)
0807 [filename, pathname] = uiputfile( ...
0808     {'*.png','Portable Network Graphics (*.png)';...
0809     '*.jpeg','JPEG figure (*.jpeg)';...
0810     '*.tiff','Compressed TIFF figure (*.tiff)';...
0811     '*.fig','Matlab figure (*.fig)';...
0812     '*.pdf','Color PDF file (*.pdf)';...
0813     '*.epsc',  'Encapsulated PostScript (*.eps)'},...
0814     'Save figure as','.png');
0815 [a,b,c]=fileparts(filename);
0816 ext=['-d',c(2:end)];
0817 
0818 % Set the color of the different backgrounds and figure parameters to white
0819 cf=get(handles.figure1,'Color');
0820 set(handles.figure1,'Color',[1,1,1])
0821 aa=get(handles.figure1,'children');
0822 xc=[];
0823 for i=1:length(aa)
0824     if strcmpi(get(aa(i),'type'),'uipanel')
0825         try
0826             xc=[xc;get(aa(i),'BackgroundColor')];
0827             set(aa(i),'BackgroundColor',[1 1 1])
0828         end
0829         bb=get(aa(i),'children');
0830         if ~isempty(bb)
0831             for j=1:length(bb)
0832                 try
0833                     xc=[xc;get(bb(j),'BackgroundColor')];
0834                     set(bb(j),'BackgroundColor',[1 1 1])
0835                 end
0836                 if strcmpi(get(bb(j),'type'),'uipanel')
0837                     cc=get(bb(j),'children');
0838                     if ~isempty(cc)
0839                         for k=1:length(cc)
0840                             try
0841                                 xc=[xc;get(cc(k),'BackgroundColor')];
0842                                 set(cc(k),'BackgroundColor',[1 1 1])
0843                             end
0844                             if strcmpi(get(cc(k),'type'),'uipanel')
0845                                 dd=get(cc(k),'children');
0846                                 if ~isempty(dd)
0847                                     for l=1:length(dd)
0848                                         try
0849                                             xc=[xc;get(dd(l),'BackgroundColor')];
0850                                             set(dd(l),'BackgroundColor',[1 1 1])
0851                                         end
0852                                     end
0853                                 end
0854                             end
0855                         end
0856                     end
0857                 end
0858             end
0859         end
0860     end
0861     if ~strcmpi(get(aa(i),'type'),'uimenu')
0862         try
0863             xc=[xc;get(aa(i),'BackgroundColor')];
0864             set(aa(i),'BackgroundColor',[1 1 1])
0865         end
0866     end
0867 end
0868 
0869 if ~strcmp(ext, '-dfig')
0870     print(handles.figure1,ext,[pathname,filesep,b],'-r500')
0871 else
0872     saveas(handles.figure1,[pathname,filesep,b],'fig')
0873 end
0874 
0875 
0876 % Set the color of the different backgrounds and figure parameters to white
0877 set(handles.figure1,'Color',cf)
0878 scount=1;
0879 for i=1:length(aa)
0880     if strcmpi(get(aa(i),'type'),'uipanel')
0881         try
0882             set(aa(i),'BackgroundColor',xc(scount,:))
0883             scount=scount+1;
0884         end
0885         bb=get(aa(i),'children');
0886         if ~isempty(bb)
0887             for j=1:length(bb)
0888                 try
0889                     set(bb(j),'BackgroundColor',xc(scount,:))
0890                     scount=scount+1;
0891                 end
0892                 if strcmpi(get(bb(j),'type'),'uipanel')
0893                     cc=get(bb(j),'children');
0894                     if ~isempty(cc)
0895                         for k=1:length(cc)
0896                             try
0897                                 set(cc(k),'BackgroundColor',xc(scount,:))
0898                                 scount=scount+1;
0899                             end
0900                             if strcmpi(get(cc(k),'type'),'uipanel')
0901                                 dd=get(cc(k),'children');
0902                                 if ~isempty(dd)
0903                                     for l=1:length(dd)
0904                                         try
0905                                             set(dd(l),'BackgroundColor',xc(scount,:))
0906                                             scount=scount+1;
0907                                         end
0908                                     end
0909                                 end
0910                             end
0911                         end
0912                     end
0913                 end
0914             end
0915         end
0916     elseif ~strcmpi(get(aa(i),'type'),'uimenu')
0917         try
0918             set(aa(i),'BackgroundColor',xc(scount,:))
0919             scount=scount+1;
0920         end
0921     end
0922 end
0923 
0924 cd(wd)
0925 
0926 
0927 % --- Executes on button press in showweights.
0928 function showweights_Callback(hObject, eventdata, handles)
0929 % hObject    handle to showweights (see GCBO)
0930 % eventdata  reserved - to be defined in a future version of MATLAB
0931 % handles    structure with handles and user data (see GUIDATA)
0932 
0933 
0934 % --- Executes on button press in editPlotButton.
0935 function editPlotButton_Callback(hObject, eventdata, handles)
0936 % hObject    handle to editPlotButton (see GCBO)
0937 % eventdata  reserved - to be defined in a future version of MATLAB
0938 % handles    structure with handles and user data (see GUIDATA)
0939 
0940 % Get stuff from the displayed figure
0941 old_fig = gcf;
0942 figure_children = get(old_fig,'Children');
0943 children_axes = findall(figure_children,'Type','axes'); %important to get the legends too
0944 
0945 % Create a new figure
0946 fig_out = figure;
0947 if length(children_axes) > 1 % There are legends in the figure
0948     axes_out = copyobj([children_axes(1); children_axes(2)], fig_out);
0949 else % There are no legends in the figure
0950     axes_out = copyobj(children_axes, fig_out);
0951 end

Generated on Tue 10-Feb-2015 18:16:33 by m2html © 2005