Home > . > prt_ui_stats.m

prt_ui_stats

PURPOSE ^

PRT_UI_STATS MATLAB code for prt_ui_stats.fig

SYNOPSIS ^

function varargout = prt_ui_stats(varargin)

DESCRIPTION ^

 PRT_UI_STATS MATLAB code for prt_ui_stats.fig

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

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

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

 PRT_UI_STATS('Property','Value',...) creates a new PRT_UI_STATS or raises
 the existing singleton*.  Starting from the left, property value pairs
 are applied to the GUI before prt_ui_stats_OpeningFcn gets called.  An
 unrecognized property name or invalid value makes property application
 stop.  All inputs are passed to prt_ui_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_stats(varargin)
0002 % PRT_UI_STATS MATLAB code for prt_ui_stats.fig
0003 %
0004 % PRT_UI_STATS, by itself, creates a new PRT_UI_STATS or raises the
0005 % existing singleton*.
0006 %
0007 % H = PRT_UI_STATS returns the handle to a new PRT_UI_STATS or the handle
0008 % to the existing singleton*.
0009 %
0010 % PRT_UI_STATS('CALLBACK',hObject,eventData,handles,...) calls the local
0011 % function named CALLBACK in PRT_UI_STATS.M with the given input arguments.
0012 %
0013 % PRT_UI_STATS('Property','Value',...) creates a new PRT_UI_STATS or raises
0014 % the existing singleton*.  Starting from the left, property value pairs
0015 % are applied to the GUI before prt_ui_stats_OpeningFcn gets called.  An
0016 % unrecognized property name or invalid value makes property application
0017 % stop.  All inputs are passed to prt_ui_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_stats
0030 
0031 % Last Modified by GUIDE v2.5 29-Mar-2012 11:29:32
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_stats_OpeningFcn, ...
0038     'gui_OutputFcn',  @prt_ui_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_stats is made visible.
0054 function prt_ui_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_stats (see VARARGIN)
0060 
0061 %if window already exists, just put it as the current figure
0062 Tag='stats';
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 :: Stats table)
0074     %set size of the window, taking screen resolution and platform into account
0075     S0= spm('WinSize','0',1);   %-Screen size (of the current monitor)
0076     if ispc
0077         PF='MS Sans Serif';
0078     else
0079         PF= spm_platform('fonts');     %-Font names (for this platform)
0080         PF=PF.helvetica;
0081     end
0082     tmp  = [S0(3)/1280 (S0(4))/800];
0083     ratio=min(tmp)*[1 1 1 1];
0084     FS = 1 + 0.85*(min(ratio)-1);  %factor to scale the fonts
0085     x=get(handles.figure1,'Position');
0086     set(handles.figure1,'DefaultTextFontSize',FS*12,...
0087         'DefaultUicontrolFontSize',FS*12,...
0088         'DefaultTextFontName',PF,...
0089         'DefaultAxesFontName',PF,...
0090         'DefaultUicontrolFontName',PF)
0091     set(handles.figure1,'Position',ratio.*x)
0092     set(handles.figure1,'Resize','on')
0093     
0094     rotate3d off
0095     color=prt_get_defaults('color');
0096     set(handles.figure1,'Color',color.bg1)
0097     aa=get(handles.figure1,'children');
0098     for i=1:length(aa)
0099         if strcmpi(get(aa(i),'type'),'uipanel')
0100             set(aa(i),'BackgroundColor',color.bg2)
0101             bb=get(aa(i),'children');
0102             if ~isempty(bb)
0103                 for j=1:length(bb)
0104                     if strcmpi(get(bb(j),'type'),'uipanel')
0105                         set(bb(j),'BackgroundColor',color.bg2)
0106                         cc=get(bb(j),'children');
0107                         for k=1:length(cc)
0108                             if strcmpi(get(cc(k),'type'),'uicontrol') && ...
0109                                     ~isempty(find(strcmpi(get(cc(k),'Style'),{'text',...
0110                                     'radiobutton','checkbox'})))
0111                                 set(cc(k),'BackgroundColor',color.bg2)
0112                             elseif strcmpi(get(cc(k),'type'),'uicontrol') && ...
0113                                     ~isempty(find(strcmpi(get(cc(k),'Style'),'pushbutton')))
0114                                 set(cc(k),'BackgroundColor',color.fr)
0115                             end
0116                             set(cc(k),'FontUnits','pixel')
0117                             xf=get(cc(k),'FontSize');
0118                             set(cc(k),'FontSize',ceil(FS*xf),'FontName',PF,...
0119                                 'FontUnits','normalized','Units','normalized')
0120                         end
0121                     elseif strcmpi(get(bb(j),'type'),'uicontrol') && ...
0122                             ~isempty(find(strcmpi(get(bb(j),'Style'),{'text',...
0123                             'radiobutton','checkbox'})))
0124                         set(bb(j),'BackgroundColor',color.bg2)
0125                     elseif strcmpi(get(bb(j),'type'),'uicontrol') && ...
0126                             ~isempty(find(strcmpi(get(bb(j),'Style'),'pushbutton')))
0127                         set(bb(j),'BackgroundColor',color.fr)
0128                     end
0129                     set(bb(j),'FontUnits','pixel')
0130                     xf=get(bb(j),'FontSize');
0131                     set(bb(j),'FontSize',ceil(FS*xf),'FontName',PF,...
0132                         'FontUnits','normalized','Units','normalized')
0133                 end
0134             end
0135         elseif strcmpi(get(aa(i),'type'),'uicontrol')
0136             if ~isempty(find(strcmpi(get(aa(i),'Style'),{'text',...
0137                     'radiobutton','checkbox'})))
0138                 set(aa(i),'BackgroundColor',color.bg1)
0139             elseif ~isempty(find(strcmpi(get(aa(i),'Style'),'pushbutton')))
0140                 set(aa(i),'BackgroundColor',color.fr)
0141             end
0142         end
0143         if ~strcmpi(get(aa(i),'type'),'uimenu')
0144             set(aa(i),'FontUnits','pixel')
0145             xf=get(aa(i),'FontSize');
0146             set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0147                 'Units','normalized')
0148         end
0149     end
0150 end
0151 
0152 if ~isempty(varargin)
0153     
0154     stats = varargin{1};
0155     
0156     switch stats.type
0157         
0158         
0159         case 'class'
0160             
0161             set(handles.corrtext,'Visible','off');
0162             set(handles.corrvaltext,'Visible','off');
0163             
0164             set(handles.r2text,'Visible','off');
0165             set(handles.r2valtext,'Visible','off');
0166             
0167             set(handles.msetext,'Visible','off');
0168             set(handles.msevaltext,'Visible','off');
0169             
0170             set(handles.nmsetext,'Visible','off');
0171             set(handles.nmsevaltext,'Visible','off');
0172             
0173             set(handles.pcorr,'Visible','off');
0174             set(handles.pr2,'Visible','off');
0175             set(handles.pmse,'Visible','off');
0176             set(handles.pnmse,'Visible','off');
0177             
0178             set(handles.accuracytext,'String','Accuracy (acc):','Visible','on');
0179             set(handles.baccuracytext,'String','Balanced acc:','Visible','on');
0180             set(handles.classaccuracytext,'String','Class acc (%):','Visible','on');
0181             set(handles.ppvtext,'String','Class pv (%): ','Visible','on');
0182             set(handles.cpvval,'String',sprintf(' %3.1f ',...
0183                 stats.mcpv*100),'Visible','on');
0184             set(handles.npvtext,'String','NPV: not yet available','Visible','off');
0185             
0186             set(handles.acctext,'String',sprintf('%3.1f %%',stats.macc*100),'Visible','on');
0187             set(handles.bacctext,'String',sprintf('%3.1f %%',stats.mbacc*100),'Visible','on');
0188             
0189             set(handles.cacctext,'String',sprintf(' %3.1f',stats.mcacc*100),'Visible','on');
0190             
0191             set(handles.pcorr, 'Visible','off');
0192             set(handles.pr2, 'Visible','off');
0193             set(handles.pmse,'Visible','off');
0194             set(handles.pnmse,'Visible','off');
0195             set(handles.pbacc,'Visible','off');
0196             set(handles.pcacc,'Visible','off');
0197             
0198             
0199             if isfield(stats,'show_perm')
0200                 
0201                 if stats.show_perm
0202                     
0203                     beep;
0204                     disp('...')
0205                     disp('Permutations results:')
0206                     disp(sprintf('Balanced accuracy p-value: %3.4f',stats.perm.pvalue_b_acc));
0207                     disp(sprintf('Class accuracy p-value:'));
0208                     disp(sprintf(' %3.4f',stats.perm.pvalue_c_acc));
0209                     
0210                 end
0211                 
0212             end
0213             
0214         case 'reg'
0215             
0216             set(handles.accuracytext,'String','Accuracy (acc):','Visible','off');
0217             set(handles.baccuracytext,'String','Balanced acc:','Visible','off');
0218             set(handles.classaccuracytext,'String','Class acc:','Visible','off');
0219             set(handles.pbacc, 'Visible','off');
0220             set(handles.pcacc,'Visible','off');
0221             
0222             set(handles.acctext,'Visible','off');
0223             set(handles.bacctext,'Visible','off');
0224             set(handles.cacctext,'Visible','off');
0225             
0226             set(handles.ppvtext,'Visible','off');
0227             set(handles.npvtext,'Visible','off');
0228             
0229             set(handles.corrtext,'String','Correlation:','Visible','on');
0230             set(handles.corrvaltext,'String',sprintf('%3.2f',stats.corr),'Visible','on');
0231             
0232             if isfield(stats,'r2')
0233                 set(handles.r2text,'String','Coefficient of determination:','Visible','on');
0234                 set(handles.r2valtext,'String',sprintf('%3.2f',stats.r2),'Visible','on');
0235             end
0236             
0237             set(handles.msetext,'String','MSE:','Visible','on');
0238             set(handles.msevaltext,'String',sprintf('%3.2f',stats.mse),'Visible','on');
0239             
0240             if isfield(stats,'nmse')
0241                 set(handles.nmsetext,'String','Normalised MSE:','Visible','on');
0242                 set(handles.nmsevaltext,'String',sprintf('%3.2f',stats.nmse),'Visible','on');
0243             end
0244             
0245             set(handles.pbacc, 'Visible','off');
0246             set(handles.pcacc,'Visible','off');
0247             set(handles.pcorr,'Visible','off');
0248             set(handles.pr2,'Visible','off');
0249             set(handles.pmse,'Visible','off');
0250             set(handles.pnmse,'Visible','off');
0251             
0252             if isfield(stats,'show_perm')
0253                 
0254                 if stats.show_perm
0255                     
0256                     beep;
0257                     disp('...')
0258                     disp('Permutations results:')
0259                     disp(sprintf('Correlation p-value: %3.4f',stats.perm.pval_corr));
0260                     if isfield(stats.perm,'pval_r2'), disp(sprintf('Coefficient of determination p-value: %3.4f',stats.perm.pval_r2)); end
0261                     disp(sprintf('Mean squared-error p-value: %3.4f',stats.perm.pval_mse));
0262                     if isfield(stats.perm,'pval_nmse'), disp(sprintf('Normalised mean squared-error p-value: %3.4f',stats.perm.pval_nmse)); end
0263                     
0264                 end
0265             end
0266     end
0267     handles.prtdir=varargin{2};
0268     
0269 end
0270 
0271 rotate3d off
0272 % Choose default command line output for prt_ui_stats
0273 handles.output = hObject;
0274 
0275 % Update handles structure
0276 guidata(hObject, handles);
0277 
0278 % UIWAIT makes prt_ui_stats wait for user response (see UIRESUME)
0279 % uiwait(handles.figure1);
0280 
0281 
0282 % --- Outputs from this function are returned to the command line.
0283 function varargout = prt_ui_stats_OutputFcn(hObject, eventdata, handles)
0284 % varargout  cell array for returning output args (see VARARGOUT);
0285 % hObject    handle to figure
0286 % eventdata  reserved - to be defined in a future version of MATLAB
0287 % handles    structure with handles and user data (see GUIDATA)
0288 
0289 % Get default command line output from handles structure
0290 varargout{1} = handles.output;
0291 
0292 
0293 
0294 
0295 % --------------------------------------------------------------------
0296 function savemenu_Callback(hObject, eventdata, handles)
0297 % hObject    handle to savemenu (see GCBO)
0298 % eventdata  reserved - to be defined in a future version of MATLAB
0299 % handles    structure with handles and user data (see GUIDATA)
0300 
0301 wd=cd;
0302 cd(handles.prtdir)
0303 [filename, pathname] = uiputfile( ...
0304     {'*.png','Portable Network Graphics (*.png)';...
0305     '*.jpeg','JPEG figure (*.jpeg)';...
0306     '*.tiff','Compressed TIFF figure (*.tiff)';...
0307     '*.fig','Matlab figure (*.fig)';...
0308     '*.pdf','Color PDF file (*.pdf)';...
0309     '*.epsc',  'Encapsulated PostScript (*.eps)'},...
0310     'Save figure as','Stats_table.png');
0311 [a,b,c]=fileparts(filename);
0312 ext=['-d',c(2:end)];
0313 
0314 % Set the color of the different backgrounds and figure parameters to white
0315 cf=get(handles.figure1,'Color');
0316 set(handles.figure1,'Color',[1,1,1])
0317 aa=get(handles.figure1,'children');
0318 xc=[];
0319 for i=1:length(aa)
0320     if strcmpi(get(aa(i),'type'),'uipanel')
0321         try
0322             xc=[xc;get(aa(i),'BackgroundColor')];
0323             set(aa(i),'BackgroundColor',[1 1 1])
0324         end
0325         bb=get(aa(i),'children');
0326         if ~isempty(bb)
0327             for j=1:length(bb)
0328                 try
0329                     xc=[xc;get(bb(j),'BackgroundColor')];
0330                     set(bb(j),'BackgroundColor',[1 1 1])
0331                 end
0332                 if strcmpi(get(bb(j),'type'),'uipanel')
0333                     cc=get(bb(j),'children');
0334                     if ~isempty(cc)
0335                         for k=1:length(cc)
0336                             try
0337                                 xc=[xc;get(cc(k),'BackgroundColor')];
0338                                 set(cc(k),'BackgroundColor',[1 1 1])
0339                             end
0340                             if strcmpi(get(cc(k),'type'),'uipanel')
0341                                 dd=get(cc(k),'children');
0342                                 if ~isempty(dd)
0343                                     for l=1:length(dd)
0344                                         try
0345                                             xc=[xc;get(dd(l),'BackgroundColor')];
0346                                             set(dd(l),'BackgroundColor',[1 1 1])
0347                                         end
0348                                     end
0349                                 end
0350                             end
0351                         end
0352                     end
0353                 end
0354             end
0355         end
0356     end
0357     if ~strcmpi(get(aa(i),'type'),'uimenu')
0358         try
0359             xc=[xc;get(aa(i),'BackgroundColor')];
0360             set(aa(i),'BackgroundColor',[1 1 1])
0361         end
0362     end
0363 end
0364 
0365 print(handles.figure1,ext,[pathname,filesep,b],'-r500')
0366 
0367 % Set the color of the different backgrounds and figure parameters to white
0368 set(handles.figure1,'Color',cf)
0369 scount=1;
0370 for i=1:length(aa)
0371     if strcmpi(get(aa(i),'type'),'uipanel')
0372         try
0373             set(aa(i),'BackgroundColor',xc(scount,:))
0374             scount=scount+1;
0375         end
0376         bb=get(aa(i),'children');
0377         if ~isempty(bb)
0378             for j=1:length(bb)
0379                 try
0380                     set(bb(j),'BackgroundColor',xc(scount,:))
0381                     scount=scount+1;
0382                 end
0383                 if strcmpi(get(bb(j),'type'),'uipanel')
0384                     cc=get(bb(j),'children');
0385                     if ~isempty(cc)
0386                         for k=1:length(cc)
0387                             try
0388                                 set(cc(k),'BackgroundColor',xc(scount,:))
0389                                 scount=scount+1;
0390                             end
0391                             if strcmpi(get(cc(k),'type'),'uipanel')
0392                                 dd=get(cc(k),'children');
0393                                 if ~isempty(dd)
0394                                     for l=1:length(dd)
0395                                         try
0396                                             set(dd(l),'BackgroundColor',xc(scount,:))
0397                                             scount=scount+1;
0398                                         end
0399                                     end
0400                                 end
0401                             end
0402                         end
0403                     end
0404                 end
0405             end
0406         end
0407     elseif ~strcmpi(get(aa(i),'type'),'uimenu')
0408         try
0409             set(aa(i),'BackgroundColor',xc(scount,:))
0410             scount=scount+1;
0411         end
0412     end
0413 end
0414 
0415 cd(wd)

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