Home > . > prt_ui_reviewCV.m

prt_ui_reviewCV

PURPOSE ^

PRT_UI_REVIEWCV M-file for prt_ui_reviewCV.fig

SYNOPSIS ^

function varargout = prt_ui_reviewCV(varargin)

DESCRIPTION ^

 PRT_UI_REVIEWCV M-file for prt_ui_reviewCV.fig
 
 PRT_UI_REVIEWCV, by itself, creates a new PRT_UI_REVIEWCV or raises the 
 existing singleton*.

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

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

 PRT_UI_REVIEWCV('Property','Value',...) creates a new PRT_UI_REVIEWCV or 
 raises the existing singleton*.  Starting from the left, property value 
 pairs are applied to the GUI before prt_ui_reviewCV_OpeningFcn gets 
 called.  An unrecognized property name or invalid value makes property 
 application stop.  All inputs are passed to prt_ui_reviewCV_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_reviewCV(varargin)
0002 % PRT_UI_REVIEWCV M-file for prt_ui_reviewCV.fig
0003 %
0004 % PRT_UI_REVIEWCV, by itself, creates a new PRT_UI_REVIEWCV or raises the
0005 % existing singleton*.
0006 %
0007 % H = PRT_UI_REVIEWCV returns the handle to a new PRT_UI_REVIEWCV or the
0008 % handle to the existing singleton*.
0009 %
0010 % PRT_UI_REVIEWCV('CALLBACK',hObject,eventData,handles,...) calls the local
0011 % function named CALLBACK in PRT_UI_REVIEWCV.M with the given input
0012 % arguments.
0013 %
0014 % PRT_UI_REVIEWCV('Property','Value',...) creates a new PRT_UI_REVIEWCV or
0015 % raises the existing singleton*.  Starting from the left, property value
0016 % pairs are applied to the GUI before prt_ui_reviewCV_OpeningFcn gets
0017 % called.  An unrecognized property name or invalid value makes property
0018 % application stop.  All inputs are passed to prt_ui_reviewCV_OpeningFcn
0019 % via varargin.
0020 %
0021 % *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
0022 % instance to run (singleton)".
0023 %
0024 % See also: GUIDE, GUIDATA, GUIHANDLES
0025 %__________________________________________________________________________
0026 % Copyright (C) 2011 Machine Learning & Neuroimaging Laboratory
0027 
0028 % Written by J. Schrouff
0029 % $Id: prt_ui_reviewCV.m 566 2012-08-07 15:22:50Z mjrosa $
0030 
0031 % Edit the above text to modify the response to help prt_ui_reviewCV
0032 
0033 % Last Modified by GUIDE v2.5 28-Mar-2012 15:59:56
0034 
0035 % Begin initialization code - DO NOT EDIT
0036 gui_Singleton = 1;
0037 gui_State = struct('gui_Name',       mfilename, ...
0038                    'gui_Singleton',  gui_Singleton, ...
0039                    'gui_OpeningFcn', @prt_ui_reviewCV_OpeningFcn, ...
0040                    'gui_OutputFcn',  @prt_ui_reviewCV_OutputFcn, ...
0041                    'gui_LayoutFcn',  [] , ...
0042                    'gui_Callback',   []);
0043 if nargin && ischar(varargin{1})
0044     gui_State.gui_Callback = str2func(varargin{1});
0045 end
0046 
0047 if nargout
0048     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0049 else
0050     gui_mainfcn(gui_State, varargin{:});
0051 end
0052 % End initialization code - DO NOT EDIT
0053 
0054 
0055 % --- Executes just before prt_ui_reviewCV is made visible.
0056 function prt_ui_reviewCV_OpeningFcn(hObject, eventdata, handles, varargin)
0057 % This function has no output args, see OutputFcn.
0058 % hObject    handle to figure
0059 % eventdata  reserved - to be defined in a future version of MATLAB
0060 % handles    structure with handles and user data (see GUIDATA)
0061 % varargin   command line arguments to prt_ui_reviewCV (see VARARGIN)
0062 
0063 % Choose default command line output for prt_ui_reviewCV
0064 handles.output = hObject;
0065 %if window already exists, just put it as the current figure
0066 Tag='CVrev';
0067 F = findall(allchild(0),'Flat','Tag',Tag);
0068 if length(F) > 1
0069     % Multiple Graphics windows - close all but most recent
0070     close(F(2:end))
0071     F = F(1);
0072     uistack(F,'top')
0073 elseif length(F)==1
0074     uistack(F,'top')
0075 else
0076     set(handles.figure1,'Tag',Tag)
0077     
0078 set(handles.figure1,'Name','PRoNTo :: Review Cross-Validation')
0079 %set size of the window, taking screen resolution and platform into account
0080 S0= spm('WinSize','0',1);   %-Screen size (of the current monitor)
0081 if ispc
0082     PF='MS Sans Serif';
0083 else
0084     PF= spm_platform('fonts');     %-Font names (for this platform)
0085     PF=PF.helvetica;
0086 end
0087 tmp  = [S0(3)/1280 (S0(4))/800];
0088 ratio=min(tmp)*[1 1 1 1];
0089 FS = 1 + 0.85*(min(ratio)-1);  %factor to scale the fonts
0090 x=get(handles.figure1,'Position');
0091 % set(handles.figure1,'DefaultTextFontSize',FS*12,...
0092 %     'DefaultUicontrolFontSize',FS*12,...
0093 %     'DefaultTextFontName',PF,...
0094 %     'DefaultAxesFontName',PF,...
0095 %     'DefaultUicontrolFontName',PF)
0096 set(handles.figure1,'Position',ratio.*x)
0097 set(handles.figure1,'Resize','on')
0098 
0099 color=prt_get_defaults('color');
0100 set(handles.figure1,'Color',color.bg1)
0101 aa=get(handles.figure1,'children');
0102 for i=1:length(aa)
0103     if strcmpi(get(aa(i),'type'),'uipanel')
0104         set(aa(i),'BackgroundColor',color.bg2)
0105         bb=get(aa(i),'children');
0106         if ~isempty(bb)
0107             for j=1:length(bb)
0108                 if ~isempty(find(strcmpi(get(bb(j),'Style'),{'text',...
0109                         'radiobutton','checkbox'}))) 
0110                     set(bb(j),'BackgroundColor',color.bg2)
0111                 elseif ~isempty(find(strcmpi(get(bb(j),'Style'),'pushbutton')))
0112                     set(bb(j),'BackgroundColor',color.fr)
0113                 end
0114                 set(bb(j),'FontUnits','pixel')
0115                 xf=get(bb(j),'FontSize');
0116                 set(bb(j),'FontSize',ceil(FS*xf),'FontName',PF,...
0117                     'FontUnits','normalized','Units','normalized')
0118             end
0119         end
0120     elseif strcmpi(get(aa(i),'type'),'uicontrol')
0121         if ~isempty(find(strcmpi(get(aa(i),'Style'),{'text',...
0122                 'radiobutton','checkbox'})))
0123             set(aa(i),'BackgroundColor',color.bg1)
0124         elseif ~isempty(find(strcmpi(get(aa(i),'Style'),'pushbutton')))
0125             set(aa(i),'BackgroundColor',color.fr)
0126         end
0127     end
0128     if ~strcmpi(get(aa(i),'type'),'uimenu')
0129         set(aa(i),'FontUnits','pixel')
0130         xf=get(aa(i),'FontSize');
0131         if ispc
0132             set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0133                 'FontUnits','normalized','Units','normalized')
0134         else
0135             set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0136                 'Units','normalized')
0137         end
0138     end
0139 end
0140 
0141 
0142 if ~isempty(varargin{1}) && strcmpi(varargin{1},'UserData')
0143     handles.PRT=varargin{2}{1};
0144     handles.indm=varargin{2}{2};
0145     handles.indf=varargin{2}{3};
0146     handles.prtdir=varargin{2}{4};
0147 else
0148     beep
0149     disp('The PRT, index of the model and index of feature set should be entered')
0150     return
0151 end
0152 end
0153 % Update handles structure
0154 guidata(hObject, handles);
0155 disp_cv(hObject,handles,handles.indm,handles.indf);
0156 
0157 
0158 
0159 % --- Outputs from this function are returned to the command line.
0160 function varargout = prt_ui_reviewCV_OutputFcn(hObject, eventdata, handles) 
0161 % varargout  cell array for returning output args (see VARARGOUT);
0162 % hObject    handle to figure
0163 % eventdata  reserved - to be defined in a future version of MATLAB
0164 % handles    structure with handles and user data (see GUIDATA)
0165 
0166 % Get default command line output from handles structure
0167 varargout{1} = handles.output;
0168 
0169 
0170 %--------------------------------------------------------------------------
0171 %-------------------------  Subfunctions ----------------------------------
0172 %--------------------------------------------------------------------------
0173 
0174 function disp_cv(hObject,handles,indm,indf)
0175 
0176 cla(handles.axes1)
0177 cla(handles.axes2)
0178 cla(handles.axes3)
0179 
0180 %Plot the id_mat in the left part of the window
0181 set(handles.figure1,'CurrentAxes',handles.axes1)
0182 dat=handles.PRT.fs(indf).id_mat(:,1:6);
0183 for i=1:6
0184     dat(:,i)=dat(:,i)./max(dat(:,i));
0185 end
0186 imagesc(dat);
0187 set(gca,'XTick',1:6)
0188 set(gca,'XTickLabel',{'Group','Subject','Modality','Condition','Block','Scans'},...
0189     'FontWeight','demi','FontSize',9);
0190 set(gca,'YTickLabel',{})
0191 colorbar('Location','WestOutside')
0192 set(get(gca,'Title'),'String','Feature set','FontWeight','bold')
0193 
0194 %Plot the CV matrix in the right part of the window
0195 set(handles.figure1,'CurrentAxes',handles.axes2)
0196 CV_mat_full=zeros(size(handles.PRT.fs(indf).id_mat,1),...
0197     size(handles.PRT.model(indm).input.cv_mat,2));
0198 xticksl=cell(1,size(handles.PRT.model(indm).input.cv_mat,2));
0199 for i=1:size(handles.PRT.model(indm).input.cv_mat,2)
0200     CV_mat_full(handles.PRT.model(indm).input.samp_idx,i)=handles.PRT.model(indm).input.cv_mat(:,i);
0201     xticksl{i}=num2str(i);
0202 end
0203 %inverting unused and test for colour purposes
0204 if max(max(CV_mat_full)-min(CV_mat_full))>1
0205     indun=find(CV_mat_full==0);
0206     indt=find(CV_mat_full==2);
0207     CV_mat_full(indun)=2;
0208     CV_mat_full(indt)=0;
0209 else
0210     indtr=find(CV_mat_full==1);
0211     indt=find(CV_mat_full==2);
0212     CV_mat_full(indtr)=2;
0213     CV_mat_full(indt)=1;
0214 end
0215 
0216 set(gca,'FontWeight','bold')
0217 xlabel('CV Folds','fontweight','demi')
0218 imagesc(CV_mat_full);
0219 set(gca,'XTick',1:i)
0220 set(gca,'YTickLabel',{})
0221 set(gca,'XTickLabel',xticksl,'FontWeight','demi','FontSize',9)
0222 colormap(gray)
0223 set(get(gca,'Title'),'String','Cross-Validation','FontWeight','bold')
0224 
0225 %Plot the 'legend' corresponding to the CV matrix in the right bottom part
0226 set(handles.figure1,'CurrentAxes',handles.axes3)
0227 if max(max(CV_mat_full)-min(CV_mat_full))>1
0228     leg=[0; 1; 2];
0229     imagesc(leg);
0230     set(gca,'YTick',[1,2,3])
0231     set(gca,'YTickLabel',{'Test','Train','Unused'});
0232 else
0233     leg=[1; 2];
0234     imagesc(leg);
0235     set(gca,'YTick',[1,2])
0236     set(gca,'YTickLabel',{'Test','Train'});
0237 end
0238 set(gca,'YAxisLocation','right')
0239 set(gca,'XTickLabel',{})
0240 
0241 % Update handles structure
0242 guidata(hObject, handles);
0243 
0244 
0245 % --------------------------------------------------------------------
0246 function savemenu_Callback(hObject, eventdata, handles)
0247 % hObject    handle to savemenu (see GCBO)
0248 % eventdata  reserved - to be defined in a future version of MATLAB
0249 % handles    structure with handles and user data (see GUIDATA)
0250 wd=cd;
0251 cd(handles.prtdir)
0252 modname=handles.PRT.model(handles.indm).model_name;
0253 [filename, pathname] = uiputfile( ...
0254 {'*.png','Portable Network Graphics (*.png)';...
0255  '*.jpeg','JPEG figure (*.jpeg)';...
0256  '*.tiff','Compressed TIFF figure (*.tiff)';... 
0257  '*.fig','Matlab figure (*.fig)';...
0258  '*.pdf','Color PDF file (*.pdf)';...
0259  '*.epsc',  'Encapsulated PostScript (*.eps)'},...
0260  'Save figure as',['Cross_Validation_',modname,'.png']);
0261 [a,b,c]=fileparts(filename);
0262 ext=['-d',c(2:end)];
0263 
0264 % Set the color of the different backgrounds and figure parameters to white
0265 cf=get(handles.figure1,'Color');
0266 set(handles.figure1,'Color',[1,1,1])
0267 aa=get(handles.figure1,'children');
0268 c=zeros(length(aa),3);
0269 cb=cell(length(aa));
0270 for i=1:length(aa)
0271     if strcmpi(get(aa(i),'type'),'uipanel')
0272         bb=get(aa(i),'children');
0273         cb{i}=zeros(length(bb),3);
0274         if ~isempty(bb)
0275             for j=1:length(bb)
0276                 try
0277                     cb{i}(j,:)=get(bb(j),'BackgroundColor');
0278                     set(bb(j),'BackgroundColor',[1 1 1]);
0279                 end
0280             end
0281         end
0282     end
0283     if ~strcmpi(get(aa(i),'type'),'uimenu')
0284         try
0285             c(i,:)=get(aa(i),'BackgroundColor');
0286             set(aa(i),'BackgroundColor',[1 1 1]);
0287         end
0288     end
0289 end
0290 
0291 print(handles.figure1,ext,[pathname,filesep,b],'-r500')
0292 
0293 % Set the color of the different backgrounds and figure parameters to white
0294 set(handles.figure1,'Color',cf)
0295 aa=get(handles.figure1,'children');
0296 for i=1:length(aa)
0297     if strcmpi(get(aa(i),'type'),'uipanel')
0298         bb=get(aa(i),'children');
0299         if ~isempty(bb)
0300             for j=1:length(bb)
0301                 set(bb(j),'BackgroundColor',cb{i}(j,:));
0302             end
0303         end
0304     end
0305     if ~strcmpi(get(aa(i),'type'),'uimenu')
0306         try
0307             set(aa(i),'BackgroundColor',c(i,:));
0308         end
0309     end
0310 end
0311 cd(wd)

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