0001 function varargout = prt_ui_reviewCV(varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
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
0053
0054
0055
0056 function prt_ui_reviewCV_OpeningFcn(hObject, eventdata, handles, varargin)
0057
0058
0059
0060
0061
0062
0063
0064 handles.output = hObject;
0065
0066 Tag='CVrev';
0067 F = findall(allchild(0),'Flat','Tag',Tag);
0068 if length(F) > 1
0069
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
0080 S0= spm('WinSize','0',1);
0081 if ispc
0082 PF='MS Sans Serif';
0083 else
0084 PF= spm_platform('fonts');
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);
0090 x=get(handles.figure1,'Position');
0091
0092
0093
0094
0095
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
0149 guidata(hObject, handles);
0150 disp_cv(hObject,handles,handles.indm,handles.indf);
0151
0152
0153
0154
0155 function varargout = prt_ui_reviewCV_OutputFcn(hObject, eventdata, handles)
0156
0157
0158
0159
0160
0161
0162 varargout{1} = handles.output;
0163
0164
0165
0166
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
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
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
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
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
0237 guidata(hObject, handles);
0238
0239
0240
0241 function savemenu_Callback(hObject, eventdata, handles)
0242
0243
0244
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
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
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)