Home > . > prt_ui_specify_CV_basis.m

prt_ui_specify_CV_basis

PURPOSE ^

PRT_UI_SPECIFY_CV_BASIS M-file for prt_ui_specify_CV_basis.fig

SYNOPSIS ^

function varargout = prt_ui_specify_CV_basis(varargin)

DESCRIPTION ^

 PRT_UI_SPECIFY_CV_BASIS M-file for prt_ui_specify_CV_basis.fig
      PRT_UI_SPECIFY_CV_BASIS, by itself, creates a new PRT_UI_SPECIFY_CV_BASIS or raises the existing
      singleton*.

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

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

      PRT_UI_SPECIFY_CV_BASIS('Property','Value',...) creates a new PRT_UI_SPECIFY_CV_BASIS or raises the
      existing singleton*.  Starting from the left, property value pairs are
      applied to the GUI before prt_ui_specify_CV_basis_OpeningFcn gets called.  An
      unrecognized property name or invalid value makes property application
      stop.  All inputs are passed to prt_ui_specify_CV_basis_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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varargout = prt_ui_specify_CV_basis(varargin)
0002 % PRT_UI_SPECIFY_CV_BASIS M-file for prt_ui_specify_CV_basis.fig
0003 %      PRT_UI_SPECIFY_CV_BASIS, by itself, creates a new PRT_UI_SPECIFY_CV_BASIS or raises the existing
0004 %      singleton*.
0005 %
0006 %      H = PRT_UI_SPECIFY_CV_BASIS returns the handle to a new PRT_UI_SPECIFY_CV_BASIS or the handle to
0007 %      the existing singleton*.
0008 %
0009 %      PRT_UI_SPECIFY_CV_BASIS('CALLBACK',hObject,eventData,handles,...) calls the local
0010 %      function named CALLBACK in PRT_UI_SPECIFY_CV_BASIS.M with the given input arguments.
0011 %
0012 %      PRT_UI_SPECIFY_CV_BASIS('Property','Value',...) creates a new PRT_UI_SPECIFY_CV_BASIS or raises the
0013 %      existing singleton*.  Starting from the left, property value pairs are
0014 %      applied to the GUI before prt_ui_specify_CV_basis_OpeningFcn gets called.  An
0015 %      unrecognized property name or invalid value makes property application
0016 %      stop.  All inputs are passed to prt_ui_specify_CV_basis_OpeningFcn via varargin.
0017 %
0018 %      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
0019 %      instance to run (singleton)".
0020 %
0021 % See also: GUIDE, GUIDATA, GUIHANDLES
0022 
0023 % Edit the above text to modify the response to help prt_ui_specify_CV_basis
0024 
0025 % Last Modified by GUIDE v2.5 10-Jun-2013 11:50:53
0026 
0027 % Begin initialization code - DO NOT EDIT
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 % End initialization code - DO NOT EDIT
0045 
0046 
0047 % --- Executes just before prt_ui_specify_CV_basis is made visible.
0048 function prt_ui_specify_CV_basis_OpeningFcn(hObject, eventdata, handles, varargin)
0049 % This function has no output args, see OutputFcn.
0050 % hObject    handle to figure
0051 % eventdata  reserved - to be defined in a future version of MATLAB
0052 % handles    structure with handles and user data (see GUIDATA)
0053 % varargin   command line arguments to prt_ui_specify_CV_basis (see VARARGIN)
0054 set(handles.figure1,'Name','PRoNTo :: Specify CV')
0055 %set size of the window, taking screen resolution and platform into account
0056 S0= spm('WinSize','0',1);   %-Screen size (of the current monitor)
0057 if ispc
0058     PF='MS Sans Serif';
0059 else
0060     PF= spm_platform('fonts');     %-Font names (for this platform)
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);  %factor to scale the fonts
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; %inputs for call to prt_model
0119 
0120 %get useful info in one structure
0121 handles.legs=a.legs;
0122 handles.cv.type='custom';
0123 % Choose default command line output for prt_ui_specify_CV_basis
0124 handles.output = hObject;
0125 handles.flagdone=0;
0126 % Update handles structure
0127 guidata(hObject, handles);
0128 
0129 
0130 
0131 % --- Outputs from this function are returned to the command line.
0132 function varargout = prt_ui_specify_CV_basis_OutputFcn(hObject, eventdata, handles) 
0133 % varargout  cell array for returning output args (see VARARGOUT);
0134 % hObject    handle to figure
0135 % eventdata  reserved - to be defined in a future version of MATLAB
0136 % handles    structure with handles and user data (see GUIDATA)
0137 
0138 % Get default command line output from handles structure
0139 if isfield(handles,'output') && ~isempty(handles.output)
0140     varargout{1} = handles.output;
0141 else
0142     varargout{1}=[];
0143 end
0144 
0145 %This figure can be deleted now
0146 if isfield(handles,'figure1') && handles.flagdone
0147     delete(handles.figure1)
0148 end
0149 
0150 
0151 % --- Executes on button press in base.
0152 function base_Callback(hObject, eventdata, handles)
0153 % hObject    handle to base (see GCBO)
0154 % eventdata  reserved - to be defined in a future version of MATLAB
0155 % handles    structure with handles and user data (see GUIDATA)
0156 
0157 % Hint: get(hObject,'Value') returns toggle state of base
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; %by default, Leave-One-Out options
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'))        %currently implemented for MCKR only
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 % Update handles structure
0191 guidata(hObject, handles);
0192 
0193 % --- Executes on button press in specnum.
0194 function specnum_Callback(hObject, eventdata, handles)
0195 % hObject    handle to specnum (see GCBO)
0196 % eventdata  reserved - to be defined in a future version of MATLAB
0197 % handles    structure with handles and user data (see GUIDATA)
0198 
0199 % Hint: get(hObject,'Value') returns toggle state of specnum
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 % Update handles structure
0212 guidata(hObject, handles);
0213 
0214 % --- Executes on selection change in basepop.
0215 function basepop_Callback(hObject, eventdata, handles)
0216 % hObject    handle to basepop (see GCBO)
0217 % eventdata  reserved - to be defined in a future version of MATLAB
0218 % handles    structure with handles and user data (see GUIDATA)
0219 
0220 % Hints: contents = get(hObject,'String') returns basepop contents as cell array
0221 %        contents{get(hObject,'Value')} returns selected item from basepop
0222 val=get(handles.basepop,'Value');
0223 mach=get(handles.basepop,'String');
0224 handles.cv.k=0; %by default, Leave-One-Out options
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'))        %currently implemented for MCKR only
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 % Update handles structure
0244 guidata(hObject, handles);
0245 
0246 % --- Executes during object creation, after setting all properties.
0247 function basepop_CreateFcn(hObject, eventdata, handles)
0248 % hObject    handle to basepop (see GCBO)
0249 % eventdata  reserved - to be defined in a future version of MATLAB
0250 % handles    empty - handles not created until after all CreateFcns called
0251 
0252 % Hint: popupmenu controls usually have a white background on Windows.
0253 %       See ISPC and COMPUTER.
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 % hObject    handle to nfolds (see GCBO)
0262 % eventdata  reserved - to be defined in a future version of MATLAB
0263 % handles    structure with handles and user data (see GUIDATA)
0264 
0265 % Hints: get(hObject,'String') returns contents of nfolds as text
0266 %        str2double(get(hObject,'String')) returns contents of nfolds as a
0267 %        double
0268 handles.cv.k=str2double(get(handles.nfolds,'String'));
0269 % Update handles structure
0270 guidata(hObject, handles);
0271 
0272 
0273 % --- Executes during object creation, after setting all properties.
0274 function nfolds_CreateFcn(hObject, eventdata, handles)
0275 % hObject    handle to nfolds (see GCBO)
0276 % eventdata  reserved - to be defined in a future version of MATLAB
0277 % handles    empty - handles not created until after all CreateFcns called
0278 
0279 % Hint: edit controls usually have a white background on Windows.
0280 %       See ISPC and COMPUTER.
0281 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0282     set(hObject,'BackgroundColor','white');
0283 end
0284 
0285 
0286 % --- Executes on button press in load.
0287 function load_Callback(hObject, eventdata, handles)
0288 % hObject    handle to load (see GCBO)
0289 % eventdata  reserved - to be defined in a future version of MATLAB
0290 % handles    structure with handles and user data (see GUIDATA)
0291 
0292 % Hint: get(hObject,'Value') returns toggle state of load
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 % --- Executes on button press in br_load.
0304 function br_load_Callback(hObject, eventdata, handles)
0305 % hObject    handle to br_load (see GCBO)
0306 % eventdata  reserved - to be defined in a future version of MATLAB
0307 % handles    structure with handles and user data (see GUIDATA)
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 % Update handles structure
0312 guidata(hObject, handles);
0313 
0314 % --- Executes on button press in donebut.
0315 function donebut_Callback(hObject, eventdata, handles)
0316 % hObject    handle to donebut (see GCBO)
0317 % eventdata  reserved - to be defined in a future version of MATLAB
0318 % handles    structure with handles and user data (see GUIDATA)
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);

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