0001 function varargout = prt_ui_specify_CV_basis(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 gui_Singleton = 1;
0029 gui_State = struct('gui_Name', mfilename, ...
0030 'gui_Singleton', gui_Singleton, ...
0031 'gui_OpeningFcn', @prt_ui_specify_CV_basis_OpeningFcn, ...
0032 'gui_OutputFcn', @prt_ui_specify_CV_basis_OutputFcn, ...
0033 'gui_LayoutFcn', [] , ...
0034 'gui_Callback', []);
0035 if nargin && ischar(varargin{1})
0036 gui_State.gui_Callback = str2func(varargin{1});
0037 end
0038
0039 if nargout
0040 [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0041 else
0042 gui_mainfcn(gui_State, varargin{:});
0043 end
0044
0045
0046
0047
0048 function prt_ui_specify_CV_basis_OpeningFcn(hObject, eventdata, handles, varargin)
0049
0050
0051
0052
0053
0054 set(handles.figure1,'Name','PRoNTo :: Specify CV')
0055
0056 S0= spm('WinSize','0',1);
0057 if ispc
0058 PF='MS Sans Serif';
0059 else
0060 PF= spm_platform('fonts');
0061 PF=PF.helvetica;
0062 end
0063 tmp = [S0(3)/1280 (S0(4))/800];
0064 ratio=min(tmp)*[1 1 1 1];
0065 FS = 1 + 0.85*(min(ratio)-1);
0066 x=get(handles.figure1,'Position');
0067 set(handles.figure1,'DefaultTextFontSize',FS*12,...
0068 'DefaultUicontrolFontSize',FS*12,...
0069 'DefaultTextFontName',PF,...
0070 'DefaultAxesFontName',PF,...
0071 'DefaultUicontrolFontName',PF)
0072 set(handles.figure1,'Position',ratio.*x)
0073 set(handles.figure1,'Resize','on')
0074
0075 color=prt_get_defaults('color');
0076 set(handles.figure1,'Color',color.bg1)
0077 aa=get(handles.figure1,'children');
0078 for i=1:length(aa)
0079 if strcmpi(get(aa(i),'type'),'uipanel')
0080 set(aa(i),'BackgroundColor',color.bg2)
0081 bb=get(aa(i),'children');
0082 if ~isempty(bb)
0083 for j=1:length(bb)
0084 if ~isempty(find(strcmpi(get(bb(j),'Style'),{'text',...
0085 'radiobutton','checkbox'})))
0086 set(bb(j),'BackgroundColor',color.bg2)
0087 elseif ~isempty(find(strcmpi(get(bb(j),'Style'),'pushbutton')))
0088 set(bb(j),'BackgroundColor',color.fr)
0089 end
0090 set(bb(j),'FontUnits','pixel')
0091 xf=get(bb(j),'FontSize');
0092 set(bb(j),'FontSize',ceil(FS*xf),'FontName',PF,...
0093 'FontUnits','normalized','Units','normalized')
0094 end
0095 end
0096 elseif strcmpi(get(aa(i),'type'),'uicontrol')
0097 if ~isempty(find(strcmpi(get(aa(i),'Style'),{'text',...
0098 'radiobutton','checkbox'})))
0099 set(aa(i),'BackgroundColor',color.bg1)
0100 elseif ~isempty(find(strcmpi(get(aa(i),'Style'),'pushbutton')))
0101 set(aa(i),'BackgroundColor',color.fr)
0102 end
0103 end
0104 set(aa(i),'FontUnits','pixel')
0105 xf=get(aa(i),'FontSize');
0106 set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0107 'Units','normalized')
0108 end
0109
0110 a=varargin{1};
0111 cvlist=get(a.pop_cv,'String');
0112 set(handles.basepop,'String',cvlist(2:end))
0113 set(handles.basepop,'Value',1)
0114 set(handles.nfolds,'Enable','off')
0115 set(handles.basepop,'Enable','off')
0116 set(handles.br_load,'Enable','off')
0117 handles.prt=a.dat;
0118 handles.in=a.in;
0119
0120
0121 handles.legs=a.legs;
0122 handles.cv.type='custom';
0123
0124 handles.output = hObject;
0125 handles.flagdone=0;
0126
0127 guidata(hObject, handles);
0128
0129
0130
0131
0132 function varargout = prt_ui_specify_CV_basis_OutputFcn(hObject, eventdata, handles)
0133
0134
0135
0136
0137
0138
0139 if isfield(handles,'output') && ~isempty(handles.output)
0140 varargout{1} = handles.output;
0141 else
0142 varargout{1}=[];
0143 end
0144
0145
0146 if isfield(handles,'figure1') && handles.flagdone
0147 delete(handles.figure1)
0148 end
0149
0150
0151
0152 function base_Callback(hObject, eventdata, handles)
0153
0154
0155
0156
0157
0158 a=get(handles.base,'Value');
0159 if a
0160 set(handles.basepop,'Enable','on')
0161 handles.spectype=2;
0162 set(handles.specnum,'Value',0)
0163 set(handles.load,'Value',0)
0164 val=get(handles.basepop,'Value');
0165 mach=get(handles.basepop,'String');
0166 handles.cv.k=0;
0167 if val==0
0168 warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0169 set(handles.basepop,'Value',1)
0170 val=1;
0171 end
0172 if any(strfind(mach{val},'Subject Out'))
0173 handles.cv.type = 'loso';
0174 elseif any(strfind(mach{val},'Subject per Group'))
0175 handles.cv.type = 'losgo';
0176 elseif any(strfind(mach{val},'Block'))
0177 handles.cv.type = 'lobo';
0178 elseif any(strfind(mach{val},'Run'))
0179 handles.cv.type = 'loro';
0180 end
0181 if any(strfind(mach{val},'k-fold'))
0182 kt=prt_text_input('Title','Specify k, the number of folds');
0183 handles.cv.k=str2double(kt);
0184 end
0185 else
0186 set(handles.basepop,'Enable','off')
0187 set(handles.basepop,'Value',1)
0188 end
0189
0190
0191 guidata(hObject, handles);
0192
0193
0194 function specnum_Callback(hObject, eventdata, handles)
0195
0196
0197
0198
0199
0200 a=get(handles.specnum,'Value');
0201 if a
0202 set(handles.nfolds,'Enable','on')
0203 handles.spectype=3;
0204 set(handles.load,'Value',0)
0205 set(handles.base,'Value',0)
0206 else
0207 set(handles.nfolds,'Enable','off')
0208 set(handles.nfolds,'Value',0)
0209 end
0210
0211
0212 guidata(hObject, handles);
0213
0214
0215 function basepop_Callback(hObject, eventdata, handles)
0216
0217
0218
0219
0220
0221
0222 val=get(handles.basepop,'Value');
0223 mach=get(handles.basepop,'String');
0224 handles.cv.k=0;
0225 if val==0
0226 warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0227 set(handles.basepop,'Value',1)
0228 val=1;
0229 end
0230 if any(strfind(mach{val},'Subject Out'))
0231 handles.cv.type = 'loso';
0232 elseif any(strfind(mach{val},'Subject per Group'))
0233 handles.cv.type = 'losgo';
0234 elseif any(strfind(mach{val},'Block'))
0235 handles.cv.type = 'lobo';
0236 elseif any(strfind(mach{val},'Run'))
0237 handles.cv.type = 'loro';
0238 end
0239 if any(strfind(mach{val},'k-fold'))
0240 kt=prt_text_input('Title','Specify k, the number of folds');
0241 handles.cv.k=str2double(kt);
0242 end
0243
0244 guidata(hObject, handles);
0245
0246
0247 function basepop_CreateFcn(hObject, eventdata, handles)
0248
0249
0250
0251
0252
0253
0254 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0255 set(hObject,'BackgroundColor','white');
0256 end
0257
0258
0259
0260 function nfolds_Callback(hObject, eventdata, handles)
0261
0262
0263
0264
0265
0266
0267
0268 handles.cv.k=str2double(get(handles.nfolds,'String'));
0269
0270 guidata(hObject, handles);
0271
0272
0273
0274 function nfolds_CreateFcn(hObject, eventdata, handles)
0275
0276
0277
0278
0279
0280
0281 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0282 set(hObject,'BackgroundColor','white');
0283 end
0284
0285
0286
0287 function load_Callback(hObject, eventdata, handles)
0288
0289
0290
0291
0292
0293 a=get(handles.load,'Value');
0294 if a
0295 set(handles.br_load,'Enable','on')
0296 handles.spectype=1;
0297 set(handles.specnum,'Value',0)
0298 set(handles.base,'Value',0)
0299 else
0300 set(handles.br_load,'Enable','off')
0301 end
0302
0303
0304 function br_load_Callback(hObject, eventdata, handles)
0305
0306
0307
0308 cvmatf=spm_select(1,'mat','Select .mat file corresponding to the custom cross-validation');
0309 handles.cv.type='custom';
0310 handles.cv.mat_file = cvmatf;
0311
0312 guidata(hObject, handles);
0313
0314
0315 function donebut_Callback(hObject, eventdata, handles)
0316
0317
0318
0319 in=handles.in;
0320 in.cv.type=handles.cv.type;
0321 if isfield(handles.cv,'k')
0322 in.cv.k=handles.cv.k;
0323 else
0324 in.cv.k=0;
0325 end
0326 if isfield(handles.cv,'mat_file')
0327 in.cv.mat_file=handles.cv.mat_file;
0328 else
0329 in.cv.mat_file=[];
0330 end
0331 [d, CV, ID]=prt_model(handles.prt, in);
0332 handles.flagdone=1;
0333 delete(handles.figure1)
0334 prt_ui_custom_CV(CV,ID,in,handles.prt,handles.legs);