0001 function varargout = prt_ui_compute_weights(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_compute_weights_OpeningFcn, ...
0040 'gui_OutputFcn', @prt_ui_compute_weights_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_compute_weights_OpeningFcn(hObject, eventdata, handles, varargin)
0057
0058
0059
0060
0061
0062
0063
0064 handles.output = hObject;
0065
0066
0067 Tag='weights';
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 set(handles.figure1,'Name','PRoNTo :: Compute weights')
0080
0081 S0= spm('WinSize','0',1);
0082 if ispc
0083 PF='MS Sans Serif';
0084 else
0085 PF= spm_platform('fonts');
0086 PF=PF.helvetica;
0087 end
0088 tmp = [S0(3)/1280 (S0(4))/800];
0089 ratio=min(tmp)*[1 1 1 1];
0090 FS = 1 + 0.85*(min(ratio)-1);
0091 x=get(handles.figure1,'Position');
0092 set(handles.figure1,'DefaultTextFontSize',FS*12,...
0093 'DefaultUicontrolFontSize',FS*12,...
0094 'DefaultTextFontName',PF,...
0095 'DefaultAxesFontName',PF,...
0096 'DefaultUicontrolFontName',PF)
0097 set(handles.figure1,'Position',ratio.*x)
0098 set(handles.figure1,'Resize','on')
0099
0100 color=prt_get_defaults('color');
0101 set(handles.figure1,'Color',color.bg1)
0102 aa=get(handles.figure1,'children');
0103 for i=1:length(aa)
0104 if strcmpi(get(aa(i),'type'),'uipanel')
0105 set(aa(i),'BackgroundColor',color.bg2)
0106 bb=get(aa(i),'children');
0107 if ~isempty(bb)
0108 for j=1:length(bb)
0109 if ~isempty(find(strcmpi(get(bb(j),'Style'),{'text',...
0110 'radiobutton','checkbox'})))
0111 set(bb(j),'BackgroundColor',color.bg2)
0112 elseif ~isempty(find(strcmpi(get(bb(j),'Style'),'pushbutton')))
0113 set(bb(j),'BackgroundColor',color.fr)
0114 end
0115 set(bb(j),'FontUnits','pixel')
0116 xf=get(bb(j),'FontSize');
0117 set(bb(j),'FontSize',ceil(FS*xf),'FontName',PF,...
0118 'FontUnits','normalized','Units','normalized')
0119 end
0120 end
0121 elseif strcmpi(get(aa(i),'type'),'uicontrol')
0122 if ~isempty(find(strcmpi(get(aa(i),'Style'),{'text',...
0123 'radiobutton','checkbox'})))
0124 set(aa(i),'BackgroundColor',color.bg1)
0125 elseif ~isempty(find(strcmpi(get(aa(i),'Style'),'pushbutton')))
0126 set(aa(i),'BackgroundColor',color.fr)
0127 end
0128 end
0129 set(aa(i),'FontUnits','pixel')
0130 xf=get(aa(i),'FontSize');
0131 if ispc
0132 set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0133 'FontUnits','normalized','Units','normalized')
0134 else
0135 set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0136 'Units','normalized')
0137 end
0138 end
0139
0140
0141
0142 set(handles.compbutt,'Enable','off')
0143 handles.img_name=[];
0144 end
0145
0146 guidata(hObject, handles);
0147
0148
0149
0150
0151
0152
0153 function varargout = prt_ui_compute_weights_OutputFcn(hObject, eventdata, handles)
0154
0155
0156
0157
0158
0159
0160 varargout{1} = handles.output;
0161
0162
0163
0164 function edit_prt_Callback(hObject, eventdata, handles)
0165
0166
0167
0168
0169
0170
0171 handles.fname=get(handles.edit_prt,'String');
0172 handles.prtdir=fileparts(handles.fname);
0173 if exist('PRT','var')
0174 clear PRT
0175 end
0176 PRT=prt_load(handles.fname);
0177 if ~isempty(PRT)
0178 handles.dat=PRT;
0179 else
0180 beep
0181 disp('Could not load file')
0182 return
0183 end
0184
0185 if ~isfield(handles.dat,'model')
0186 beep
0187 disp('No model found in this PRT')
0188 disp('Please specify model first')
0189 delete(handles.figure1)
0190 end
0191
0192 handles.indm=[];
0193 for m = 1:length(handles.dat.model)
0194 if isfield(handles.dat.model(m),'input') && ~isempty(handles.dat.model(m).input)
0195 if isfield(handles.dat.model(m),'output') && ~isempty(handles.dat.model(m).output)
0196 handles.indm=[handles.indm,m];
0197 end
0198 end
0199 end
0200
0201 if isempty(handles.indm)
0202 beep
0203 disp('No model computed in this PRT')
0204 disp('Please specify AND run model before computing weights')
0205 return
0206 end
0207
0208 list={handles.dat.model(:).model_name};
0209 set(handles.pop_models,'String',list(handles.indm))
0210 set(handles.pop_models,'Value',1)
0211 handles.selmod=handles.indm(1);
0212 set(handles.compbutt,'Enable','on')
0213
0214 guidata(hObject, handles);
0215
0216
0217
0218 function edit_prt_CreateFcn(hObject, eventdata, handles)
0219
0220
0221
0222
0223
0224
0225 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0226 set(hObject,'BackgroundColor','white');
0227 end
0228
0229
0230
0231 function br_prt_Callback(hObject, eventdata, handles)
0232
0233
0234
0235 handles.fname=spm_select(1,'.mat','Select PRT.mat',[],pwd,'PRT.mat');
0236 set(handles.edit_prt,'String',handles.fname)
0237 handles.prtdir=fileparts(handles.fname);
0238 if exist('PRT','var')
0239 clear PRT
0240 end
0241 PRT=prt_load(handles.fname);
0242 if ~isempty(PRT)
0243 handles.dat=PRT;
0244 else
0245 beep
0246 disp('Could not load file')
0247 return
0248 end
0249
0250 if ~isfield(handles.dat,'model')
0251 beep
0252 disp('No model found in this PRT')
0253 disp('Please specify model first')
0254 delete(handles.figure1)
0255 end
0256 handles.indm=[];
0257 for i=1:length(handles.dat.model)
0258 if ~isempty(handles.dat.model(i).output)
0259 handles.indm=[handles.indm,i];
0260 end
0261 end
0262 list={handles.dat.model(:).model_name};
0263 set(handles.pop_models,'String',list(handles.indm))
0264 set(handles.pop_models,'Value',1)
0265 handles.selmod=handles.indm(1);
0266 set(handles.compbutt,'Enable','on')
0267
0268 guidata(hObject, handles);
0269
0270
0271
0272 function pop_models_Callback(hObject, eventdata, handles)
0273
0274
0275
0276
0277
0278
0279 val=get(handles.pop_models,'Value');
0280 if val==0
0281 warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0282 set(handles.pop_models,'Value',1)
0283 val=1;
0284 end
0285 handles.selmod=handles.indm(val);
0286
0287 guidata(hObject, handles);
0288
0289
0290
0291 function pop_models_CreateFcn(hObject, eventdata, handles)
0292
0293
0294
0295
0296
0297
0298 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0299 set(hObject,'BackgroundColor','white');
0300 end
0301
0302 function edit_imgname_Callback(hObject, eventdata, handles)
0303
0304
0305
0306
0307
0308
0309 handles.img_name=get(handles.edit_imgname,'String');
0310 if ~prt_checkAlphaNumUnder(handles.img_name)
0311 beep
0312 disp('Name of the image should be in alphanumeric format (no extension)')
0313 disp('Please correct')
0314 return
0315 end
0316
0317 guidata(hObject, handles);
0318
0319
0320 function edit_imgname_CreateFcn(hObject, eventdata, handles)
0321
0322
0323
0324
0325
0326
0327 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0328 set(hObject,'BackgroundColor','white');
0329 end
0330
0331
0332
0333 function compbutt_Callback(hObject, eventdata, handles)
0334
0335
0336
0337 list={handles.dat.model(:).model_name};
0338 in.model_name=list{handles.selmod};
0339 in.pathdir=handles.prtdir;
0340 in.img_name=handles.img_name;
0341 prt_compute_weights(handles.dat,in)
0342 delete(handles.figure1)