0001 function varargout = prt_ui_model(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_model_OpeningFcn, ...
0040 'gui_OutputFcn', @prt_ui_model_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_model_OpeningFcn(hObject, eventdata, handles, varargin)
0057
0058
0059
0060
0061
0062
0063
0064 handles.output = hObject;
0065
0066
0067 Tag='modelwin';
0068 F = findall(allchild(0),'Flat','Tag',Tag);
0069 if length(F) > 1
0070
0071 close(F(2:end))
0072 F = F(1);
0073 uistack(F,'top')
0074 elseif length(F)==1
0075 uistack(F,'top')
0076 else
0077 set(handles.figure1,'Tag',Tag)
0078
0079
0080 set(handles.figure1,'Name','PRoNTo :: Specify model')
0081
0082
0083 S0= spm('WinSize','0',1);
0084 if ispc
0085 PF='MS Sans Serif';
0086 else
0087 PF= spm_platform('fonts');
0088 PF=PF.helvetica;
0089 end
0090 tmp = [S0(3)/1280 (S0(4))/800];
0091 ratio=min(tmp)*[1 1 1 1];
0092 FS = 1 + 0.85*(min(ratio)-1);
0093 x=get(handles.figure1,'Position');
0094 set(handles.figure1,'DefaultTextFontSize',FS*12,...
0095 'DefaultUicontrolFontSize',FS*12,...
0096 'DefaultTextFontName',PF,...
0097 'DefaultAxesFontName',PF,...
0098 'DefaultUicontrolFontName',PF)
0099 set(handles.figure1,'Position',ratio.*x)
0100
0101 set(handles.figure1,'Resize','on')
0102
0103 color=prt_get_defaults('color');
0104 handles.color=color;
0105 set(handles.figure1,'Color',color.bg1)
0106 aa=get(handles.figure1,'children');
0107 for i=1:length(aa)
0108 if strcmpi(get(aa(i),'type'),'uipanel')
0109 set(aa(i),'BackgroundColor',color.bg2)
0110 bb=get(aa(i),'children');
0111 if ~isempty(bb)
0112 for j=1:length(bb)
0113 if ~isempty(find(strcmpi(get(bb(j),'Style'),{'text',...
0114 'radiobutton','checkbox'})))
0115 set(bb(j),'BackgroundColor',color.bg2)
0116 elseif ~isempty(find(strcmpi(get(bb(j),'Style'),'pushbutton')))
0117 set(bb(j),'BackgroundColor',color.fr)
0118 end
0119 set(bb(j),'FontUnits','pixel')
0120 xf=get(bb(j),'FontSize');
0121 set(bb(j),'FontSize',ceil(FS*xf),'FontName',PF,...
0122 'FontUnits','normalized','Units','normalized')
0123 end
0124 end
0125 elseif strcmpi(get(aa(i),'type'),'uicontrol')
0126 if ~isempty(find(strcmpi(get(aa(i),'Style'),{'text',...
0127 'radiobutton','checkbox'})))
0128 set(aa(i),'BackgroundColor',color.bg1)
0129 elseif ~isempty(find(strcmpi(get(aa(i),'Style'),'pushbutton')))
0130 set(aa(i),'BackgroundColor',color.fr)
0131 end
0132 end
0133 set(aa(i),'FontUnits','pixel')
0134 xf=get(aa(i),'FontSize');
0135 if ispc
0136 set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0137 'FontUnits','normalized','Units','normalized')
0138 else
0139 set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0140 'Units','normalized')
0141 end
0142 end
0143
0144
0145
0146
0147 handles.def=prt_get_defaults('model');
0148 set(handles.usekern,'Value',1)
0149 handles.use_kernel=1;
0150 set(handles.pop_cv,'String',{'Custom'})
0151 set(handles.pop_cv,'Value',1)
0152 handles.cv.type='custom';
0153 handles.cv.mat_file=[];
0154 set(handles.pop_reg,'String',{'Classification','Regression'})
0155 set(handles.pop_reg,'Value',1)
0156 handles.type='classification';
0157 set(handles.butt_defclass,'ForegroundColor',handles.color.high)
0158 set(handles.pop_machine,'String',{'Binary support vector machine',...
0159 'Binary Gaussian Process Classification','Random Forest',...
0160 'Multiclass GPC'})
0161 set(handles.pop_machine,'Value',1)
0162 handles.machine.function='prt_machine_svm_bin';
0163 handles.machine.args=handles.def.svmargs;
0164
0165
0166
0167
0168
0169
0170 list={'Sample averaging (within block)',...
0171 'Sample averaging (within subject/condition)',...
0172 'Mean centre features using training data',...
0173 'Divide data vectors by their norm'};
0174
0175 handles.indop{1}=1:length(list);
0176 handles.indop{2}=0;
0177 set(handles.uns_list,'String',list)
0178 set(handles.sel_list,'String',{''})
0179 handles.operations = [];
0180 handles.namop=list;
0181 set(handles.uns_list,'Value',1)
0182 set(handles.sel_list,'Value',1)
0183 end
0184
0185 guidata(hObject, handles);
0186
0187
0188
0189
0190
0191
0192 function varargout = prt_ui_model_OutputFcn(hObject, eventdata, handles)
0193
0194
0195
0196
0197
0198
0199 if isfield(handles,'output') && ~isempty(handles.output)
0200 varargout{1} = handles.output;
0201 else
0202 varargout{1}=[];
0203 end
0204
0205
0206
0207
0208
0209 function br_prt_Callback(hObject, eventdata, handles)
0210
0211
0212
0213 fname=spm_select(1,'.mat','Select PRT.mat',[],pwd,'PRT.mat');
0214 if exist('PRT','var')
0215 clear PRT
0216 end
0217 PRT=prt_load(fname);
0218 if ~isempty(PRT)
0219 handles.dat=PRT;
0220 set(handles.edit_prt,'String',fname);
0221 else
0222 beep
0223 disp('Could not load file')
0224 return
0225 end
0226
0227 if ~isfield(handles.dat,'fs')
0228 beep
0229 disp('No feature set found in the PRT.mat')
0230 disp('Please, prepare feature set before computing model')
0231 delete(handles.figure1)
0232 return
0233 end
0234 list={};
0235 for i=1:length(PRT.fs)
0236 if ~isempty(PRT.fs(i).fs_name)
0237 list=[list; {PRT.fs(i).fs_name}];
0238 end
0239 end
0240 set(handles.pop_featset,'String',list)
0241 set(handles.pop_featset,'Value',1)
0242 list=get(handles.pop_featset,'String');
0243 handles.fs(1).fs_name=list{1};
0244 handles.fs(1).indfs=1;
0245
0246
0247 guidata(hObject, handles);
0248
0249
0250
0251 function edit_prt_Callback(hObject, eventdata, handles)
0252
0253
0254
0255
0256
0257
0258 fname=get(handles.edit_prt,'String');
0259 if exist('PRT','var')
0260 clear PRT
0261 end
0262 PRT=prt_load(fname);
0263 if ~isempty(PRT)
0264 handles.dat=PRT;
0265 set(handles.edit_prt,'String',fname);
0266 else
0267 beep
0268 disp('Could not load file')
0269 return
0270 end
0271
0272 if ~isfield(handles.dat,'fs')
0273 beep
0274 disp('No feature set found in the PRT.mat')
0275 disp('Please, prepare feature set before computing model')
0276 delete(handles.figure1)
0277 return
0278 end
0279 list={};
0280 for i=1:length(PRT.fs)
0281 if ~isempty(PRT.fs(i).fs_name)
0282 list=[list; {PRT.fs(i).fs_name}];
0283 end
0284 end
0285 set(handles.pop_featset,'String',list)
0286 set(handles.pop_featset,'Value',1)
0287 list=get(handles.pop_featset,'String');
0288 handles.fs(1).fs_name=list{1};
0289 handles.fs(1).indfs=1;
0290
0291
0292 guidata(hObject, handles);
0293
0294
0295
0296 function edit_prt_CreateFcn(hObject, eventdata, handles)
0297
0298
0299
0300
0301
0302
0303 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0304 set(hObject,'BackgroundColor','white');
0305 end
0306
0307 function edit_modelname_Callback(hObject, eventdata, handles)
0308
0309
0310
0311
0312
0313
0314 handles.model_name=deblank(get(handles.edit_modelname,'String'));
0315 if ~(prt_checkAlphaNumUnder(handles.model_name))
0316 beep
0317 disp('Model name should be entered in alphanumeric format only')
0318 disp('Please correct')
0319 set(handles.edit_modelname,'ForegroundColor',[1,0,0])
0320 return
0321 else
0322 set(handles.edit_modelname,'ForegroundColor',[0,0,0])
0323 end
0324
0325 guidata(hObject, handles);
0326
0327
0328 function edit_modelname_CreateFcn(hObject, eventdata, handles)
0329
0330
0331
0332
0333
0334
0335 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0336 set(hObject,'BackgroundColor','white');
0337 end
0338
0339
0340 function pop_featset_Callback(hObject, eventdata, handles)
0341
0342
0343
0344
0345
0346
0347 val=get(handles.pop_featset,'Value');
0348 if val==0
0349 warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0350 set(handles.pop_feaset,'Value',1)
0351 val=1;
0352 end
0353 list=get(handles.pop_featset,'String');
0354 handles.fs(1).fs_name=list{val};
0355 handles.fs(1).indfs=val;
0356 if length(handles.dat.fs(val).modality)>1
0357 list=get(handles.pop_cv,'String');
0358 list=[list;{'Leave One Run/Session Out'}];
0359 set(handles.pop_cv,'String',list)
0360 set(handles.pop_cv,'Value',length(list))
0361 handles.cv.type = 'loro';
0362 end
0363
0364 guidata(hObject, handles);
0365
0366
0367 function pop_featset_CreateFcn(hObject, eventdata, handles)
0368
0369
0370
0371
0372
0373
0374 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0375 set(hObject,'BackgroundColor','white');
0376 end
0377
0378
0379
0380 function usekern_Callback(hObject, eventdata, handles)
0381
0382
0383
0384
0385
0386 handles.use_kernel=get(handles.usekern,'Value');
0387
0388 guidata(hObject, handles);
0389
0390
0391
0392 function pop_reg_Callback(hObject, eventdata, handles)
0393
0394
0395
0396
0397
0398
0399 val=get(handles.pop_reg,'Value');
0400 if val==0
0401 warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0402 set(handles.pop_reg,'Value',1)
0403 val=1;
0404 end
0405 if val==1
0406 handles.type='classification';
0407
0408 set(handles.pop_machine,'String',{'Binary support vector machine',...
0409 'Binary Gaussian Process Classification','Random Forest',...
0410 'Multiclass GPC'})
0411 set(handles.pop_machine,'Value',1)
0412 handles.machine.function='prt_machine_svm_bin';
0413 handles.machine.args=handles.def.svmargs;
0414 set(handles.butt_defclass,'String','Define classes')
0415 elseif val==2
0416 handles.type='regression';
0417 set(handles.butt_defclass,'String','Select subjects/scans')
0418
0419 set(handles.pop_machine,'String',{'Kernel Ridge Regression',...
0420 'Relevance Vector Regression','Gaussian Process Regression'})
0421 set(handles.pop_machine,'Value',1)
0422 handles.machine.function='prt_machine_krr';
0423 handles.machine.args=handles.def.krrargs;
0424 end
0425 set(handles.butt_defclass,'ForegroundColor',handles.color.high)
0426
0427 guidata(hObject, handles);
0428
0429
0430 function pop_reg_CreateFcn(hObject, eventdata, handles)
0431
0432
0433
0434
0435
0436
0437 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0438 set(hObject,'BackgroundColor','white');
0439 end
0440
0441
0442
0443
0444 function butt_defclass_Callback(hObject, eventdata, handles)
0445
0446
0447
0448 if strcmpi(handles.type,'classification')
0449 speccl=prt_ui_select_class('UserData',{handles.dat,handles.fs(1).indfs});
0450 handles.class=speccl.class;
0451 ns=zeros(length(speccl.class),1);
0452 for ii=1:length(speccl.class)
0453 for jj=1:length(speccl.class(ii).group)
0454 ns(ii)=ns(ii)+length(speccl.class(ii).group(jj).subj);
0455 end
0456 end
0457 if (speccl.design)
0458 list=get(handles.pop_cv,'String');
0459 list=[list;{'Leave One Block Out'}];
0460 set(handles.pop_cv,'String',list)
0461 set(handles.pop_cv,'Value',length(list))
0462 handles.cv.type = 'lobo';
0463 end
0464 handles.loospg=speccl.loospg;
0465 if min(ns)>1
0466 list=get(handles.pop_cv,'String');
0467 list=[list;{'Leave One Subject Out'}];
0468 set(handles.pop_cv,'String',list)
0469 set(handles.pop_cv,'Value',length(list))
0470 handles.cv.type = 'loso';
0471 list=get(handles.pop_cv,'String');
0472 list=[list;{'Leave One Subject per Group Out'}];
0473 set(handles.pop_cv,'String',list)
0474 set(handles.pop_cv,'Value',length(list))
0475 handles.cv.type = 'losgo';
0476 end
0477 else
0478 sel=prt_ui_select_reg('UserData',{handles.dat,handles.fs(1).indfs});
0479 handles.group=sel;
0480 n=0;
0481 for i=1:length(sel)
0482 n=n+length(sel(i).subj);
0483 end
0484 if n>1
0485 list=get(handles.pop_cv,'String');
0486 list=[list;{'Leave One Subject Out'}];
0487 set(handles.pop_cv,'String',list)
0488 set(handles.pop_cv,'Value',1)
0489 handles.cv.type = 'loso';
0490 end
0491 end
0492 set(handles.butt_defclass,'ForegroundColor',[0 0 0])
0493
0494 guidata(hObject, handles);
0495
0496
0497
0498 function pop_machine_Callback(hObject, eventdata, handles)
0499
0500
0501
0502
0503
0504
0505 mach=get(handles.pop_machine,'String');
0506 val=get(handles.pop_machine,'Value');
0507 if val==0
0508 warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0509 set(handles.pop_machine,'Value',1)
0510 val=1;
0511 end
0512 if any(strfind(mach{val},'support'))
0513 handles.machine.function='prt_machine_svm_bin';
0514 handles.machine.args=handles.def.svmargs;
0515 elseif any(strfind(mach{val},'Binary Gaussian'))
0516 handles.machine.function='prt_machine_gpml';
0517 handles.machine.args=handles.def.gpcargs;
0518 elseif any(strfind(mach{val},'Multiclass GPC'))
0519 handles.machine.function='prt_machine_gpclap';
0520 handles.machine.args=handles.def.gpclapargs;
0521 elseif any(strfind(mach{val},'Ridge'))
0522 handles.machine.function='prt_machine_krr';
0523 handles.machine.args=handles.def.krrargs;
0524 elseif any(strfind(mach{val},'Relevance'))
0525 handles.machine.function='prt_machine_rvr';
0526 handles.machine.args=[];
0527 elseif any(strfind(mach{val},'Process Regression'))
0528 handles.machine.function='prt_machine_gpr';
0529 handles.machine.args=handles.def.gprargs;
0530 elseif any(strfind(mach{val},'Random'))
0531 handles.machine.function='prt_machine_RT_bin';
0532 handles.machine.args=handles.def.rtargs;
0533 end
0534
0535 guidata(hObject, handles);
0536
0537
0538
0539 function pop_machine_CreateFcn(hObject, eventdata, handles)
0540
0541
0542
0543
0544
0545
0546 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0547 set(hObject,'BackgroundColor','white');
0548 end
0549
0550
0551 function pop_cv_Callback(hObject, eventdata, handles)
0552
0553
0554
0555
0556
0557
0558
0559 val=get(handles.pop_cv,'Value');
0560 mach=get(handles.pop_cv,'String');
0561 if val==0
0562 warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0563 set(handles.pop_cv,'Value',1)
0564 val=1;
0565 end
0566 if any(strfind(mach{val},'Subject Out'))
0567 handles.cv.type = 'loso';
0568 elseif any(strfind(mach{val},'Subject per Group'))
0569 if ~handles.loospg
0570 beep
0571 disp('Warning: Subjects are not balanced across classes!')
0572 end
0573 handles.cv.type = 'losgo';
0574 elseif any(strfind(mach{val},'Block'))
0575 handles.cv.type = 'lobo';
0576 elseif any(strfind(mach{val},'Run'))
0577 handles.cv.type = 'loro';
0578 else
0579 handles.cv.type = 'custom';
0580 cvmatf=spm_select(1,'mat','Select .mat file corresponding to the custom cross-validation');
0581 handles.cv.mat_file = cvmatf;
0582 end
0583
0584 guidata(hObject, handles);
0585
0586
0587 function pop_cv_CreateFcn(hObject, eventdata, handles)
0588
0589
0590
0591
0592
0593
0594 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0595 set(hObject,'BackgroundColor','white');
0596 end
0597
0598
0599 function uns_list_Callback(hObject, eventdata, handles)
0600
0601
0602
0603
0604
0605
0606 val=get(handles.uns_list,'Value');
0607 if val==0
0608 warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0609 set(handles.uns_list,'Value',1)
0610 val=1;
0611 end
0612
0613 ind=handles.indop{1}(val);
0614 handles.operations=[handles.operations, ind];
0615 handles.indop{1}=setdiff(handles.indop{1},ind);
0616 if isempty(handles.indop{1})
0617 handles.indop{1}=0;
0618 set(handles.uns_list,'String',{''})
0619 else
0620 set(handles.uns_list,'String',{handles.namop{handles.indop{1}}})
0621 end
0622 set(handles.uns_list,'Value',1)
0623 if handles.indop{2}==0
0624 handles.indop{2}=ind;
0625 else
0626 handles.indop{2}=[handles.indop{2},ind];
0627 end
0628 set(handles.sel_list,'String',{handles.namop{handles.indop{2}}})
0629 set(handles.sel_list,'Value',length(handles.indop{2}))
0630
0631 guidata(hObject, handles);
0632
0633
0634 function uns_list_CreateFcn(hObject, eventdata, handles)
0635
0636
0637
0638
0639
0640
0641 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0642 set(hObject,'BackgroundColor','white');
0643 end
0644
0645
0646
0647 function sel_list_Callback(hObject, eventdata, handles)
0648
0649
0650
0651
0652
0653
0654 val=get(handles.sel_list,'Value');
0655 if val==0
0656 warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0657 set(handles.sel_list,'Value',1)
0658 val=1;
0659 end
0660
0661 ind=handles.indop{2}(val);
0662 handles.operations=setdiff(handles.operations, ind);
0663 handles.indop{2}=setdiff(handles.indop{2},ind);
0664 if isempty(handles.indop{2})
0665 handles.indop{2}=0;
0666 set(handles.sel_list,'String',{''})
0667 else
0668 set(handles.sel_list,'String',{handles.namop{handles.indop{2}}})
0669 end
0670 set(handles.sel_list,'Value',1)
0671 if handles.indop{1}==0
0672 handles.indop{1}=ind;
0673 else
0674 handles.indop{1}=[handles.indop{1},ind];
0675 end
0676 set(handles.uns_list,'String',{handles.namop{handles.indop{1}}})
0677 set(handles.uns_list,'Value',length(handles.indop{1}))
0678
0679 guidata(hObject, handles);
0680
0681
0682 function sel_list_CreateFcn(hObject, eventdata, handles)
0683
0684
0685
0686
0687
0688
0689 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0690 set(hObject,'BackgroundColor','white');
0691 end
0692
0693
0694
0695
0696 function buildbutt_Callback(hObject, eventdata, handles)
0697
0698
0699
0700
0701
0702 in.fname=get(handles.edit_prt,'String');
0703 if ~isfield(handles,'model_name')
0704 beep
0705 disp('Please, provide a model name')
0706 return
0707 end
0708 if strcmpi(handles.cv.type,'custom') && isempty(handles.cv.mat_file)
0709 beep
0710 disp('Please, select a cross-validation or provide a custom matrix')
0711 return
0712 end
0713 in.model_name=handles.model_name;
0714 in.type=handles.type;
0715 in.machine=handles.machine;
0716 in.use_kernel=handles.use_kernel;
0717 in.operations=handles.operations;
0718 in.fs(1).fs_name=handles.fs(1).fs_name;
0719 in.cv=handles.cv;
0720
0721 if strcmpi(in.type,'classification')
0722 if ~isfield(handles,'class')
0723 beep
0724 disp('No class selected for classification')
0725 disp('Please, define classes')
0726 return
0727 else
0728 for i=1:length(handles.class)
0729 ind=[];
0730 for g=1:length(handles.class(i).group)
0731 if ~isempty(handles.class(i).group(g).gr_name)
0732 ind=[ind,g];
0733 end
0734 end
0735 handles.class(i).group=handles.class(i).group(ind);
0736 end
0737 in.class=handles.class;
0738 end
0739 else
0740 if ~isfield(handles,'group')
0741 beep
0742 disp('No subjects/scans selected for classification')
0743 disp('Please, select subjects/scans')
0744 return
0745 else
0746 ind=[];
0747 for g=1:length(handles.group)
0748 if ~isempty(handles.group(g).gr_name)
0749 ind=[ind,g];
0750 end
0751 end
0752 handles.group=handles.group(ind);
0753 in.group=handles.group;
0754 end
0755 end
0756
0757
0758 if strcmpi(in.cv.type,'lobo')
0759 if ~isfield(in,'class')
0760 beep
0761 disp('Leave One Block Out cross-validation only allowed for classification')
0762 disp('Please correct')
0763 return
0764 else
0765 for c=1:length(in.class)
0766 for i=1:length(in.class(c).group)
0767 if length(in.class(c).group(i).subj)>1
0768 beep
0769 disp('Leave One Block Out cross-validation only allowed for within-subject classification')
0770 disp('Please correct')
0771 return
0772 end
0773 end
0774 end
0775 end
0776 end
0777 if ~isfield(in,'class')
0778 if ~strcmpi(in.cv.type,'loso')
0779 beep
0780 disp('Regression only allows a Leave One Subject Out cross-validation')
0781 disp('Please correct')
0782 end
0783 end
0784 PRT=prt_model(handles.dat,in);
0785 clear in
0786 in.fname = get(handles.edit_prt,'String');
0787 in.model_name = handles.model_name;
0788 if exist('PRT','var')
0789 clear PRT
0790 end
0791 load(in.fname)
0792 mid = prt_init_model(PRT, in);
0793
0794 if strcmpi(PRT.model(mid).input.machine.function,'prt_machine_mckr')
0795 prt_cv_mckr(PRT,in);
0796 else
0797 prt_cv_model(PRT, in);
0798 end
0799 disp('Model specification and estimation complete.')
0800 disp('Done...')
0801 delete(handles.figure1)
0802
0803
0804
0805 function specbutt_Callback(hObject, eventdata, handles)
0806
0807
0808
0809
0810
0811 in.fname=get(handles.edit_prt,'String');
0812 if ~isfield(handles,'model_name')
0813 beep
0814 disp('Please enter a valid model name')
0815 end
0816 in.model_name=handles.model_name;
0817 in.type=handles.type;
0818 in.machine=handles.machine;
0819 in.use_kernel=handles.use_kernel;
0820 in.operations=handles.operations;
0821 in.fs(1).fs_name=handles.fs(1).fs_name;
0822 in.cv=handles.cv;
0823
0824 if strcmpi(in.type,'classification')
0825 if ~isfield(handles,'class')
0826 beep
0827 disp('No class selected for classification')
0828 disp('Please, define classes')
0829 return
0830 else
0831 for i=1:length(handles.class)
0832 ind=[];
0833 for g=1:length(handles.class(i).group)
0834 if ~isempty(handles.class(i).group(g).gr_name)
0835 ind=[ind,g];
0836 end
0837 end
0838 handles.class(i).group=handles.class(i).group(ind);
0839 end
0840 in.class=handles.class;
0841 end
0842 else
0843 if ~isfield(handles,'group')
0844 beep
0845 disp('No subjects/scans selected for classification')
0846 disp('Please, select subjects/scans')
0847 return
0848 else
0849 ind=[];
0850 for g=1:length(handles.group)
0851 if ~isempty(handles.group(g).gr_name)
0852 ind=[ind,g];
0853 end
0854 end
0855 handles.group=handles.group(ind);
0856 in.group=handles.group;
0857 end
0858 end
0859
0860
0861 if strcmpi(in.cv.type,'lobo')
0862 if ~isfield(in,'class')
0863 beep
0864 disp('Leave One Block Out cross-validation only allowed for classification')
0865 disp('Please correct')
0866 return
0867 else
0868 for c=1:length(in.class)
0869 for i=1:length(in.class(c).group)
0870 if length(in.class(c).group(i).subj)>1
0871 beep
0872 disp('Leave One Block Out cross-validation only allowed for within-subject classification')
0873 disp('Please correct')
0874 return
0875 end
0876 end
0877 end
0878 end
0879 end
0880 if ~isfield(in,'class')
0881 if ~strcmpi(in.cv.type,'loso')
0882 beep
0883 disp('Regression only allows a Leave One Subject Out cross-validation')
0884 disp('Please correct')
0885 end
0886 end
0887
0888 prt_model(handles.dat,in);
0889
0890 disp('Model specification complete.')
0891 disp('Done...')
0892 delete(handles.figure1)
0893