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$
0030 
0031 % Edit the above text to modify the response to help prt_ui_compute_weights
0032 
0033 % Last Modified by GUIDE v2.5 15-Apr-2014 11:57:20
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         set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0132             'Units','normalized')
0133     end
0134 
0135 
0136 set(handles.flag_cwi,'Value',0);
0137 set(handles.flag_cwi,'Visible','off');
0138 set(handles.flag_cwi,'Enable','off');
0139 handles.flag = 0;
0140 set(handles.compbutt,'Enable','off')
0141 handles.img_name=[];
0142 handles.flag2 = 0;
0143 handles.atl_name = [];
0144 set(handles.edit_atlas,'Enable','off')
0145 set(handles.br_atlas,'Enable','off')
0146 set(handles.build_ROI_flag2,'Value',0)
0147 end
0148 % Update handles structure
0149 guidata(hObject, handles);
0150 
0151 % UIWAIT makes prt_ui_compute_weights wait for user response (see UIRESUME)
0152 % uiwait(handles.figure1);
0153 
0154 
0155 % --- Outputs from this function are returned to the command line.
0156 function varargout = prt_ui_compute_weights_OutputFcn(hObject, eventdata, handles) 
0157 % varargout  cell array for returning output args (see VARARGOUT);
0158 % hObject    handle to figure
0159 % eventdata  reserved - to be defined in a future version of MATLAB
0160 % handles    structure with handles and user data (see GUIDATA)
0161 
0162 % Get default command line output from handles structure
0163 varargout{1} = handles.output;
0164 
0165 
0166 
0167 function edit_prt_Callback(hObject, eventdata, handles)
0168 % hObject    handle to edit_prt (see GCBO)
0169 % eventdata  reserved - to be defined in a future version of MATLAB
0170 % handles    structure with handles and user data (see GUIDATA)
0171 
0172 % Hints: get(hObject,'String') returns contents of edit_prt as text
0173 %        str2double(get(hObject,'String')) returns contents of edit_prt as a double
0174 handles.fname=get(handles.edit_prt,'String');
0175 handles.prtdir=fileparts(handles.fname);
0176 if exist('PRT','var')
0177     clear PRT
0178 end
0179 PRT=prt_load(handles.fname);
0180 if ~isempty(PRT)
0181     handles.dat=PRT;
0182 else
0183     beep
0184     disp('Could not load file')
0185     return
0186 end
0187 %fill the list of models
0188 if ~isfield(handles.dat,'model')
0189     beep
0190     disp('No model found in this PRT')
0191     disp('Please specify model first')
0192     delete(handles.figure1)
0193 end
0194 
0195 handles.indm=[];
0196 for m = 1:length(handles.dat.model)
0197     if isfield(handles.dat.model(m),'input') && ~isempty(handles.dat.model(m).input)
0198         if isfield(handles.dat.model(m),'output') && ~isempty(handles.dat.model(m).output)
0199             handles.indm=[handles.indm,m];
0200         end
0201     end
0202 end
0203 
0204 if isempty(handles.indm)
0205     beep
0206     disp('No model computed in this PRT')
0207     disp('Please specify AND run model before computing weights')
0208     return
0209 end
0210 
0211 list={handles.dat.model(:).model_name};
0212 set(handles.pop_models,'String',list(handles.indm))
0213 set(handles.pop_models,'Value',1)
0214 handles.selmod=handles.indm(1);
0215 set(handles.compbutt,'Enable','on')
0216 in = struct();
0217 im = handles.indm(1);
0218 in.fs_name = handles.dat.model(im).input.fs(1).fs_name;
0219 fid = prt_init_fs(handles.dat,in);
0220 if isfield(handles.dat.fs(fid),'atlas_name') && ...
0221         ~isempty(handles.dat.fs(fid).atlas_name) && ...
0222         ~isempty(strfind(handles.dat.model(im).input.machine.function,'MKL'))
0223     if iscell(handles.dat.fs(fid).atlas_name)
0224         set(handles.edit_atlas,'String',handles.dat.fs(fid).atlas_name{1});
0225     else
0226         set(handles.edit_atlas,'String',handles.dat.fs(fid).atlas_name);
0227     end
0228 else
0229     set(handles.edit_atlas,'String','Load atlas');
0230 end
0231 % Update handles structure
0232 guidata(hObject, handles);
0233 
0234 
0235 % --- Executes during object creation, after setting all properties.
0236 function edit_prt_CreateFcn(hObject, eventdata, handles)
0237 % hObject    handle to edit_prt (see GCBO)
0238 % eventdata  reserved - to be defined in a future version of MATLAB
0239 % handles    empty - handles not created until after all CreateFcns called
0240 
0241 % Hint: edit controls usually have a white background on Windows.
0242 %       See ISPC and COMPUTER.
0243 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0244     set(hObject,'BackgroundColor','white');
0245 end
0246 
0247 
0248 % --- Executes on button press in br_prt.
0249 function br_prt_Callback(hObject, eventdata, handles)
0250 % hObject    handle to br_prt (see GCBO)
0251 % eventdata  reserved - to be defined in a future version of MATLAB
0252 % handles    structure with handles and user data (see GUIDATA)
0253 handles.fname=spm_select(1,'.mat','Select PRT.mat',[],pwd,'PRT.mat');
0254 set(handles.edit_prt,'String',handles.fname)
0255 handles.prtdir=fileparts(handles.fname);
0256 if exist('PRT','var')
0257     clear PRT
0258 end
0259 PRT=prt_load(handles.fname);
0260 if ~isempty(PRT)
0261     handles.dat=PRT;
0262 else
0263     beep
0264     disp('Could not load file')
0265     return
0266 end
0267 %fill the list of models
0268 if ~isfield(handles.dat,'model')
0269     beep
0270     disp('No model found in this PRT')
0271     disp('Please specify model first')
0272     delete(handles.figure1)
0273 end
0274 handles.indm=[];
0275 for i=1:length(handles.dat.model)
0276     if ~isempty(handles.dat.model(i).output)
0277         handles.indm=[handles.indm,i];
0278     end
0279 end   
0280 list={handles.dat.model(:).model_name};
0281 set(handles.pop_models,'String',list(handles.indm))
0282 set(handles.pop_models,'Value',1)
0283 handles.selmod=handles.indm(1);
0284 set(handles.compbutt,'Enable','on')
0285 in = struct();
0286 im = handles.indm(1);
0287 in.fs_name = handles.dat.model(im).input.fs(1).fs_name;
0288 fid = prt_init_fs(handles.dat,in);
0289 if isfield(handles.dat.fs(fid),'atlas_name') && ...
0290         ~isempty(handles.dat.fs(fid).atlas_name) && ...
0291         ~isempty(strfind(handles.dat.model(im).input.machine.function,'MKL'))
0292     if iscell(handles.dat.fs(fid).atlas_name)
0293         set(handles.edit_atlas,'String',handles.dat.fs(fid).atlas_name{1});
0294     else
0295         set(handles.edit_atlas,'String',handles.dat.fs(fid).atlas_name);
0296     end
0297 else
0298     set(handles.edit_atlas,'String','Load atlas');
0299 end
0300 % Update handles structure
0301 guidata(hObject, handles);
0302 
0303 
0304 % --- Executes on selection change in pop_models.
0305 function pop_models_Callback(hObject, eventdata, handles)
0306 % hObject    handle to pop_models (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 pop_models contents as cell array
0311 %        contents{get(hObject,'Value')} returns selected item from pop_models
0312 val=get(handles.pop_models,'Value');
0313 if val==0
0314     warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0315     set(handles.pop_models,'Value',1)
0316     val=1;
0317 end
0318 in = struct();
0319 im = handles.indm(val);
0320 in.fs_name = handles.dat.model(im).input.fs(1).fs_name;
0321 fid = prt_init_fs(handles.dat,in);
0322 if isfield(handles.dat.fs(fid),'atlas_name') && ...
0323         ~isempty(handles.dat.fs(fid).atlas_name) && ...
0324         ~isempty(strfind(handles.dat.model(im).input.machine.function,'MKL'))
0325     if iscell(handles.dat.fs(fid).atlas_name)
0326         set(handles.edit_atlas,'String',handles.dat.fs(fid).atlas_name{1});
0327     else
0328         set(handles.edit_atlas,'String',handles.dat.fs(fid).atlas_name);
0329     end
0330 else
0331     set(handles.edit_atlas,'String','Load atlas');
0332 end
0333 im_name = ['weights_',handles.dat.model(im).model_name,'.img'];
0334 set(handles.edit_imgname,'String',im_name)
0335 handles.selmod=handles.indm(val);
0336 % Update handles structure
0337 guidata(hObject, handles);
0338 
0339 
0340 % --- Executes during object creation, after setting all properties.
0341 function pop_models_CreateFcn(hObject, eventdata, handles)
0342 % hObject    handle to pop_models (see GCBO)
0343 % eventdata  reserved - to be defined in a future version of MATLAB
0344 % handles    empty - handles not created until after all CreateFcns called
0345 
0346 % Hint: popupmenu controls usually have a white background on Windows.
0347 %       See ISPC and COMPUTER.
0348 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0349     set(hObject,'BackgroundColor','white');
0350 end
0351 
0352 function edit_imgname_Callback(hObject, eventdata, handles)
0353 % hObject    handle to edit_imgname (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 
0357 % Hints: get(hObject,'String') returns contents of edit_imgname as text
0358 %        str2double(get(hObject,'String')) returns contents of edit_imgname as a double
0359 handles.img_name=get(handles.edit_imgname,'String');
0360 if ~prt_checkAlphaNumUnder(handles.img_name)
0361     beep
0362     disp('Name of the image should be in alphanumeric format (no extension)')
0363     disp('Please correct')
0364     return
0365 end
0366 % Update handles structure
0367 guidata(hObject, handles);
0368 
0369 % --- Executes during object creation, after setting all properties.
0370 function edit_imgname_CreateFcn(hObject, eventdata, handles)
0371 % hObject    handle to edit_imgname (see GCBO)
0372 % eventdata  reserved - to be defined in a future version of MATLAB
0373 % handles    empty - handles not created until after all CreateFcns called
0374 
0375 % Hint: edit controls usually have a white background on Windows.
0376 %       See ISPC and COMPUTER.
0377 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0378     set(hObject,'BackgroundColor','white');
0379 end
0380 
0381 % --- Executes on button press in flag_cwi, build the weight images for
0382 % permutations flag
0383 function flag_cwi_Callback(hObject, eventdata, handles)
0384 % hObject    handle to flag_cwi (see GCBO)
0385 % eventdata  reserved - to be defined in a future version of MATLAB
0386 % handles    structure with handles and user data (see GUIDATA)
0387 
0388 % Hint: get(hObject,'Value') returns toggle state of flag_cwi
0389 flag=get(handles.flag_cwi,'Value');
0390 if flag
0391     handles.flag=1;
0392 else
0393     handles.flag=0;
0394 end
0395 guidata(hObject, handles);
0396 
0397 % --- Executes on button press in build_ROI_flag2.
0398 function build_ROI_flag2_Callback(hObject, eventdata, handles)
0399 % hObject    handle to build_ROI_flag2 (see GCBO)
0400 % eventdata  reserved - to be defined in a future version of MATLAB
0401 % handles    structure with handles and user data (see GUIDATA)
0402 
0403 % Hint: get(hObject,'Value') returns toggle state of build_ROI_flag2
0404 val = get(handles.build_ROI_flag2,'Value');
0405 if val
0406     handles.flag2 = 1;
0407     handles.atl_name = [];
0408     set(handles.edit_atlas,'Enable','on')
0409     set(handles.br_atlas,'Enable','on')
0410 else
0411     handles.flag2 = 0;
0412     handles.atl_name = [];
0413     set(handles.edit_atlas,'Enable','off')
0414     set(handles.br_atlas,'Enable','off')
0415 end
0416 guidata(hObject, handles);
0417 
0418 
0419 function edit_atlas_Callback(hObject, eventdata, handles)
0420 % hObject    handle to edit_atlas (see GCBO)
0421 % eventdata  reserved - to be defined in a future version of MATLAB
0422 % handles    structure with handles and user data (see GUIDATA)
0423 
0424 % Hints: get(hObject,'String') returns contents of edit_atlas as text
0425 %        str2double(get(hObject,'String')) returns contents of edit_atlas as a double
0426 handles.atl_name=get(handles.edit_atlas,'String');
0427 if ~prt_checkAlphaNumUnder(handles.atl_name)
0428     beep
0429     disp('Name of the atlas should be in alphanumeric format (no extension)')
0430     disp('Please correct')
0431     return
0432 end
0433 % Update handles structure
0434 guidata(hObject, handles);
0435 
0436 % --- Executes during object creation, after setting all properties.
0437 function edit_atlas_CreateFcn(hObject, eventdata, handles)
0438 % hObject    handle to edit_atlas (see GCBO)
0439 % eventdata  reserved - to be defined in a future version of MATLAB
0440 % handles    empty - handles not created until after all CreateFcns called
0441 
0442 % Hint: edit controls usually have a white background on Windows.
0443 %       See ISPC and COMPUTER.
0444 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0445     set(hObject,'BackgroundColor','white');
0446 end
0447 
0448 
0449 % --- Executes on button press in br_atlas.
0450 function br_atlas_Callback(hObject, eventdata, handles)
0451 % hObject    handle to br_atlas (see GCBO)
0452 % eventdata  reserved - to be defined in a future version of MATLAB
0453 % handles    structure with handles and user data (see GUIDATA)
0454 handles.atl_name=spm_select(1,'img','Select atlas to build weights per region',[],pwd,'.*');
0455 set(handles.edit_atlas,'String',handles.atl_name)
0456 % Update handles structure
0457 guidata(hObject, handles);
0458 
0459 % --- Executes on button press in compbutt.
0460 function compbutt_Callback(hObject, eventdata, handles)
0461 % hObject    handle to compbutt (see GCBO)
0462 % eventdata  reserved - to be defined in a future version of MATLAB
0463 % handles    structure with handles and user data (see GUIDATA)
0464 list={handles.dat.model(:).model_name};
0465 in.model_name=list{handles.selmod};
0466 in.pathdir=handles.prtdir;
0467 in.img_name=handles.img_name;  %for the moment, coming soon
0468 in.atl_name = handles.atl_name;
0469 prt_compute_weights(handles.dat,in,handles.flag,handles.flag2);
0470 delete(handles.figure1)

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