Home > . > prt_ui_compute_weights.m

prt_ui_compute_weights

PURPOSE ^

PRT_UI_COMPUTE_WEIGHTS M-file for prt_ui_compute_weights.fig

SYNOPSIS ^

function varargout = prt_ui_compute_weights(varargin)

DESCRIPTION ^

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

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

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

 PRT_UI_COMPUTE_WEIGHTS('Property','Value',...) creates a new PRT_UI_COMPUTE_WEIGHTS
 or raises the existing singleton*.  Starting from the left, property 
 value pairs are applied to the GUI before prt_ui_compute_weights_OpeningFcn
 gets called.  An unrecognized property name or invalid value makes 
 property application stop.  All inputs are passed to prt_ui_compute_weights_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_compute_weights(varargin)
0002 % PRT_UI_COMPUTE_WEIGHTS M-file for prt_ui_compute_weights.fig
0003 %
0004 % PRT_UI_COMPUTE_WEIGHTS, by itself, creates a new PRT_UI_COMPUTE_WEIGHTS
0005 % or raises the existing singleton*.
0006 %
0007 % H = PRT_UI_COMPUTE_WEIGHTS returns the handle to a new PRT_UI_COMPUTE_WEIGHTS
0008 % or the handle to the existing singleton*.
0009 %
0010 % PRT_UI_COMPUTE_WEIGHTS('CALLBACK',hObject,eventData,handles,...) calls
0011 % the local function named CALLBACK in PRT_UI_COMPUTE_WEIGHTS.M with the
0012 % given input arguments.
0013 %
0014 % PRT_UI_COMPUTE_WEIGHTS('Property','Value',...) creates a new PRT_UI_COMPUTE_WEIGHTS
0015 % or raises the existing singleton*.  Starting from the left, property
0016 % value pairs are applied to the GUI before prt_ui_compute_weights_OpeningFcn
0017 % gets called.  An unrecognized property name or invalid value makes
0018 % property application stop.  All inputs are passed to prt_ui_compute_weights_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_compute_weights.m 523 2012-05-09 11:43:36Z jrichiar $
0030 
0031 % Edit the above text to modify the response to help prt_ui_compute_weights
0032 
0033 % Last Modified by GUIDE v2.5 07-Nov-2011 12:08:08
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_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 % End initialization code - DO NOT EDIT
0053 
0054 
0055 % --- Executes just before prt_ui_compute_weights is made visible.
0056 function prt_ui_compute_weights_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_compute_weights (see VARARGIN)
0062 
0063 % Choose default command line output for prt_ui_compute_weights
0064 handles.output = hObject;
0065 
0066 %if window already exists, just put it as the current figure
0067 Tag='weights';
0068 F = findall(allchild(0),'Flat','Tag',Tag);
0069 if length(F) > 1
0070     % Multiple Graphics windows - close all but most recent
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 %set size of the window, taking screen resolution and platform into account
0081 S0= spm('WinSize','0',1);   %-Screen size (of the current monitor)
0082 if ispc
0083     PF='MS Sans Serif';
0084 else
0085     PF= spm_platform('fonts');     %-Font names (for this platform)
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);  %factor to scale the fonts
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 % Update handles structure
0146 guidata(hObject, handles);
0147 
0148 % UIWAIT makes prt_ui_compute_weights 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_compute_weights_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 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 %fill the list of models
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 % Update handles structure
0214 guidata(hObject, handles);
0215 
0216 
0217 % --- Executes during object creation, after setting all properties.
0218 function edit_prt_CreateFcn(hObject, eventdata, handles)
0219 % hObject    handle to edit_prt (see GCBO)
0220 % eventdata  reserved - to be defined in a future version of MATLAB
0221 % handles    empty - handles not created until after all CreateFcns called
0222 
0223 % Hint: edit controls usually have a white background on Windows.
0224 %       See ISPC and COMPUTER.
0225 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0226     set(hObject,'BackgroundColor','white');
0227 end
0228 
0229 
0230 % --- Executes on button press in br_prt.
0231 function br_prt_Callback(hObject, eventdata, handles)
0232 % hObject    handle to br_prt (see GCBO)
0233 % eventdata  reserved - to be defined in a future version of MATLAB
0234 % handles    structure with handles and user data (see GUIDATA)
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 %fill the list of models
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 % Update handles structure
0268 guidata(hObject, handles);
0269 
0270 
0271 % --- Executes on selection change in pop_models.
0272 function pop_models_Callback(hObject, eventdata, handles)
0273 % hObject    handle to pop_models (see GCBO)
0274 % eventdata  reserved - to be defined in a future version of MATLAB
0275 % handles    structure with handles and user data (see GUIDATA)
0276 
0277 % Hints: contents = get(hObject,'String') returns pop_models contents as cell array
0278 %        contents{get(hObject,'Value')} returns selected item from pop_models
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 % Update handles structure
0287 guidata(hObject, handles);
0288 
0289 
0290 % --- Executes during object creation, after setting all properties.
0291 function pop_models_CreateFcn(hObject, eventdata, handles)
0292 % hObject    handle to pop_models (see GCBO)
0293 % eventdata  reserved - to be defined in a future version of MATLAB
0294 % handles    empty - handles not created until after all CreateFcns called
0295 
0296 % Hint: popupmenu controls usually have a white background on Windows.
0297 %       See ISPC and COMPUTER.
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 % hObject    handle to edit_imgname (see GCBO)
0304 % eventdata  reserved - to be defined in a future version of MATLAB
0305 % handles    structure with handles and user data (see GUIDATA)
0306 
0307 % Hints: get(hObject,'String') returns contents of edit_imgname as text
0308 %        str2double(get(hObject,'String')) returns contents of edit_imgname as a double
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 % Update handles structure
0317 guidata(hObject, handles);
0318 
0319 % --- Executes during object creation, after setting all properties.
0320 function edit_imgname_CreateFcn(hObject, eventdata, handles)
0321 % hObject    handle to edit_imgname (see GCBO)
0322 % eventdata  reserved - to be defined in a future version of MATLAB
0323 % handles    empty - handles not created until after all CreateFcns called
0324 
0325 % Hint: edit controls usually have a white background on Windows.
0326 %       See ISPC and COMPUTER.
0327 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0328     set(hObject,'BackgroundColor','white');
0329 end
0330 
0331 
0332 % --- Executes on button press in compbutt.
0333 function compbutt_Callback(hObject, eventdata, handles)
0334 % hObject    handle to compbutt (see GCBO)
0335 % eventdata  reserved - to be defined in a future version of MATLAB
0336 % handles    structure with handles and user data (see GUIDATA)
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;  %for the moment, coming soon
0341 prt_compute_weights(handles.dat,in)
0342 delete(handles.figure1)

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