Home > . > prt_ui_select_reg.m

prt_ui_select_reg

PURPOSE ^

PRT_UI_SELECT_REG M-file for prt_ui_select_reg.fig

SYNOPSIS ^

function varargout = prt_ui_select_reg(varargin)

DESCRIPTION ^

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

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

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

 PRT_UI_SELECT_REG('Property','Value',...) creates a new PRT_UI_SELECT_REG
 or raises the existing singleton*.  Starting from the left, property 
 value pairs are applied to the GUI before prt_ui_select_reg_OpeningFcn 
 gets called.  An unrecognized property name or invalid value makes 
 property application stop.  All inputs are passed to prt_ui_select_reg_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_select_reg(varargin)
0002 % PRT_UI_SELECT_REG M-file for prt_ui_select_reg.fig
0003 %
0004 % PRT_UI_SELECT_REG, by itself, creates a new PRT_UI_SELECT_REG or raises
0005 % the existing singleton*.
0006 %
0007 % H = PRT_UI_SELECT_REG returns the handle to a new PRT_UI_SELECT_REG or
0008 % the handle to the existing singleton*.
0009 %
0010 % PRT_UI_SELECT_REG('CALLBACK',hObject,eventData,handles,...) calls the
0011 % local function named CALLBACK in PRT_UI_SELECT_REG.M with the given input
0012 % arguments.
0013 %
0014 % PRT_UI_SELECT_REG('Property','Value',...) creates a new PRT_UI_SELECT_REG
0015 % or raises the existing singleton*.  Starting from the left, property
0016 % value pairs are applied to the GUI before prt_ui_select_reg_OpeningFcn
0017 % gets called.  An unrecognized property name or invalid value makes
0018 % property application stop.  All inputs are passed to prt_ui_select_reg_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_select_reg.m 523 2012-05-09 11:43:36Z jrichiar $
0030 
0031 % Edit the above text to modify the response to help prt_ui_select_reg
0032 
0033 % Last Modified by GUIDE v2.5 02-Nov-2011 17:45:41
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_select_reg_OpeningFcn, ...
0040                    'gui_OutputFcn',  @prt_ui_select_reg_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_select_reg is made visible.
0056 function prt_ui_select_reg_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_select_reg (see VARARGIN)
0062     
0063 set(handles.figure1,'Name','PRoNTo :: Specify subjects/scans to regress')
0064 %set size of the window, taking screen resolution and platform into account
0065 S0= spm('WinSize','0',1);   %-Screen size (of the current monitor)
0066 if ispc
0067     PF='MS Sans Serif';
0068 else
0069     PF= spm_platform('fonts');     %-Font names (for this platform)
0070     PF=PF.helvetica;
0071 end
0072 tmp  = [S0(3)/1280 (S0(4))/800];
0073 ratio=min(tmp)*[1 1 1 1];
0074 FS = 1 + 0.85*(min(ratio)-1);  %factor to scale the fonts
0075 x=get(handles.figure1,'Position');
0076 set(handles.figure1,'DefaultTextFontSize',FS*12,...
0077     'DefaultUicontrolFontSize',FS*12,...
0078     'DefaultTextFontName',PF,...
0079     'DefaultAxesFontName',PF,...
0080     'DefaultUicontrolFontName',PF)
0081 set(handles.figure1,'Position',ratio.*x)
0082 set(handles.figure1,'Resize','on')
0083 
0084 color=prt_get_defaults('color');
0085 set(handles.figure1,'Color',color.bg1)
0086 aa=get(handles.figure1,'children');
0087 for i=1:length(aa)
0088     if strcmpi(get(aa(i),'type'),'uipanel')
0089         set(aa(i),'BackgroundColor',color.bg2)
0090         bb=get(aa(i),'children');
0091         if ~isempty(bb)
0092             for j=1:length(bb)
0093                 if ~isempty(find(strcmpi(get(bb(j),'Style'),{'text',...
0094                         'radiobutton','checkbox'})))
0095                     set(bb(j),'BackgroundColor',color.bg2)
0096                 elseif ~isempty(find(strcmpi(get(bb(j),'Style'),'pushbutton')))
0097                     set(bb(j),'BackgroundColor',color.fr)
0098                 end
0099                 set(bb(j),'FontUnits','pixel')
0100                 xf=get(bb(j),'FontSize');
0101                 set(bb(j),'FontSize',ceil(FS*xf),'FontName',PF,...
0102                     'FontUnits','normalized','Units','normalized')
0103             end
0104         end
0105     elseif strcmpi(get(aa(i),'type'),'uicontrol')
0106         if ~isempty(find(strcmpi(get(aa(i),'Style'),{'text',...
0107                 'radiobutton','checkbox'})))
0108             set(aa(i),'BackgroundColor',color.bg1)
0109         elseif ~isempty(find(strcmpi(get(aa(i),'Style'),'pushbutton')))
0110             set(aa(i),'BackgroundColor',color.fr)
0111         end
0112     end
0113     set(aa(i),'FontUnits','pixel')
0114     xf=get(aa(i),'FontSize');
0115     if ispc
0116         set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0117             'FontUnits','normalized','Units','normalized')
0118     else
0119         set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0120             'Units','normalized')
0121     end
0122 end
0123 
0124 
0125 
0126 %get information from the PRT.mat
0127 if ~isempty(varargin) && strcmpi(varargin{1},'UserData')
0128     handles.dat=varargin{2}{1};
0129     %get names of groups
0130     list={handles.dat.group(:).gr_name};
0131     ng=length(list);
0132     set(handles.group_list,'String',list)
0133     set(handles.group_list,'Value',1)
0134     list={handles.dat.group(1).subject(:).subj_name};
0135     set(handles.uns_list,'String',list);
0136     set(handles.sel_list,'String',{});
0137     %get the subjects
0138     indfs=varargin{2}{2};
0139     handles.indfs=indfs;
0140     nm=length(handles.dat.fs(indfs).modality);
0141     handles.condm=cell(1,2);
0142     for i=1:nm
0143         handles.condm{1,1}=get(handles.group_list,'String');
0144         handles.condm{1,2}=cell(length(get(handles.group_list,'String')),1);
0145         for j=1:ng
0146             handles.condm{1,2}{j}={handles.dat.group(j).subject(:).subj_name};
0147         end
0148     end
0149     handles.clas{1,1}=1:length(handles.condm{1,1});
0150     handles.clas{1,2}=cell(length(handles.condm{1,1}),2);
0151     for j=1:length(get(handles.group_list,'String'))   
0152         handles.clas{1,2}{j,1}=1:length(handles.condm{1,2}{j});
0153         handles.clas{1,2}{j,2}=0;
0154     end
0155     cg=get(handles.group_list,'Value');
0156     list=handles.condm{1,2}{cg};
0157     %set subjects lists
0158     if handles.clas{1,2}{cg,1}~=0
0159         set(handles.uns_list,'Value',1);
0160         set(handles.uns_list,'String',list(handles.clas{1,2}{cg,1}));
0161     else
0162         set(handles.uns_list,'Value',0);
0163         set(handles.uns_list,'String',{});
0164     end
0165     if handles.clas{1,2}{cg,2}~=0
0166         set(handles.sel_list,'Value',1);
0167         set(handles.sel_list,'String',list(handles.clas{1,2}{cg,2}));
0168     else
0169         set(handles.sel_list,'Value',0);
0170         set(handles.sel_list,'String',{});
0171     end
0172 end
0173 % Update handles structure
0174 guidata(hObject, handles);
0175 
0176 % UIWAIT makes prt_ui_select_reg wait for user response (see UIRESUME)
0177 uiwait(handles.figure1);
0178 
0179 
0180 % --- Outputs from this function are returned to the command line.
0181 function varargout = prt_ui_select_reg_OutputFcn(hObject, eventdata, handles) 
0182 % varargout  cell array for returning output args (see VARARGOUT);
0183 % hObject    handle to figure
0184 % eventdata  reserved - to be defined in a future version of MATLAB
0185 % handles    structure with handles and user data (see GUIDATA)
0186 
0187 % Get default command line output from handles structure
0188 if isfield(handles,'output') && ~isempty(handles.output)
0189     varargout{1} = handles.output;
0190 else
0191     varargout{1}=[];
0192 end
0193 
0194 %This figure can be deleted now
0195 if isfield(handles,'figure1')
0196     delete(handles.figure1)
0197 end
0198 
0199 
0200 
0201 % --- Executes on selection change in group_list.
0202 function group_list_Callback(hObject, eventdata, handles)
0203 % hObject    handle to group_list (see GCBO)
0204 % eventdata  reserved - to be defined in a future version of MATLAB
0205 % handles    structure with handles and user data (see GUIDATA)
0206 
0207 % Hints: contents = get(hObject,'String') returns group_list contents as cell array
0208 %        contents{get(hObject,'Value')} returns selected item from group_list
0209 cl=1;
0210 cg=get(handles.group_list,'Value');
0211 list=handles.condm{1,2}{cg};
0212 %set subjects lists
0213 if handles.clas{cl,2}{cg,1}~=0
0214     set(handles.uns_list,'Value',1);
0215     set(handles.uns_list,'String',list(handles.clas{cl,2}{cg,1}));
0216 else
0217     set(handles.uns_list,'Value',0);
0218     set(handles.uns_list,'String',{});
0219 end
0220 if handles.clas{cl,2}{cg,2}~=0
0221     set(handles.sel_list,'Value',1);
0222     set(handles.sel_list,'String',list(handles.clas{cl,2}{cg,2}));
0223 else
0224     set(handles.sel_list,'Value',0);
0225     set(handles.sel_list,'String',{});
0226 end
0227 % Update handles structure
0228 guidata(hObject, handles);
0229 
0230 % --- Executes during object creation, after setting all properties.
0231 function group_list_CreateFcn(hObject, eventdata, handles)
0232 % hObject    handle to group_list (see GCBO)
0233 % eventdata  reserved - to be defined in a future version of MATLAB
0234 % handles    empty - handles not created until after all CreateFcns called
0235 
0236 % Hint: listbox controls usually have a white background on Windows.
0237 %       See ISPC and COMPUTER.
0238 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0239     set(hObject,'BackgroundColor','white');
0240 end
0241 
0242 % --- Executes on selection change in uns_list.
0243 function uns_list_Callback(hObject, eventdata, handles)
0244 % hObject    handle to uns_list (see GCBO)
0245 % eventdata  reserved - to be defined in a future version of MATLAB
0246 % handles    structure with handles and user data (see GUIDATA)
0247 
0248 % Hints: contents = get(hObject,'String') returns uns_list contents as cell array
0249 %        contents{get(hObject,'Value')} returns selected item from uns_list
0250 val=get(handles.uns_list,'Value');
0251 induns=1:length(get(handles.uns_list,'String'));
0252 indok=setdiff(induns,val);
0253 cl=1;
0254 cg=get(handles.group_list,'Value');
0255 if handles.clas{cl,2}{cg,2}==0
0256     handles.clas{cl,2}{cg,2}=handles.clas{cl,2}{cg,1}(val);
0257 else
0258     handles.clas{cl,2}{cg,2}=[handles.clas{cl,2}{cg,2}, handles.clas{cl,2}{cg,1}(val)];
0259 end
0260 if isempty(indok)
0261     handles.clas{cl,2}{cg,1}=0;
0262 else
0263     handles.clas{cl,2}{cg,1}=handles.clas{cl,2}{cg,1}(indok);
0264 end
0265 list=handles.condm{1,2}{cg};
0266 %set subjects lists
0267 if handles.clas{cl,2}{cg,1}~=0
0268     set(handles.uns_list,'Value',1);
0269     set(handles.uns_list,'String',list(handles.clas{cl,2}{cg,1}));
0270 else
0271     set(handles.uns_list,'Value',0);
0272     set(handles.uns_list,'String',{});
0273 end
0274 if handles.clas{cl,2}{cg,2}~=0
0275     set(handles.sel_list,'Value',1);
0276     set(handles.sel_list,'String',list(handles.clas{cl,2}{cg,2}));
0277 else
0278     set(handles.sel_list,'Value',0);
0279     set(handles.sel_list,'String',{});
0280 end
0281 
0282 % Update handles structure
0283 guidata(hObject, handles);
0284 
0285 % --- Executes during object creation, after setting all properties.
0286 function uns_list_CreateFcn(hObject, eventdata, handles)
0287 % hObject    handle to uns_list (see GCBO)
0288 % eventdata  reserved - to be defined in a future version of MATLAB
0289 % handles    empty - handles not created until after all CreateFcns called
0290 
0291 % Hint: listbox controls usually have a white background on Windows.
0292 %       See ISPC and COMPUTER.
0293 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0294     set(hObject,'BackgroundColor','white');
0295 end
0296 
0297 % --- Executes on selection change in sel_list.
0298 function sel_list_Callback(hObject, eventdata, handles)
0299 % hObject    handle to sel_list (see GCBO)
0300 % eventdata  reserved - to be defined in a future version of MATLAB
0301 % handles    structure with handles and user data (see GUIDATA)
0302 
0303 % Hints: contents = get(hObject,'String') returns sel_list contents as cell array
0304 %        contents{get(hObject,'Value')} returns selected item from sel_list
0305 val=get(handles.sel_list,'Value');
0306 indsel=1:length(get(handles.sel_list,'String'));
0307 indok=setdiff(indsel,val);
0308 cl=1;
0309 cg=get(handles.group_list,'Value');
0310 if handles.clas{cl,2}{cg,1}==0
0311     handles.clas{cl,2}{cg,1}=handles.clas{cl,2}{cg,2}(val);
0312 else
0313     handles.clas{cl,2}{cg,1}=[handles.clas{cl,2}{cg,1}, handles.clas{cl,2}{cg,2}(val)];
0314 end
0315 if isempty(indok)
0316     handles.clas{cl,2}{cg,2}=0;
0317 else
0318     handles.clas{cl,2}{cg,2}=handles.clas{cl,2}{cg,2}(indok);
0319 end
0320 list=handles.condm{1,2}{cg};
0321 %set subjects lists
0322 if handles.clas{cl,2}{cg,1}~=0
0323     set(handles.uns_list,'String',list(handles.clas{cl,2}{cg,1}));
0324     set(handles.uns_list,'Value',length(get(handles.uns_list,'String')));
0325 else
0326     set(handles.uns_list,'Value',0);
0327     set(handles.uns_list,'String',{});
0328 end
0329 if handles.clas{cl,2}{cg,2}~=0
0330     set(handles.sel_list,'String',list(handles.clas{cl,2}{cg,2}));
0331     set(handles.sel_list,'Value',length(get(handles.sel_list,'String')));
0332 else
0333     set(handles.sel_list,'Value',0);
0334     set(handles.sel_list,'String',{});
0335 end
0336 % Update handles structure
0337 guidata(hObject, handles);
0338 
0339 % --- Executes during object creation, after setting all properties.
0340 function sel_list_CreateFcn(hObject, eventdata, handles)
0341 % hObject    handle to sel_list (see GCBO)
0342 % eventdata  reserved - to be defined in a future version of MATLAB
0343 % handles    empty - handles not created until after all CreateFcns called
0344 
0345 % Hint: listbox controls usually have a white background on Windows.
0346 %       See ISPC and COMPUTER.
0347 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0348     set(hObject,'BackgroundColor','white');
0349 end
0350 
0351 
0352 % --- Executes on button press in sel_all.
0353 function sel_all_Callback(hObject, eventdata, handles)
0354 % hObject    handle to sel_all (see GCBO)
0355 % eventdata  reserved - to be defined in a future version of MATLAB
0356 % handles    structure with handles and user data (see GUIDATA)
0357 cl=1;
0358 cg=get(handles.group_list,'Value');
0359 list=handles.condm{1,2}{cg,1};
0360 indsel=1:length(list);
0361 handles.clas{cl,2}{cg,2}=indsel;
0362 handles.clas{cl,2}{cg,1}=0;
0363 set(handles.uns_list,'String',{});
0364 set(handles.uns_list,'Value',0);
0365 set(handles.sel_list,'String',list(handles.clas{cl,2}{cg,2}));
0366 set(handles.sel_list,'Value',length(get(handles.sel_list,'String')));
0367 % Update handles structure
0368 guidata(hObject, handles);
0369 
0370 
0371 
0372 
0373 % --- Executes on button press in done_button.
0374 function done_button_Callback(hObject, eventdata, handles)
0375 % hObject    handle to done_button (see GCBO)
0376 % eventdata  reserved - to be defined in a future version of MATLAB
0377 % handles    structure with handles and user data (see GUIDATA)
0378 
0379 flag=0;
0380 for i=1:size(handles.clas,1)
0381     list=get(handles.group_list,'String');
0382     for g=1:length(list)
0383         scount=1;
0384         g2=find(strcmpi(list{g},{handles.dat.group(:).gr_name}));
0385         sids=handles.clas{i,2}{g,2};
0386         handles.class(i).group(g2).gr_name=list{g};
0387         if ~isempty(sids) && any(sids)
0388             flag=1;
0389             for s=1:length(sids)
0390                 handles.class(i).group(g2).subj(scount).num=sids(s);
0391                 listm={handles.dat.fs(handles.indfs).modality(:).mod_name};
0392                 for m=1:length(listm)
0393                     handles.class(i).group(g2).subj(scount).modality(m).mod_name=listm{m};
0394                 end
0395                 scount=scount+1;
0396             end
0397         end
0398     end
0399     if ~flag  %for this class, no subjects were selected
0400         beep
0401         sprintf('No subjects found in the definition of the regression problem')
0402         disp('Please select subjects/scans')
0403         return
0404     end
0405 end
0406 handles.output=handles.class.group;
0407 % Update handles structure
0408 guidata(hObject, handles);
0409 
0410 uiresume(handles.figure1)

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