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$
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             set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0132                 'Units','normalized')
0133         end
0134     end
0135 
0136 
0137 if ~isempty(varargin{1}) && strcmpi(varargin{1},'UserData')
0138     handles.PRT=varargin{2}{1};
0139     handles.indm=varargin{2}{2};
0140     handles.indf=varargin{2}{3};
0141     handles.prtdir=varargin{2}{4};
0142 else
0143     beep
0144     disp('The PRT, index of the model and index of feature set should be entered')
0145     return
0146 end
0147 end
0148 % Update handles structure
0149 guidata(hObject, handles);
0150 disp_cv(hObject,handles,handles.indm,handles.indf);
0151 
0152 
0153 
0154 % --- Outputs from this function are returned to the command line.
0155 function varargout = prt_ui_reviewCV_OutputFcn(hObject, eventdata, handles) 
0156 % varargout  cell array for returning output args (see VARARGOUT);
0157 % hObject    handle to figure
0158 % eventdata  reserved - to be defined in a future version of MATLAB
0159 % handles    structure with handles and user data (see GUIDATA)
0160 
0161 % Get default command line output from handles structure
0162 varargout{1} = handles.output;
0163 
0164 
0165 %--------------------------------------------------------------------------
0166 %-------------------------  Subfunctions ----------------------------------
0167 %--------------------------------------------------------------------------
0168 
0169 function disp_cv(hObject,handles,indm,indf)
0170 
0171 cla(handles.axes1)
0172 cla(handles.axes2)
0173 cla(handles.axes3)
0174 
0175 %Plot the id_mat in the left part of the window
0176 set(handles.figure1,'CurrentAxes',handles.axes1)
0177 dat=handles.PRT.fs(indf).id_mat(:,1:6);
0178 for i=1:6
0179     dat(:,i)=dat(:,i)./max(dat(:,i));
0180 end
0181 imagesc(dat);
0182 set(gca,'XTick',1:6)
0183 set(gca,'XTickLabel',{'Group','Subject','Modality','Condition','Block','Scans'},...
0184     'FontWeight','demi','FontSize',9);
0185 set(gca,'YTickLabel',{})
0186 colorbar('Location','WestOutside')
0187 set(get(gca,'Title'),'String','Feature set','FontWeight','bold')
0188 
0189 %Plot the CV matrix in the right part of the window
0190 set(handles.figure1,'CurrentAxes',handles.axes2)
0191 CV_mat_full=zeros(size(handles.PRT.fs(indf).id_mat,1),...
0192     size(handles.PRT.model(indm).input.cv_mat,2));
0193 xticksl=cell(1,size(handles.PRT.model(indm).input.cv_mat,2));
0194 for i=1:size(handles.PRT.model(indm).input.cv_mat,2)
0195     CV_mat_full(handles.PRT.model(indm).input.samp_idx,i)=handles.PRT.model(indm).input.cv_mat(:,i);
0196     xticksl{i}=num2str(i);
0197 end
0198 %inverting unused and test for colour purposes
0199 if max(max(CV_mat_full)-min(CV_mat_full))>1
0200     indun=find(CV_mat_full==0);
0201     indt=find(CV_mat_full==2);
0202     CV_mat_full(indun)=2;
0203     CV_mat_full(indt)=0;
0204 else
0205     indtr=find(CV_mat_full==1);
0206     indt=find(CV_mat_full==2);
0207     CV_mat_full(indtr)=2;
0208     CV_mat_full(indt)=1;
0209 end
0210 
0211 set(gca,'FontWeight','bold')
0212 xlabel('CV Folds','fontweight','demi')
0213 imagesc(CV_mat_full);
0214 set(gca,'XTick',1:i)
0215 set(gca,'YTickLabel',{})
0216 set(gca,'XTickLabel',xticksl,'FontWeight','demi','FontSize',9)
0217 colormap(gray)
0218 set(get(gca,'Title'),'String','Cross-Validation','FontWeight','bold')
0219 
0220 %Plot the 'legend' corresponding to the CV matrix in the right bottom part
0221 set(handles.figure1,'CurrentAxes',handles.axes3)
0222 if max(max(CV_mat_full)-min(CV_mat_full))>1
0223     leg=[0; 1; 2];
0224     imagesc(leg);
0225     set(gca,'YTick',[1,2,3])
0226     set(gca,'YTickLabel',{'Test','Train','Unused'});
0227 else
0228     leg=[1; 2];
0229     imagesc(leg);
0230     set(gca,'YTick',[1,2])
0231     set(gca,'YTickLabel',{'Test','Train'});
0232 end
0233 set(gca,'YAxisLocation','right')
0234 set(gca,'XTickLabel',{})
0235 
0236 % Update handles structure
0237 guidata(hObject, handles);
0238 
0239 
0240 % --------------------------------------------------------------------
0241 function savemenu_Callback(hObject, eventdata, handles)
0242 % hObject    handle to savemenu (see GCBO)
0243 % eventdata  reserved - to be defined in a future version of MATLAB
0244 % handles    structure with handles and user data (see GUIDATA)
0245 wd=cd;
0246 cd(handles.prtdir)
0247 modname=handles.PRT.model(handles.indm).model_name;
0248 [filename, pathname] = uiputfile( ...
0249 {'*.png','Portable Network Graphics (*.png)';...
0250  '*.jpeg','JPEG figure (*.jpeg)';...
0251  '*.tiff','Compressed TIFF figure (*.tiff)';... 
0252  '*.fig','Matlab figure (*.fig)';...
0253  '*.pdf','Color PDF file (*.pdf)';...
0254  '*.epsc',  'Encapsulated PostScript (*.eps)'},...
0255  'Save figure as',['Cross_Validation_',modname,'.png']);
0256 [a,b,c]=fileparts(filename);
0257 ext=['-d',c(2:end)];
0258 
0259 % Set the color of the different backgrounds and figure parameters to white
0260 cf=get(handles.figure1,'Color');
0261 set(handles.figure1,'Color',[1,1,1])
0262 aa=get(handles.figure1,'children');
0263 c=zeros(length(aa),3);
0264 cb=cell(length(aa));
0265 for i=1:length(aa)
0266     if strcmpi(get(aa(i),'type'),'uipanel')
0267         bb=get(aa(i),'children');
0268         cb{i}=zeros(length(bb),3);
0269         if ~isempty(bb)
0270             for j=1:length(bb)
0271                 try
0272                     cb{i}(j,:)=get(bb(j),'BackgroundColor');
0273                     set(bb(j),'BackgroundColor',[1 1 1]);
0274                 end
0275             end
0276         end
0277     end
0278     if ~strcmpi(get(aa(i),'type'),'uimenu')
0279         try
0280             c(i,:)=get(aa(i),'BackgroundColor');
0281             set(aa(i),'BackgroundColor',[1 1 1]);
0282         end
0283     end
0284 end
0285 
0286 print(handles.figure1,ext,[pathname,filesep,b],'-r500')
0287 
0288 % Set the color of the different backgrounds and figure parameters to white
0289 set(handles.figure1,'Color',cf)
0290 aa=get(handles.figure1,'children');
0291 for i=1:length(aa)
0292     if strcmpi(get(aa(i),'type'),'uipanel')
0293         bb=get(aa(i),'children');
0294         if ~isempty(bb)
0295             for j=1:length(bb)
0296                 set(bb(j),'BackgroundColor',cb{i}(j,:));
0297             end
0298         end
0299     end
0300     if ~strcmpi(get(aa(i),'type'),'uimenu')
0301         try
0302             set(aa(i),'BackgroundColor',c(i,:));
0303         end
0304     end
0305 end
0306 cd(wd)

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