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