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$
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     set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0116         'Units','normalized')
0117 end
0118 
0119 
0120 
0121 %get information from the PRT.mat
0122 if ~isempty(varargin) && strcmpi(varargin{1},'UserData')
0123     handles.dat=varargin{2}{1};
0124     %get names of groups
0125     list={handles.dat.group(:).gr_name};
0126     ng=length(list);
0127     set(handles.group_list,'String',list)
0128     set(handles.group_list,'Value',1)
0129     list={handles.dat.group(1).subject(:).subj_name};
0130     set(handles.uns_list,'String',list);
0131     set(handles.sel_list,'String',{});
0132     %get the subjects
0133     indfs=varargin{2}{2};
0134     handles.indfs=indfs;
0135     nm=length(handles.dat.fs(indfs).modality);
0136     handles.condm=cell(1,2);
0137     for i=1:nm
0138         handles.condm{1,1}=get(handles.group_list,'String');
0139         handles.condm{1,2}=cell(length(get(handles.group_list,'String')),1);
0140         for j=1:ng
0141             handles.condm{1,2}{j}={handles.dat.group(j).subject(:).subj_name};
0142         end
0143     end
0144     handles.clas{1,1}=1:length(handles.condm{1,1});
0145     handles.clas{1,2}=cell(length(handles.condm{1,1}),2);
0146     for j=1:length(get(handles.group_list,'String'))   
0147         handles.clas{1,2}{j,1}=1:length(handles.condm{1,2}{j});
0148         handles.clas{1,2}{j,2}=0;
0149     end
0150     cg=get(handles.group_list,'Value');
0151     list=handles.condm{1,2}{cg};
0152     %set subjects lists
0153     if handles.clas{1,2}{cg,1}~=0
0154         set(handles.uns_list,'Value',1);
0155         set(handles.uns_list,'String',list(handles.clas{1,2}{cg,1}));
0156     else
0157         set(handles.uns_list,'Value',0);
0158         set(handles.uns_list,'String',{});
0159     end
0160     if handles.clas{1,2}{cg,2}~=0
0161         set(handles.sel_list,'Value',1);
0162         set(handles.sel_list,'String',list(handles.clas{1,2}{cg,2}));
0163     else
0164         set(handles.sel_list,'Value',0);
0165         set(handles.sel_list,'String',{});
0166     end
0167 end
0168 % Update handles structure
0169 guidata(hObject, handles);
0170 
0171 % UIWAIT makes prt_ui_select_reg wait for user response (see UIRESUME)
0172 uiwait(handles.figure1);
0173 
0174 
0175 % --- Outputs from this function are returned to the command line.
0176 function varargout = prt_ui_select_reg_OutputFcn(hObject, eventdata, handles) 
0177 % varargout  cell array for returning output args (see VARARGOUT);
0178 % hObject    handle to figure
0179 % eventdata  reserved - to be defined in a future version of MATLAB
0180 % handles    structure with handles and user data (see GUIDATA)
0181 
0182 % Get default command line output from handles structure
0183 if isfield(handles,'output') && ~isempty(handles.output)
0184     varargout{1} = handles.output;
0185 else
0186     varargout{1}=[];
0187 end
0188 
0189 %This figure can be deleted now
0190 if isfield(handles,'figure1')
0191     delete(handles.figure1)
0192 end
0193 
0194 
0195 
0196 % --- Executes on selection change in group_list.
0197 function group_list_Callback(hObject, eventdata, handles)
0198 % hObject    handle to group_list (see GCBO)
0199 % eventdata  reserved - to be defined in a future version of MATLAB
0200 % handles    structure with handles and user data (see GUIDATA)
0201 
0202 % Hints: contents = get(hObject,'String') returns group_list contents as cell array
0203 %        contents{get(hObject,'Value')} returns selected item from group_list
0204 cl=1;
0205 cg=get(handles.group_list,'Value');
0206 list=handles.condm{1,2}{cg};
0207 %set subjects lists
0208 if handles.clas{cl,2}{cg,1}~=0
0209     set(handles.uns_list,'Value',1);
0210     set(handles.uns_list,'String',list(handles.clas{cl,2}{cg,1}));
0211 else
0212     set(handles.uns_list,'Value',0);
0213     set(handles.uns_list,'String',{});
0214 end
0215 if handles.clas{cl,2}{cg,2}~=0
0216     set(handles.sel_list,'Value',1);
0217     set(handles.sel_list,'String',list(handles.clas{cl,2}{cg,2}));
0218 else
0219     set(handles.sel_list,'Value',0);
0220     set(handles.sel_list,'String',{});
0221 end
0222 % Update handles structure
0223 guidata(hObject, handles);
0224 
0225 % --- Executes during object creation, after setting all properties.
0226 function group_list_CreateFcn(hObject, eventdata, handles)
0227 % hObject    handle to group_list (see GCBO)
0228 % eventdata  reserved - to be defined in a future version of MATLAB
0229 % handles    empty - handles not created until after all CreateFcns called
0230 
0231 % Hint: listbox controls usually have a white background on Windows.
0232 %       See ISPC and COMPUTER.
0233 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0234     set(hObject,'BackgroundColor','white');
0235 end
0236 
0237 % --- Executes on selection change in uns_list.
0238 function uns_list_Callback(hObject, eventdata, handles)
0239 % hObject    handle to uns_list (see GCBO)
0240 % eventdata  reserved - to be defined in a future version of MATLAB
0241 % handles    structure with handles and user data (see GUIDATA)
0242 
0243 % Hints: contents = get(hObject,'String') returns uns_list contents as cell array
0244 %        contents{get(hObject,'Value')} returns selected item from uns_list
0245 val=get(handles.uns_list,'Value');
0246 induns=1:length(get(handles.uns_list,'String'));
0247 indok=setdiff(induns,val);
0248 cl=1;
0249 cg=get(handles.group_list,'Value');
0250 if handles.clas{cl,2}{cg,2}==0
0251     handles.clas{cl,2}{cg,2}=handles.clas{cl,2}{cg,1}(val);
0252 else
0253     handles.clas{cl,2}{cg,2}=[handles.clas{cl,2}{cg,2}, handles.clas{cl,2}{cg,1}(val)];
0254 end
0255 if isempty(indok)
0256     handles.clas{cl,2}{cg,1}=0;
0257 else
0258     handles.clas{cl,2}{cg,1}=handles.clas{cl,2}{cg,1}(indok);
0259 end
0260 list=handles.condm{1,2}{cg};
0261 %set subjects lists
0262 if handles.clas{cl,2}{cg,1}~=0
0263     set(handles.uns_list,'Value',1);
0264     set(handles.uns_list,'String',list(handles.clas{cl,2}{cg,1}));
0265 else
0266     set(handles.uns_list,'Value',0);
0267     set(handles.uns_list,'String',{});
0268 end
0269 if handles.clas{cl,2}{cg,2}~=0
0270     set(handles.sel_list,'Value',1);
0271     set(handles.sel_list,'String',list(handles.clas{cl,2}{cg,2}));
0272 else
0273     set(handles.sel_list,'Value',0);
0274     set(handles.sel_list,'String',{});
0275 end
0276 
0277 % Update handles structure
0278 guidata(hObject, handles);
0279 
0280 % --- Executes during object creation, after setting all properties.
0281 function uns_list_CreateFcn(hObject, eventdata, handles)
0282 % hObject    handle to uns_list (see GCBO)
0283 % eventdata  reserved - to be defined in a future version of MATLAB
0284 % handles    empty - handles not created until after all CreateFcns called
0285 
0286 % Hint: listbox controls usually have a white background on Windows.
0287 %       See ISPC and COMPUTER.
0288 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0289     set(hObject,'BackgroundColor','white');
0290 end
0291 
0292 % --- Executes on selection change in sel_list.
0293 function sel_list_Callback(hObject, eventdata, handles)
0294 % hObject    handle to sel_list (see GCBO)
0295 % eventdata  reserved - to be defined in a future version of MATLAB
0296 % handles    structure with handles and user data (see GUIDATA)
0297 
0298 % Hints: contents = get(hObject,'String') returns sel_list contents as cell array
0299 %        contents{get(hObject,'Value')} returns selected item from sel_list
0300 val=get(handles.sel_list,'Value');
0301 indsel=1:length(get(handles.sel_list,'String'));
0302 indok=setdiff(indsel,val);
0303 cl=1;
0304 cg=get(handles.group_list,'Value');
0305 if handles.clas{cl,2}{cg,1}==0
0306     handles.clas{cl,2}{cg,1}=handles.clas{cl,2}{cg,2}(val);
0307 else
0308     handles.clas{cl,2}{cg,1}=[handles.clas{cl,2}{cg,1}, handles.clas{cl,2}{cg,2}(val)];
0309 end
0310 if isempty(indok)
0311     handles.clas{cl,2}{cg,2}=0;
0312 else
0313     handles.clas{cl,2}{cg,2}=handles.clas{cl,2}{cg,2}(indok);
0314 end
0315 list=handles.condm{1,2}{cg};
0316 %set subjects lists
0317 if handles.clas{cl,2}{cg,1}~=0
0318     set(handles.uns_list,'String',list(handles.clas{cl,2}{cg,1}));
0319     set(handles.uns_list,'Value',length(get(handles.uns_list,'String')));
0320 else
0321     set(handles.uns_list,'Value',0);
0322     set(handles.uns_list,'String',{});
0323 end
0324 if handles.clas{cl,2}{cg,2}~=0
0325     set(handles.sel_list,'String',list(handles.clas{cl,2}{cg,2}));
0326     set(handles.sel_list,'Value',length(get(handles.sel_list,'String')));
0327 else
0328     set(handles.sel_list,'Value',0);
0329     set(handles.sel_list,'String',{});
0330 end
0331 % Update handles structure
0332 guidata(hObject, handles);
0333 
0334 % --- Executes during object creation, after setting all properties.
0335 function sel_list_CreateFcn(hObject, eventdata, handles)
0336 % hObject    handle to sel_list (see GCBO)
0337 % eventdata  reserved - to be defined in a future version of MATLAB
0338 % handles    empty - handles not created until after all CreateFcns called
0339 
0340 % Hint: listbox controls usually have a white background on Windows.
0341 %       See ISPC and COMPUTER.
0342 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0343     set(hObject,'BackgroundColor','white');
0344 end
0345 
0346 
0347 % --- Executes on button press in sel_all.
0348 function sel_all_Callback(hObject, eventdata, handles)
0349 % hObject    handle to sel_all (see GCBO)
0350 % eventdata  reserved - to be defined in a future version of MATLAB
0351 % handles    structure with handles and user data (see GUIDATA)
0352 cl=1;
0353 cg=get(handles.group_list,'Value');
0354 list=handles.condm{1,2}{cg,1};
0355 indsel=1:length(list);
0356 handles.clas{cl,2}{cg,2}=indsel;
0357 handles.clas{cl,2}{cg,1}=0;
0358 set(handles.uns_list,'String',{});
0359 set(handles.uns_list,'Value',0);
0360 set(handles.sel_list,'String',list(handles.clas{cl,2}{cg,2}));
0361 set(handles.sel_list,'Value',length(get(handles.sel_list,'String')));
0362 % Update handles structure
0363 guidata(hObject, handles);
0364 
0365 
0366 
0367 
0368 % --- Executes on button press in done_button.
0369 function done_button_Callback(hObject, eventdata, handles)
0370 % hObject    handle to done_button (see GCBO)
0371 % eventdata  reserved - to be defined in a future version of MATLAB
0372 % handles    structure with handles and user data (see GUIDATA)
0373 
0374 flag=0;
0375 for i=1:size(handles.clas,1)
0376     list=get(handles.group_list,'String');
0377     for g=1:length(list)
0378         scount=1;
0379         g2=find(strcmpi(list{g},{handles.dat.group(:).gr_name}));
0380         sids=handles.clas{i,2}{g,2};
0381         handles.class(i).group(g2).gr_name=list{g};
0382         if ~isempty(sids) && any(sids)
0383             flag=1;
0384             for s=1:length(sids)
0385                 handles.class(i).group(g2).subj(scount).num=sids(s);
0386                 listm={handles.dat.fs(handles.indfs).modality(:).mod_name};
0387                 for m=1:length(listm)
0388                     handles.class(i).group(g2).subj(scount).modality(m).mod_name=listm{m};
0389                 end
0390                 scount=scount+1;
0391             end
0392         end
0393     end
0394     if ~flag  %for this class, no subjects were selected
0395         beep
0396         sprintf('No subjects found in the definition of the regression problem')
0397         disp('Please select subjects/scans')
0398         return
0399     end
0400 end
0401 %get names of selected groups for custom CV GUI
0402 lg={};
0403 lc={};
0404 for i=1:size(handles.clas,1)
0405     %get which groups
0406     d=handles.clas{i,2};
0407     for j=1:size(d,1)
0408         if ~isempty(d{j,2}) && any(d{j,2}~=0)
0409             lg=[lg;handles.condm{1}(j)];
0410         end
0411     end
0412 end
0413 legends=struct();
0414 legends.lg=lg;
0415 legends.lc=lc;
0416 handles.class.legends=legends;
0417 handles.output=handles.class;
0418 % Update handles structure
0419 guidata(hObject, handles);
0420 
0421 uiresume(handles.figure1)

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