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: prt_ui_stats.m 551 2012-05-31 08:26:54Z amarquan $
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         if ispc
0147             set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0148                 'FontUnits','normalized','Units','normalized')
0149         else
0150             set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0151                 'Units','normalized')
0152         end
0153     end 
0154 end
0155 end
0156 
0157 if ~isempty(varargin)
0158     
0159     stats = varargin{1};
0160     
0161         switch stats.type
0162             
0163             
0164             case 'class'
0165                 
0166                 set(handles.corrtext,'Visible','off');
0167                 set(handles.corrvaltext,'Visible','off');
0168                 
0169                 set(handles.msetext,'Visible','off');
0170                 set(handles.msevaltext,'Visible','off');
0171                 
0172                 set(handles.pcorr,'Visible','off');
0173                 set(handles.pmse,'Visible','off');
0174                 
0175                 set(handles.accuracytext,'String','Accuracy (acc):','Visible','on');
0176                 set(handles.baccuracytext,'String','Balanced acc:','Visible','on');
0177                 set(handles.classaccuracytext,'String','Class acc (%):','Visible','on');
0178                 set(handles.ppvtext,'String','Class pv (%): ','Visible','on');
0179                 set(handles.cpvval,'String',sprintf(' %3.1f ',...
0180                     stats.mcpv*100),'Visible','on');
0181                 set(handles.npvtext,'String','NPV: not yet available','Visible','off');
0182                 
0183                 set(handles.acctext,'String',sprintf('%3.1f %%',stats.macc*100),'Visible','on');
0184                 set(handles.bacctext,'String',sprintf('%3.1f %%',stats.mbacc*100),'Visible','on');
0185                 
0186                 set(handles.cacctext,'String',sprintf(' %3.1f',stats.mcacc*100),'Visible','on');
0187                 
0188                 set(handles.pcorr, 'Visible','off');
0189                 set(handles.pmse,'Visible','off');
0190                 set(handles.pbacc,'Visible','off');
0191                 set(handles.pcacc,'Visible','off');
0192                 
0193                 
0194                 if isfield(stats,'show_perm')
0195                     
0196                     if stats.show_perm
0197                         
0198                         beep;
0199                         disp('...')
0200                         disp('Permutations results:')
0201                         disp(sprintf('Balanced accuracy p-value: %3.4f',stats.perm.pvalue_b_acc));
0202                         disp(sprintf('Class accuracy p-value:'));
0203                         disp(sprintf(' %3.4f',stats.perm.pvalue_c_acc));
0204                         
0205                     end
0206                     
0207                 end
0208                 
0209             case 'reg'
0210                 
0211                 set(handles.accuracytext,'String','Accuracy (acc):','Visible','off');
0212                 set(handles.baccuracytext,'String','Balanced acc:','Visible','off');
0213                 set(handles.classaccuracytext,'String','Class acc:','Visible','off');
0214                 set(handles.pbacc, 'Visible','off');
0215                 set(handles.pcacc,'Visible','off');
0216                 
0217                 set(handles.acctext,'Visible','off');
0218                 set(handles.bacctext,'Visible','off');
0219                 set(handles.cacctext,'Visible','off');
0220                 
0221                 set(handles.ppvtext,'Visible','off');
0222                 set(handles.npvtext,'Visible','off');
0223                 
0224                 set(handles.corrtext,'String','Correlation:','Visible','on');
0225                 set(handles.corrvaltext,'String',sprintf('%3.2f',stats.corr),'Visible','on');
0226                 
0227                 set(handles.msetext,'String','MSE:','Visible','on');
0228                 set(handles.msevaltext,'String',sprintf('%3.2f',stats.mse),'Visible','on');
0229                 
0230                 set(handles.pbacc, 'Visible','off');
0231                 set(handles.pcacc,'Visible','off');
0232                 set(handles.pcorr,'Visible','off');
0233                 set(handles.pmse,'Visible','off');
0234                 
0235                 if isfield(stats,'show_perm')
0236                     
0237                     if stats.show_perm
0238                        
0239                         beep;
0240                         disp('...')
0241                         disp('Permutations results:')
0242                         disp(sprintf('Correlation p-value: %3.4f',stats.perm.pval_corr));
0243                         disp(sprintf('Mean squared-error p-value: %3.4f',stats.perm.pval_mse));
0244 
0245                     end
0246                 end
0247         end
0248         handles.prtdir=varargin{2};
0249         
0250 end
0251 
0252 rotate3d off
0253 % Choose default command line output for prt_ui_stats
0254 handles.output = hObject;
0255 
0256 % Update handles structure
0257 guidata(hObject, handles);
0258 
0259 % UIWAIT makes prt_ui_stats wait for user response (see UIRESUME)
0260 % uiwait(handles.figure1);
0261 
0262 
0263 % --- Outputs from this function are returned to the command line.
0264 function varargout = prt_ui_stats_OutputFcn(hObject, eventdata, handles) 
0265 % varargout  cell array for returning output args (see VARARGOUT);
0266 % hObject    handle to figure
0267 % eventdata  reserved - to be defined in a future version of MATLAB
0268 % handles    structure with handles and user data (see GUIDATA)
0269 
0270 % Get default command line output from handles structure
0271 varargout{1} = handles.output;
0272 
0273 
0274 
0275 
0276 % --------------------------------------------------------------------
0277 function savemenu_Callback(hObject, eventdata, handles)
0278 % hObject    handle to savemenu (see GCBO)
0279 % eventdata  reserved - to be defined in a future version of MATLAB
0280 % handles    structure with handles and user data (see GUIDATA)
0281 
0282 wd=cd;
0283 cd(handles.prtdir)
0284 [filename, pathname] = uiputfile( ...
0285 {'*.png','Portable Network Graphics (*.png)';...
0286  '*.jpeg','JPEG figure (*.jpeg)';...
0287  '*.tiff','Compressed TIFF figure (*.tiff)';... 
0288  '*.fig','Matlab figure (*.fig)';...
0289  '*.pdf','Color PDF file (*.pdf)';...
0290  '*.epsc',  'Encapsulated PostScript (*.eps)'},...
0291  'Save figure as','Stats_table.png');
0292 [a,b,c]=fileparts(filename);
0293 ext=['-d',c(2:end)];
0294 
0295 % Set the color of the different backgrounds and figure parameters to white
0296 cf=get(handles.figure1,'Color');
0297 set(handles.figure1,'Color',[1,1,1])
0298 aa=get(handles.figure1,'children');
0299 xc=[];
0300 for i=1:length(aa)
0301     if strcmpi(get(aa(i),'type'),'uipanel')
0302         try
0303             xc=[xc;get(aa(i),'BackgroundColor')];
0304             set(aa(i),'BackgroundColor',[1 1 1])
0305         end
0306         bb=get(aa(i),'children');
0307         if ~isempty(bb)
0308             for j=1:length(bb)
0309                 try
0310                     xc=[xc;get(bb(j),'BackgroundColor')];
0311                     set(bb(j),'BackgroundColor',[1 1 1])
0312                 end
0313                 if strcmpi(get(bb(j),'type'),'uipanel')
0314                     cc=get(bb(j),'children');
0315                     if ~isempty(cc)
0316                         for k=1:length(cc)
0317                             try
0318                                 xc=[xc;get(cc(k),'BackgroundColor')];
0319                                 set(cc(k),'BackgroundColor',[1 1 1])
0320                             end
0321                             if strcmpi(get(cc(k),'type'),'uipanel')
0322                                 dd=get(cc(k),'children');
0323                                 if ~isempty(dd)
0324                                     for l=1:length(dd)
0325                                         try
0326                                             xc=[xc;get(dd(l),'BackgroundColor')];
0327                                             set(dd(l),'BackgroundColor',[1 1 1])
0328                                         end
0329                                     end
0330                                 end
0331                             end
0332                         end
0333                     end
0334                 end
0335             end
0336         end
0337     end
0338     if ~strcmpi(get(aa(i),'type'),'uimenu')
0339         try
0340             xc=[xc;get(aa(i),'BackgroundColor')];
0341             set(aa(i),'BackgroundColor',[1 1 1])
0342         end
0343     end
0344 end
0345 
0346 print(handles.figure1,ext,[pathname,filesep,b],'-r500')
0347 
0348 % Set the color of the different backgrounds and figure parameters to white
0349 set(handles.figure1,'Color',cf)
0350 scount=1;
0351 for i=1:length(aa)
0352     if strcmpi(get(aa(i),'type'),'uipanel')
0353         try
0354             set(aa(i),'BackgroundColor',xc(scount,:))
0355             scount=scount+1;
0356         end
0357         bb=get(aa(i),'children');
0358         if ~isempty(bb)
0359             for j=1:length(bb)
0360                 try
0361                     set(bb(j),'BackgroundColor',xc(scount,:))
0362                     scount=scount+1;
0363                 end
0364                 if strcmpi(get(bb(j),'type'),'uipanel')
0365                     cc=get(bb(j),'children');
0366                     if ~isempty(cc)
0367                         for k=1:length(cc)
0368                             try
0369                                 set(cc(k),'BackgroundColor',xc(scount,:))
0370                                 scount=scount+1;
0371                             end
0372                             if strcmpi(get(cc(k),'type'),'uipanel')
0373                                 dd=get(cc(k),'children');
0374                                 if ~isempty(dd)
0375                                     for l=1:length(dd)
0376                                         try
0377                                             set(dd(l),'BackgroundColor',xc(scount,:))
0378                                             scount=scount+1;
0379                                         end
0380                                     end
0381                                 end
0382                             end
0383                         end
0384                     end
0385                 end
0386             end
0387         end
0388     elseif ~strcmpi(get(aa(i),'type'),'uimenu')
0389         try
0390             set(aa(i),'BackgroundColor',xc(scount,:))
0391             scount=scount+1;
0392         end
0393     end
0394 end
0395 
0396 cd(wd)

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