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: prt_ui_cv_model.m 523 2012-05-09 11:43:36Z jrichiar $
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     if ispc
0131         set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0132             'FontUnits','normalized','Units','normalized')
0133     else
0134         set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0135             'Units','normalized')
0136     end
0137 end
0138 
0139 
0140 set(handles.unslist,'Enable','off')
0141 set(handles.sellist,'Enable','off')
0142 set(handles.selallbutt,'Enable','off')
0143 set(handles.runbutt,'Enable','off')
0144 end
0145 % Update handles structure
0146 guidata(hObject, handles);
0147 
0148 % UIWAIT makes prt_ui_cv_model wait for user response (see UIRESUME)
0149 % uiwait(handles.figure1);
0150 
0151 
0152 % --- Outputs from this function are returned to the command line.
0153 function varargout = prt_ui_cv_model_OutputFcn(hObject, eventdata, handles) 
0154 % varargout  cell array for returning output args (see VARARGOUT);
0155 % hObject    handle to figure
0156 % eventdata  reserved - to be defined in a future version of MATLAB
0157 % handles    structure with handles and user data (see GUIDATA)
0158 
0159 % Get default command line output from handles structure
0160 varargout{1} = handles.output;
0161 
0162 
0163 
0164 function edit_prt_Callback(hObject, eventdata, handles)
0165 % hObject    handle to edit_prt (see GCBO)
0166 % eventdata  reserved - to be defined in a future version of MATLAB
0167 % handles    structure with handles and user data (see GUIDATA)
0168 
0169 % Hints: get(hObject,'String') returns contents of edit_prt as text
0170 %        str2double(get(hObject,'String')) returns contents of edit_prt as a double
0171 handles.fname=get(handles.edit_prt,'String');
0172 if exist('PRT','var')
0173     clear PRT
0174 end
0175 try
0176     load(handles.fname)
0177     handles.dat=PRT;
0178 catch
0179     beep
0180     disp('Could not load file')
0181     return
0182 end
0183 %fill the list of models
0184 if ~isfield(handles.dat,'model')
0185     beep
0186     disp('No model found in this PRT')
0187     disp('Please specify model first')
0188     delete(handles.figure1)
0189 end
0190 list={handles.dat.model(:).model_name};
0191 set(handles.unslist,'String',list)
0192 set(handles.sellist,'String',{''})
0193 handles.models=cell(1,2);
0194 handles.models{1}=1:length(list);
0195 handles.models{2}=[];
0196 set(handles.unslist,'Enable','on')
0197 set(handles.sellist,'Enable','on')
0198 set(handles.selallbutt,'Enable','on')
0199 
0200 % Update handles structure
0201 guidata(hObject, handles);
0202 
0203 
0204 % --- Executes during object creation, after setting all properties.
0205 function edit_prt_CreateFcn(hObject, eventdata, handles)
0206 % hObject    handle to edit_prt (see GCBO)
0207 % eventdata  reserved - to be defined in a future version of MATLAB
0208 % handles    empty - handles not created until after all CreateFcns called
0209 
0210 % Hint: edit controls usually have a white background on Windows.
0211 %       See ISPC and COMPUTER.
0212 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0213     set(hObject,'BackgroundColor','white');
0214 end
0215 
0216 
0217 % --- Executes on button press in br_prt.
0218 function br_prt_Callback(hObject, eventdata, handles)
0219 % hObject    handle to br_prt (see GCBO)
0220 % eventdata  reserved - to be defined in a future version of MATLAB
0221 % handles    structure with handles and user data (see GUIDATA)
0222 handles.fname=spm_select(1,'.mat','Select PRT.mat',[],pwd,'PRT.mat');
0223 set(handles.edit_prt,'String',handles.fname)
0224 if exist('PRT','var')
0225     clear PRT
0226 end
0227 try
0228     load(handles.fname)
0229     handles.dat=PRT;
0230 catch
0231     beep
0232     disp('Could not load file')
0233     return
0234 end
0235 %fill the list of models
0236 if ~isfield(handles.dat,'model')
0237     beep
0238     disp('No model found in this PRT')
0239     disp('Please specify model first')
0240     return
0241 end
0242 list={handles.dat.model(:).model_name};
0243 set(handles.unslist,'String',list)
0244 set(handles.sellist,'String',{''})
0245 handles.models=cell(1,2);
0246 handles.models{1}=1:length(list);
0247 handles.models{2}=0;
0248 set(handles.unslist,'Enable','on')
0249 set(handles.sellist,'Enable','on')
0250 set(handles.selallbutt,'Enable','on')
0251 
0252 % Update handles structure
0253 guidata(hObject, handles);
0254 
0255 
0256 % --- Executes on selection change in unslist.
0257 function unslist_Callback(hObject, eventdata, handles)
0258 % hObject    handle to unslist (see GCBO)
0259 % eventdata  reserved - to be defined in a future version of MATLAB
0260 % handles    structure with handles and user data (see GUIDATA)
0261 
0262 % Hints: contents = get(hObject,'String') returns unslist contents as cell array
0263 %        contents{get(hObject,'Value')} returns selected item from unslist
0264 val=get(handles.unslist,'Value');
0265 if ~any(handles.models{2})
0266     handles.models{2}=handles.models{1}(val);
0267 else
0268     handles.models{2}=[handles.models{2},handles.models{1}(val)];
0269 end
0270 indm=handles.models{1}(val);
0271 handles.models{1}=setxor(handles.models{1},indm);
0272 list={handles.dat.model(:).model_name};
0273 if isempty(handles.models{1})
0274     handles.models{1}=0;
0275     listu={''};
0276 else
0277     listu=list(handles.models{1});
0278 end
0279 if any(handles.models{2}==0)
0280     return
0281 end
0282 lists=list(handles.models{2});
0283 set(handles.unslist,'String',listu)
0284 set(handles.unslist,'Value',1)
0285 set(handles.sellist,'String',lists)
0286 set(handles.sellist,'Value',length(lists))
0287 set(handles.runbutt,'Enable','on')
0288 % Update handles structure
0289 guidata(hObject, handles);
0290 
0291 % --- Executes during object creation, after setting all properties.
0292 function unslist_CreateFcn(hObject, eventdata, handles)
0293 % hObject    handle to unslist (see GCBO)
0294 % eventdata  reserved - to be defined in a future version of MATLAB
0295 % handles    empty - handles not created until after all CreateFcns called
0296 
0297 % Hint: listbox controls usually have a white background on Windows.
0298 %       See ISPC and COMPUTER.
0299 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0300     set(hObject,'BackgroundColor','white');
0301 end
0302 
0303 
0304 % --- Executes on selection change in sellist.
0305 function sellist_Callback(hObject, eventdata, handles)
0306 % hObject    handle to sellist (see GCBO)
0307 % eventdata  reserved - to be defined in a future version of MATLAB
0308 % handles    structure with handles and user data (see GUIDATA)
0309 
0310 % Hints: contents = get(hObject,'String') returns sellist contents as cell array
0311 %        contents{get(hObject,'Value')} returns selected item from sellist
0312 val=get(handles.sellist,'Value');
0313 if ~any(handles.models{1})
0314     handles.models{1}=handles.models{2}(val);
0315 else
0316     handles.models{1}=[handles.models{1},handles.models{2}(val)];
0317 end
0318 indm=handles.models{2}(val);
0319 handles.models{2}=setxor(handles.models{2},indm);
0320 list={handles.dat.model(:).model_name};
0321 if isempty(handles.models{2})
0322     handles.models{2}=0;
0323     lists={''};
0324 else
0325     lists=list(handles.models{2});
0326 end
0327 if any(handles.models{1}==0)
0328     return
0329 end
0330 listu=list(handles.models{1});
0331 set(handles.unslist,'String',listu)
0332 set(handles.unslist,'Value',length(listu))
0333 set(handles.sellist,'String',lists)
0334 set(handles.sellist,'Value',1)
0335 % Update handles structure
0336 guidata(hObject, handles);
0337 
0338 % --- Executes during object creation, after setting all properties.
0339 function sellist_CreateFcn(hObject, eventdata, handles)
0340 % hObject    handle to sellist (see GCBO)
0341 % eventdata  reserved - to be defined in a future version of MATLAB
0342 % handles    empty - handles not created until after all CreateFcns called
0343 
0344 % Hint: listbox controls usually have a white background on Windows.
0345 %       See ISPC and COMPUTER.
0346 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0347     set(hObject,'BackgroundColor','white');
0348 end
0349 
0350 
0351 % --- Executes on button press in selallbutt.
0352 function selallbutt_Callback(hObject, eventdata, handles)
0353 % hObject    handle to selallbutt (see GCBO)
0354 % eventdata  reserved - to be defined in a future version of MATLAB
0355 % handles    structure with handles and user data (see GUIDATA)
0356 list={handles.dat.model(:).model_name};
0357 handles.models{1}=0;
0358 handles.models{2}=1:length(list);
0359 listu={''};
0360 lists=list(handles.models{2});
0361 set(handles.unslist,'String',listu)
0362 set(handles.unslist,'Value',1)
0363 set(handles.sellist,'String',lists)
0364 set(handles.sellist,'Value',1)
0365 set(handles.runbutt,'Enable','on')
0366 % Update handles structure
0367 guidata(hObject, handles);
0368 
0369 
0370 % --- Executes on button press in runbutt.
0371 function runbutt_Callback(hObject, eventdata, handles)
0372 % hObject    handle to runbutt (see GCBO)
0373 % eventdata  reserved - to be defined in a future version of MATLAB
0374 % handles    structure with handles and user data (see GUIDATA)
0375 if ~any(handles.models{2})
0376     beep
0377     disp('Select a model to run')
0378     return
0379 end
0380 PRT=handles.dat;
0381 list={PRT.model(:).model_name};
0382 for i=1:length(handles.models{2})
0383     in.fname      = handles.fname;
0384     in.model_name = list{handles.models{2}(i)};
0385     disp('--------------------------------------------------------')
0386     disp(['Running model ',char(in.model_name)])
0387     disp('--------------------------------------------------------')
0388     mid = prt_init_model(PRT, in);
0389     % Special cross-validation for MCKR
0390     if strcmp(PRT.model(mid).input.machine.function,'prt_machine_mckr')
0391         prt_cv_mckr(PRT,in);
0392     else
0393         prt_cv_model(PRT, in);
0394     end
0395     disp('--------------------------------------------------------')
0396     disp(['Model ',char(in.model_name),' run completed'])
0397     disp('--------------------------------------------------------')
0398 end
0399 delete(handles.figure1)

Generated on Sun 20-May-2012 13:24:48 by m2html © 2005