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 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
0154 guidata(hObject, handles);
0155 disp_cv(hObject,handles,handles.indm,handles.indf);
0156
0157
0158
0159
0160 function varargout = prt_ui_reviewCV_OutputFcn(hObject, eventdata, handles)
0161
0162
0163
0164
0165
0166
0167 varargout{1} = handles.output;
0168
0169
0170
0171
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
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
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
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
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
0242 guidata(hObject, handles);
0243
0244
0245
0246 function savemenu_Callback(hObject, eventdata, handles)
0247
0248
0249
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
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
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)