Home > . > prt_ui_cv_model.m

prt_ui_cv_model

PURPOSE ^

PRT_UI_CV_MODEL M-file for prt_ui_cv_model.fig

SYNOPSIS ^

function varargout = prt_ui_cv_model(varargin)

DESCRIPTION ^

 PRT_UI_CV_MODEL M-file for prt_ui_cv_model.fig

 PRT_UI_CV_MODEL, by itself, creates a new PRT_UI_CV_MODEL or raises the
 existing singleton*.

 H = PRT_UI_CV_MODEL returns the handle to a new PRT_UI_CV_MODEL or the
 handle to the existing singleton*.

 PRT_UI_CV_MODEL('CALLBACK',hObject,eventData,handles,...) calls the local
 function named CALLBACK in PRT_UI_CV_MODEL.M with the given input
 arguments.

 PRT_UI_CV_MODEL('Property','Value',...) creates a new PRT_UI_CV_MODEL or
 raises the existing singleton*.  Starting from the left, property value
 pairs are applied to the GUI before prt_ui_cv_model_OpeningFcn gets
 called. An unrecognized property name or invalid value makes property
 application stop.  All inputs are passed to prt_ui_cv_model_OpeningFcn
 via varargin.

 *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
  instance to run (singleton)".

 See also: GUIDE, GUIDATA, GUIHANDLES
__________________________________________________________________________
 Copyright (C) 2011 Machine Learning & Neuroimaging Laboratory

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varargout = prt_ui_cv_model(varargin)
0002 % PRT_UI_CV_MODEL M-file for prt_ui_cv_model.fig
0003 %
0004 % PRT_UI_CV_MODEL, by itself, creates a new PRT_UI_CV_MODEL or raises the
0005 % existing singleton*.
0006 %
0007 % H = PRT_UI_CV_MODEL returns the handle to a new PRT_UI_CV_MODEL or the
0008 % handle to the existing singleton*.
0009 %
0010 % PRT_UI_CV_MODEL('CALLBACK',hObject,eventData,handles,...) calls the local
0011 % function named CALLBACK in PRT_UI_CV_MODEL.M with the given input
0012 % arguments.
0013 %
0014 % PRT_UI_CV_MODEL('Property','Value',...) creates a new PRT_UI_CV_MODEL or
0015 % raises the existing singleton*.  Starting from the left, property value
0016 % pairs are applied to the GUI before prt_ui_cv_model_OpeningFcn gets
0017 % called. An unrecognized property name or invalid value makes property
0018 % application stop.  All inputs are passed to prt_ui_cv_model_OpeningFcn
0019 % via varargin.
0020 %
0021 % *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
0022 %  instance to run (singleton)".
0023 %
0024 % See also: GUIDE, GUIDATA, GUIHANDLES
0025 %__________________________________________________________________________
0026 % Copyright (C) 2011 Machine Learning & Neuroimaging Laboratory
0027 
0028 % Written by J.Schrouff
0029 % $Id$
0030 
0031 % Edit the above text to modify the response to help prt_ui_cv_model
0032 
0033 % Last Modified by GUIDE v2.5 04-Nov-2011 18:47:47
0034 
0035 % Begin initialization code - DO NOT EDIT
0036 gui_Singleton = 1;
0037 gui_State = struct('gui_Name',       mfilename, ...
0038     'gui_Singleton',  gui_Singleton, ...
0039     'gui_OpeningFcn', @prt_ui_cv_model_OpeningFcn, ...
0040     'gui_OutputFcn',  @prt_ui_cv_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 % End initialization code - DO NOT EDIT
0053 
0054 
0055 % --- Executes just before prt_ui_cv_model is made visible.
0056 function prt_ui_cv_model_OpeningFcn(hObject, eventdata, handles, varargin)
0057 % This function has no output args, see OutputFcn.
0058 % hObject    handle to figure
0059 % eventdata  reserved - to be defined in a future version of MATLAB
0060 % handles    structure with handles and user data (see GUIDATA)
0061 % varargin   command line arguments to prt_ui_cv_model (see VARARGIN)
0062 
0063 % Choose default command line output for prt_ui_cv_model
0064 handles.output = hObject;
0065 %if window already exists, just put it as the current figure
0066 Tag='model_run';
0067 F = findall(allchild(0),'Flat','Tag',Tag);
0068 if length(F) > 1
0069     % Multiple Graphics windows - close all but most recent
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 :: Run model')
0079     %set size of the window, taking screen resolution and platform into account
0080     S0= spm('WinSize','0',1);   %-Screen size (of the current monitor)
0081     if ispc
0082         PF='MS Sans Serif';
0083     else
0084         PF= spm_platform('fonts');     %-Font names (for this platform)
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);  %factor to scale the fonts
0090     x=get(handles.figure1,'Position');
0091     set(handles.figure1,'DefaultTextFontSize',FS*12,...
0092         'DefaultUicontrolFontSize',FS*12,...
0093         'DefaultTextFontName',PF,...
0094         'DefaultAxesFontName',PF,...
0095         'DefaultUicontrolFontName',PF)
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         set(aa(i),'FontUnits','pixel')
0129         xf=get(aa(i),'FontSize');
0130         set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0131             'Units','normalized')
0132     end
0133 
0134 
0135 set(handles.unslist,'Enable','off')
0136 set(handles.sellist,'Enable','off')
0137 set(handles.selallbutt,'Enable','off')
0138 set(handles.runbutt,'Enable','off')
0139 end
0140 % Update handles structure
0141 guidata(hObject, handles);
0142 
0143 % UIWAIT makes prt_ui_cv_model wait for user response (see UIRESUME)
0144 % uiwait(handles.figure1);
0145 
0146 
0147 % --- Outputs from this function are returned to the command line.
0148 function varargout = prt_ui_cv_model_OutputFcn(hObject, eventdata, handles) 
0149 % varargout  cell array for returning output args (see VARARGOUT);
0150 % hObject    handle to figure
0151 % eventdata  reserved - to be defined in a future version of MATLAB
0152 % handles    structure with handles and user data (see GUIDATA)
0153 
0154 % Get default command line output from handles structure
0155 varargout{1} = handles.output;
0156 
0157 
0158 
0159 function edit_prt_Callback(hObject, eventdata, handles)
0160 % hObject    handle to edit_prt (see GCBO)
0161 % eventdata  reserved - to be defined in a future version of MATLAB
0162 % handles    structure with handles and user data (see GUIDATA)
0163 
0164 % Hints: get(hObject,'String') returns contents of edit_prt as text
0165 %        str2double(get(hObject,'String')) returns contents of edit_prt as a double
0166 handles.fname=get(handles.edit_prt,'String');
0167 if exist('PRT','var')
0168     clear PRT
0169 end
0170 try
0171     load(handles.fname)
0172     handles.dat=PRT;
0173 catch
0174     beep
0175     disp('Could not load file')
0176     return
0177 end
0178 %fill the list of models
0179 if ~isfield(handles.dat,'model')
0180     beep
0181     disp('No model found in this PRT')
0182     disp('Please specify model first')
0183     delete(handles.figure1)
0184 end
0185 list={handles.dat.model(:).model_name};
0186 set(handles.unslist,'String',list)
0187 set(handles.sellist,'String',{''})
0188 handles.models=cell(1,2);
0189 handles.models{1}=1:length(list);
0190 handles.models{2}=[];
0191 set(handles.unslist,'Enable','on')
0192 set(handles.sellist,'Enable','on')
0193 set(handles.selallbutt,'Enable','on')
0194 
0195 % Update handles structure
0196 guidata(hObject, handles);
0197 
0198 
0199 % --- Executes during object creation, after setting all properties.
0200 function edit_prt_CreateFcn(hObject, eventdata, handles)
0201 % hObject    handle to edit_prt (see GCBO)
0202 % eventdata  reserved - to be defined in a future version of MATLAB
0203 % handles    empty - handles not created until after all CreateFcns called
0204 
0205 % Hint: edit controls usually have a white background on Windows.
0206 %       See ISPC and COMPUTER.
0207 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0208     set(hObject,'BackgroundColor','white');
0209 end
0210 
0211 
0212 % --- Executes on button press in br_prt.
0213 function br_prt_Callback(hObject, eventdata, handles)
0214 % hObject    handle to br_prt (see GCBO)
0215 % eventdata  reserved - to be defined in a future version of MATLAB
0216 % handles    structure with handles and user data (see GUIDATA)
0217 handles.fname=spm_select(1,'.mat','Select PRT.mat',[],pwd,'PRT.mat');
0218 set(handles.edit_prt,'String',handles.fname)
0219 if exist('PRT','var')
0220     clear PRT
0221 end
0222 try
0223     load(handles.fname)
0224     handles.dat=PRT;
0225 catch
0226     beep
0227     disp('Could not load file')
0228     return
0229 end
0230 %fill the list of models
0231 if ~isfield(handles.dat,'model')
0232     beep
0233     disp('No model found in this PRT')
0234     disp('Please specify model first')
0235     return
0236 end
0237 list={handles.dat.model(:).model_name};
0238 set(handles.unslist,'String',list)
0239 set(handles.sellist,'String',{''})
0240 handles.models=cell(1,2);
0241 handles.models{1}=1:length(list);
0242 handles.models{2}=0;
0243 set(handles.unslist,'Enable','on')
0244 set(handles.sellist,'Enable','on')
0245 set(handles.selallbutt,'Enable','on')
0246 
0247 % Update handles structure
0248 guidata(hObject, handles);
0249 
0250 
0251 % --- Executes on selection change in unslist.
0252 function unslist_Callback(hObject, eventdata, handles)
0253 % hObject    handle to unslist (see GCBO)
0254 % eventdata  reserved - to be defined in a future version of MATLAB
0255 % handles    structure with handles and user data (see GUIDATA)
0256 
0257 % Hints: contents = get(hObject,'String') returns unslist contents as cell array
0258 %        contents{get(hObject,'Value')} returns selected item from unslist
0259 val=get(handles.unslist,'Value');
0260 if ~any(handles.models{2})
0261     handles.models{2}=handles.models{1}(val);
0262 else
0263     handles.models{2}=[handles.models{2},handles.models{1}(val)];
0264 end
0265 indm=handles.models{1}(val);
0266 handles.models{1}=setxor(handles.models{1},indm);
0267 list={handles.dat.model(:).model_name};
0268 if isempty(handles.models{1})
0269     handles.models{1}=0;
0270     listu={''};
0271 else
0272     listu=list(handles.models{1});
0273 end
0274 if any(handles.models{2}==0)
0275     return
0276 end
0277 lists=list(handles.models{2});
0278 set(handles.unslist,'String',listu)
0279 set(handles.unslist,'Value',1)
0280 set(handles.sellist,'String',lists)
0281 set(handles.sellist,'Value',length(lists))
0282 set(handles.runbutt,'Enable','on')
0283 % Update handles structure
0284 guidata(hObject, handles);
0285 
0286 % --- Executes during object creation, after setting all properties.
0287 function unslist_CreateFcn(hObject, eventdata, handles)
0288 % hObject    handle to unslist (see GCBO)
0289 % eventdata  reserved - to be defined in a future version of MATLAB
0290 % handles    empty - handles not created until after all CreateFcns called
0291 
0292 % Hint: listbox controls usually have a white background on Windows.
0293 %       See ISPC and COMPUTER.
0294 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0295     set(hObject,'BackgroundColor','white');
0296 end
0297 
0298 
0299 % --- Executes on selection change in sellist.
0300 function sellist_Callback(hObject, eventdata, handles)
0301 % hObject    handle to sellist (see GCBO)
0302 % eventdata  reserved - to be defined in a future version of MATLAB
0303 % handles    structure with handles and user data (see GUIDATA)
0304 
0305 % Hints: contents = get(hObject,'String') returns sellist contents as cell array
0306 %        contents{get(hObject,'Value')} returns selected item from sellist
0307 val=get(handles.sellist,'Value');
0308 if ~any(handles.models{1})
0309     handles.models{1}=handles.models{2}(val);
0310 else
0311     handles.models{1}=[handles.models{1},handles.models{2}(val)];
0312 end
0313 indm=handles.models{2}(val);
0314 handles.models{2}=setxor(handles.models{2},indm);
0315 list={handles.dat.model(:).model_name};
0316 if isempty(handles.models{2})
0317     handles.models{2}=0;
0318     lists={''};
0319 else
0320     lists=list(handles.models{2});
0321 end
0322 if any(handles.models{1}==0)
0323     return
0324 end
0325 listu=list(handles.models{1});
0326 set(handles.unslist,'String',listu)
0327 set(handles.unslist,'Value',length(listu))
0328 set(handles.sellist,'String',lists)
0329 set(handles.sellist,'Value',1)
0330 % Update handles structure
0331 guidata(hObject, handles);
0332 
0333 % --- Executes during object creation, after setting all properties.
0334 function sellist_CreateFcn(hObject, eventdata, handles)
0335 % hObject    handle to sellist (see GCBO)
0336 % eventdata  reserved - to be defined in a future version of MATLAB
0337 % handles    empty - handles not created until after all CreateFcns called
0338 
0339 % Hint: listbox controls usually have a white background on Windows.
0340 %       See ISPC and COMPUTER.
0341 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0342     set(hObject,'BackgroundColor','white');
0343 end
0344 
0345 
0346 % --- Executes on button press in selallbutt.
0347 function selallbutt_Callback(hObject, eventdata, handles)
0348 % hObject    handle to selallbutt (see GCBO)
0349 % eventdata  reserved - to be defined in a future version of MATLAB
0350 % handles    structure with handles and user data (see GUIDATA)
0351 list={handles.dat.model(:).model_name};
0352 handles.models{1}=0;
0353 handles.models{2}=1:length(list);
0354 listu={''};
0355 lists=list(handles.models{2});
0356 set(handles.unslist,'String',listu)
0357 set(handles.unslist,'Value',1)
0358 set(handles.sellist,'String',lists)
0359 set(handles.sellist,'Value',1)
0360 set(handles.runbutt,'Enable','on')
0361 % Update handles structure
0362 guidata(hObject, handles);
0363 
0364 
0365 % --- Executes on button press in runbutt.
0366 function runbutt_Callback(hObject, eventdata, handles)
0367 % hObject    handle to runbutt (see GCBO)
0368 % eventdata  reserved - to be defined in a future version of MATLAB
0369 % handles    structure with handles and user data (see GUIDATA)
0370 if ~any(handles.models{2})
0371     beep
0372     disp('Select a model to run')
0373     return
0374 end
0375 PRT=handles.dat;
0376 list={PRT.model(:).model_name};
0377 for i=1:length(handles.models{2})
0378     in.fname      = handles.fname;
0379     in.model_name = list{handles.models{2}(i)};
0380     disp('--------------------------------------------------------')
0381     disp(['Running model ',char(in.model_name)])
0382     disp('--------------------------------------------------------')
0383     mid = prt_init_model(PRT, in);
0384     % Special cross-validation for MCKR
0385     if strcmp(PRT.model(mid).input.machine.function,'prt_machine_mckr')
0386         prt_cv_mckr(PRT,in);
0387     else
0388         prt_cv_model(PRT, in);
0389     end
0390     disp('--------------------------------------------------------')
0391     disp(['Model ',char(in.model_name),' run completed'])
0392     disp('--------------------------------------------------------')
0393     clear PRT
0394     load(handles.fname);
0395 end
0396 delete(handles.figure1)

Generated on Tue 10-Feb-2015 18:16:33 by m2html © 2005