Home > . > prt_ui_select_class.m

prt_ui_select_class

PURPOSE ^

PRT_UI_SELECT_CLASS M-file for prt_ui_select_class.fig

SYNOPSIS ^

function varargout = prt_ui_select_class(varargin)

DESCRIPTION ^

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

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

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

 PRT_UI_SELECT_CLASS('Property','Value',...) creates a new PRT_UI_SELECT_CLASS
 or raises the existing singleton*.  Starting from the left, property 
 value pairs are applied to the GUI before prt_ui_select_class_OpeningFcn 
 gets called.  An unrecognized property name or invalid value makes 
 property application stop.  All inputs are passed to prt_ui_select_class_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_class(varargin)
0002 % PRT_UI_SELECT_CLASS M-file for prt_ui_select_class.fig
0003 %
0004 % PRT_UI_SELECT_CLASS, by itself, creates a new PRT_UI_SELECT_CLASS or
0005 % raises the existing singleton*.
0006 %
0007 % H = PRT_UI_SELECT_CLASS returns the handle to a new PRT_UI_SELECT_CLASS
0008 % or the handle to the existing singleton*.
0009 %
0010 % PRT_UI_SELECT_CLASS('CALLBACK',hObject,eventData,handles,...) calls the
0011 % local function named CALLBACK in PRT_UI_SELECT_CLASS.M with the given
0012 % input arguments.
0013 %
0014 % PRT_UI_SELECT_CLASS('Property','Value',...) creates a new PRT_UI_SELECT_CLASS
0015 % or raises the existing singleton*.  Starting from the left, property
0016 % value pairs are applied to the GUI before prt_ui_select_class_OpeningFcn
0017 % gets called.  An unrecognized property name or invalid value makes
0018 % property application stop.  All inputs are passed to prt_ui_select_class_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_class
0032 
0033 % Last Modified by GUIDE v2.5 01-Nov-2011 16:35:44
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_class_OpeningFcn, ...
0040                    'gui_OutputFcn',  @prt_ui_select_class_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_class is made visible.
0056 function prt_ui_select_class_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_class (see VARARGIN)
0062 
0063 set(handles.figure1,'Name','PRoNTo :: Specify classes')
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 %set the different fields to disable (will be enabled when choosing the
0120 %number of classes)
0121 set(handles.group_list,'Enable','off')
0122 set(handles.uns_list,'Enable','off')
0123 set(handles.sel_list,'Enable','off')
0124 set(handles.uns_cond_list,'Enable','off')
0125 set(handles.sel_cond_list,'Enable','off')
0126 set(handles.sel_all,'Enable','off')
0127 set(handles.sel_cond_all,'Enable','off');
0128 
0129 %get information from the PRT.mat
0130 if ~isempty(varargin) && strcmpi(varargin{1},'UserData')
0131     handles.dat=varargin{2}{1};
0132     %get names of groups
0133     list={handles.dat.group(:).gr_name};
0134     ng=length(list);
0135     set(handles.group_list,'String',list)
0136     
0137     
0138     %get the conditions which are common to all groups and subjects for the
0139     %different modalities comprised in the selected feature set
0140     indfs=varargin{2}{2};
0141     handles.indfs=indfs;
0142     nm=length(handles.dat.fs(indfs).modality);
0143     modnam={handles.dat.masks(:).mod_name};
0144     handles.condm=cell(1,3);
0145     handles.flagcond=1;
0146     %for each modality, get the conditions which are common to all subjects
0147     for i=1:nm
0148         handles.condm{1,1}=get(handles.group_list,'String');
0149         handles.condm{1,3}=cell(length(get(handles.group_list,'String')),1);
0150         flag=1;
0151         for j=1:ng
0152             handles.condm{1,3}{j}={handles.dat.group(j).subject(:).subj_name};
0153             for k=1:length(handles.dat.group(j).subject)
0154                 m2= strcmpi(handles.dat.fs(indfs).modality(nm).mod_name,modnam);
0155                 des=handles.dat.group(j).subject(k).modality(m2).design;
0156                 if isstruct(des) && flag
0157                     if k==1 && j == 1 % [afm] && nm==1
0158                         lcond={des.conds(:).cond_name};
0159                     else
0160                         tocmp={des.conds(:).cond_name};
0161                         lcond=intersect(lower(lcond),lower(tocmp));
0162                     end
0163                 else
0164                     flag=0;
0165                     lcond={};
0166                 end
0167             end
0168         end
0169     end
0170     handles.condm{1,2}=lcond;
0171     if isempty(handles.condm{1,2})
0172         disp('No conditions were common to all subjects, all groups, all modalities within the feature set')
0173         disp('Classifying subjects only')
0174         handles.flagcond=0;
0175     end
0176     if length(varargin{2})==2
0177         handles.flagrev=0;
0178         set(handles.group_list,'Value',1)
0179         list={handles.dat.group(1).subject(:).subj_name};
0180         set(handles.uns_list,'String',list);
0181         set(handles.sel_list,'String',{});
0182         % Update handles structure
0183         guidata(hObject, handles);
0184         % UIWAIT makes prt_ui_select_class wait for user response (see UIRESUME)
0185         uiwait(handles.figure1);
0186     else
0187         %review the model
0188         handles.flagrev=1;
0189         indm=varargin{2}{3};
0190         mod=handles.dat.model(indm).input;
0191         %classification case
0192         nc=length(mod.class);
0193         set(handles.num_class,'String',num2str(nc))
0194         set(handles.num_class,'Enable','off')
0195         set(handles.edit2,'Enable','off')
0196         handles.clas=cell(nc,4);
0197         %set the names of the classes in the pop_class
0198         cl={};
0199         for i=1:nc
0200             cl=[cl,{['Class ',num2str(i)]}];
0201         end
0202         set(handles.pop_class,'String',cl);
0203         set(handles.pop_class,'Value',1);
0204         for i=1:nc
0205             handles.class(i).class_name=mod.class(i).class_name;
0206             handles.clas{i,1}=1:length(handles.condm{1,1});
0207             handles.clas{i,2}=cell(length(handles.condm{1,1}),2);
0208             list=get(handles.group_list,'String');
0209             for j=1:length(list)
0210                 indg=find(strcmpi(list{j},{mod.class(i).group(:).gr_name}));
0211                 if~isempty(indg)
0212                     sel=[mod.class(i).group(indg).subj(:).num];
0213                     all=1:length(handles.condm{1,3}{j});
0214                     handles.clas{i,2}{j,1}=setdiff(all,sel);
0215                     handles.clas{i,2}{j,2}=sel;
0216                 else
0217                     handles.clas{i,2}{j,1}=1:length(handles.condm{1,3}{j});
0218                     handles.clas{i,2}{j,2}=0;
0219                 end
0220                 if isempty(handles.clas{i,2}{j,1})
0221                     handles.clas{i,2}{j,1}=0;
0222                 end
0223                 if isempty(handles.clas{i,2}{j,2})
0224                     handles.clas{i,2}{j,2}=0;
0225                 end
0226             end
0227             if handles.flagcond
0228                 listc=handles.condm{1,2};
0229                 selc=[];
0230                 if isfield(mod.class(i).group(1).subj(1).modality(1),'all_cond')
0231                     selc=1:length(listc);
0232                 elseif isfield(mod.class(i).group(1).subj(1).modality(1),'conds')
0233                     for icc=1:length(listc)
0234                         indcc=strcmpi(listc{icc},{mod.class(i).group(1).subj(1).modality(1).conds(:).cond_name});
0235                         if any(indcc)
0236                             selc=[selc,icc];
0237                         end
0238                     end
0239                 end
0240                 allc=1:length(handles.condm{1,2});
0241                 handles.clas{i,3}=setdiff(allc,selc);
0242                 handles.clas{i,4}=selc;
0243                 if isempty(handles.clas{i,3})
0244                     handles.clas{i,3}=0;
0245                 end
0246                 if isempty(handles.clas{i,4})
0247                     handles.clas{i,3}=0;
0248                 end
0249             end
0250             handles.class(i).class_name=mod.class(i).class_name;            
0251         end
0252         set(handles.group_list,'Enable','on');
0253         % Update handles structure
0254         guidata(hObject, handles);
0255     end
0256 end
0257 
0258 
0259 
0260 
0261 
0262 
0263 % --- Outputs from this function are returned to the command line.
0264 function varargout = prt_ui_select_class_OutputFcn(hObject, eventdata, handles) 
0265 % varargout  cell array for returning output args (see VARARGOUT);
0266 % hObject    handle to figure
0267 % eventdata  reserved - to be defined in a future version of MATLAB
0268 % handles    structure with handles and user data (see GUIDATA)
0269 
0270 % Get default command line output from handles structure
0271 if isfield(handles,'output') && ~isempty(handles.output)
0272     varargout{1} = handles.output;
0273 else
0274     varargout{1}=[];
0275 end
0276 
0277 %This figure can be deleted now
0278 if isfield(handles,'figure1') && ~handles.flagrev
0279     delete(handles.figure1)
0280 end
0281 
0282 
0283 
0284 function num_class_Callback(hObject, eventdata, handles)
0285 % hObject    handle to num_class (see GCBO)
0286 % eventdata  reserved - to be defined in a future version of MATLAB
0287 % handles    structure with handles and user data (see GUIDATA)
0288 
0289 % Hints: get(hObject,'String') returns contents of num_class as text
0290 %        str2double(get(hObject,'String')) returns contents of num_class as a double
0291 ncl=str2double(get(handles.num_class,'String'));
0292 if isnan(ncl)
0293     return
0294 end
0295 %set the names of the classes in the pop_class
0296 cl={};
0297 for i=1:ncl
0298     cl=[cl,{['Class ',num2str(i)]}];
0299 end
0300 set(handles.pop_class,'String',cl);
0301 set(handles.pop_class,'Value',1);
0302 %For each class, build a cell containing the indexes of
0303 %the selected groups and conditions
0304 handles.clas=cell(ncl,4);
0305 for i=1:ncl
0306     handles.clas{i,1}=1:length(handles.condm{1,1});
0307     handles.clas{i,2}=cell(length(handles.condm{1,1}),2);
0308     for j=1:length(get(handles.group_list,'String'))
0309         handles.clas{i,2}{j,1}=1:length(handles.condm{1,3}{j});
0310         handles.clas{i,2}{j,2}=0;
0311     end
0312     if handles.flagcond
0313         handles.clas{i,3}=1:length(handles.condm{1,2});
0314         handles.clas{i,4}=0;
0315     end
0316     handles.class(i).class_name=cl{i};
0317 end
0318 set(handles.edit2,'String',handles.class(1).class_name)
0319 % Update handles structure
0320 guidata(hObject, handles);
0321 
0322 % --- Executes during object creation, after setting all properties.
0323 function num_class_CreateFcn(hObject, eventdata, handles)
0324 % hObject    handle to num_class (see GCBO)
0325 % eventdata  reserved - to be defined in a future version of MATLAB
0326 % handles    empty - handles not created until after all CreateFcns called
0327 
0328 % Hint: edit controls usually have a white background on Windows.
0329 %       See ISPC and COMPUTER.
0330 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0331     set(hObject,'BackgroundColor','white');
0332 end
0333 
0334 
0335 %change the name of the classes
0336 function edit2_Callback(hObject, eventdata, handles)
0337 % hObject    handle to edit2 (see GCBO)
0338 % eventdata  reserved - to be defined in a future version of MATLAB
0339 % handles    structure with handles and user data (see GUIDATA)
0340 
0341 % Hints: get(hObject,'String') returns contents of edit2 as text
0342 %        str2double(get(hObject,'String')) returns contents of edit2 as a double
0343 indc=get(handles.pop_class,'Value');
0344 handles.class(indc).class_name=get(handles.edit2,'String');
0345 % Update handles structure
0346 guidata(hObject, handles);
0347 
0348 % --- Executes during object creation, after setting all properties.
0349 function edit2_CreateFcn(hObject, eventdata, handles)
0350 % hObject    handle to edit2 (see GCBO)
0351 % eventdata  reserved - to be defined in a future version of MATLAB
0352 % handles    empty - handles not created until after all CreateFcns called
0353 
0354 % Hint: edit controls usually have a white background on Windows.
0355 %       See ISPC and COMPUTER.
0356 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0357     set(hObject,'BackgroundColor','white');
0358 end
0359 
0360 % --- Executes on selection change in pop_class.
0361 function pop_class_Callback(hObject, eventdata, handles)
0362 % hObject    handle to pop_class (see GCBO)
0363 % eventdata  reserved - to be defined in a future version of MATLAB
0364 % handles    structure with handles and user data (see GUIDATA)
0365 
0366 % Hints: contents = get(hObject,'String') returns pop_class contents as cell array
0367 %        contents{get(hObject,'Value')} returns selected item from pop_class
0368 vc=get(handles.pop_class,'Value');
0369 if vc==0
0370     warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0371     set(handles.pop_class,'Value',1)
0372     vc=1;
0373 end
0374 cg=get(handles.group_list,'Value');
0375 list=handles.condm{1,3}{cg};
0376 clist=handles.condm{1,2};
0377 set(handles.edit2,'String',handles.class(vc).class_name)
0378 %set subjects lists
0379 if handles.clas{vc,2}{cg,1}~=0
0380     set(handles.uns_list,'Value',1);
0381     set(handles.uns_list,'String',list(handles.clas{vc,2}{cg,1}));
0382 else
0383     set(handles.uns_list,'Value',0);
0384     set(handles.uns_list,'String',{});
0385 end
0386 if handles.clas{vc,2}{cg,2}~=0
0387     set(handles.sel_list,'Value',1);
0388     set(handles.sel_list,'String',list(handles.clas{vc,2}{cg,2}));
0389 else
0390     set(handles.sel_list,'Value',0);
0391     set(handles.sel_list,'String',{});
0392 end
0393 %set conditions lists
0394 if handles.flagcond
0395     if handles.clas{vc,3}~=0
0396         set(handles.uns_cond_list,'Value',1);
0397         set(handles.uns_cond_list,'String',clist(handles.clas{vc,3}));
0398     else
0399         set(handles.uns_cond_list,'Value',0);
0400         set(handles.uns_cond_list,'String',{});
0401     end
0402     if handles.clas{vc,4}~=0
0403         set(handles.sel_cond_list,'Value',1);
0404         set(handles.sel_cond_list,'String',clist(handles.clas{vc,4}));
0405     else
0406         set(handles.sel_cond_list,'Value',0);
0407         set(handles.sel_cond_list,'String',{});
0408     end
0409     if ~handles.flagrev
0410         set(handles.uns_cond_list,'Enable','on');
0411         set(handles.sel_cond_list,'Enable','on');
0412         set(handles.sel_cond_all,'Enable','on');
0413     end
0414 end
0415 if ~handles.flagrev
0416     set(handles.uns_list,'Enable','on');
0417     set(handles.sel_list,'Enable','on');
0418     set(handles.sel_all,'Enable','on');
0419 end
0420 set(handles.group_list,'Enable','on');
0421 % Update handles structure
0422 guidata(hObject, handles);
0423 
0424 % --- Executes during object creation, after setting all properties.
0425 function pop_class_CreateFcn(hObject, eventdata, handles)
0426 % hObject    handle to pop_class (see GCBO)
0427 % eventdata  reserved - to be defined in a future version of MATLAB
0428 % handles    empty - handles not created until after all CreateFcns called
0429 
0430 % Hint: popupmenu controls usually have a white background on Windows.
0431 %       See ISPC and COMPUTER.
0432 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0433     set(hObject,'BackgroundColor','white');
0434 end
0435 
0436 % --- Executes on selection change in group_list.
0437 function group_list_Callback(hObject, eventdata, handles)
0438 % hObject    handle to group_list (see GCBO)
0439 % eventdata  reserved - to be defined in a future version of MATLAB
0440 % handles    structure with handles and user data (see GUIDATA)
0441 
0442 % Hints: contents = get(hObject,'String') returns group_list contents as cell array
0443 %        contents{get(hObject,'Value')} returns selected item from group_list
0444 cl=get(handles.pop_class,'Value');
0445 if cl==0
0446     warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0447     set(handles.pop_classes,'Value',1)
0448 end
0449 cl=get(handles.pop_class,'Value');
0450 cg=get(handles.group_list,'Value');
0451 list=handles.condm{1,3}{cg};
0452 %set subjects lists
0453 if handles.clas{cl,2}{cg,1}~=0
0454     set(handles.uns_list,'Value',1);
0455     set(handles.uns_list,'String',list(handles.clas{cl,2}{cg,1}));
0456 else
0457     set(handles.uns_list,'Value',0);
0458     set(handles.uns_list,'String',{});
0459 end
0460 if handles.clas{cl,2}{cg,2}~=0
0461     set(handles.sel_list,'Value',1);
0462     set(handles.sel_list,'String',list(handles.clas{cl,2}{cg,2}));
0463 else
0464     set(handles.sel_list,'Value',0);
0465     set(handles.sel_list,'String',{});
0466 end
0467 % Update handles structure
0468 guidata(hObject, handles);
0469 
0470 % --- Executes during object creation, after setting all properties.
0471 function group_list_CreateFcn(hObject, eventdata, handles)
0472 % hObject    handle to group_list (see GCBO)
0473 % eventdata  reserved - to be defined in a future version of MATLAB
0474 % handles    empty - handles not created until after all CreateFcns called
0475 
0476 % Hint: listbox controls usually have a white background on Windows.
0477 %       See ISPC and COMPUTER.
0478 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0479     set(hObject,'BackgroundColor','white');
0480 end
0481 
0482 % --- Executes on selection change in uns_list.
0483 function uns_list_Callback(hObject, eventdata, handles)
0484 % hObject    handle to uns_list (see GCBO)
0485 % eventdata  reserved - to be defined in a future version of MATLAB
0486 % handles    structure with handles and user data (see GUIDATA)
0487 
0488 % Hints: contents = get(hObject,'String') returns uns_list contents as cell array
0489 %        contents{get(hObject,'Value')} returns selected item from uns_list
0490 val=get(handles.uns_list,'Value');
0491 induns=1:length(get(handles.uns_list,'String'));
0492 indok=setdiff(induns,val);
0493 cl=get(handles.pop_class,'Value');
0494 if cl==0
0495     warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0496     set(handles.pop_classes,'Value',1)
0497 end
0498 cl=get(handles.pop_class,'Value');
0499 cg=get(handles.group_list,'Value');
0500 if handles.clas{cl,2}{cg,2}==0
0501     handles.clas{cl,2}{cg,2}=handles.clas{cl,2}{cg,1}(val);
0502 else
0503     handles.clas{cl,2}{cg,2}=[handles.clas{cl,2}{cg,2}, handles.clas{cl,2}{cg,1}(val)];
0504 end
0505 if isempty(indok)
0506     handles.clas{cl,2}{cg,1}=0;
0507 else
0508     handles.clas{cl,2}{cg,1}=handles.clas{cl,2}{cg,1}(indok);
0509 end
0510 list=handles.condm{1,3}{cg};
0511 %set subjects lists
0512 if handles.clas{cl,2}{cg,1}~=0
0513     set(handles.uns_list,'Value',1);
0514     set(handles.uns_list,'String',list(handles.clas{cl,2}{cg,1}));
0515 else
0516     set(handles.uns_list,'Value',0);
0517     set(handles.uns_list,'String',{});
0518 end
0519 if handles.clas{cl,2}{cg,2}~=0
0520     set(handles.sel_list,'Value',1);
0521     set(handles.sel_list,'String',list(handles.clas{cl,2}{cg,2}));
0522 else
0523     set(handles.sel_list,'Value',0);
0524     set(handles.sel_list,'String',{});
0525 end
0526 
0527 % Update handles structure
0528 guidata(hObject, handles);
0529 
0530 % --- Executes during object creation, after setting all properties.
0531 function uns_list_CreateFcn(hObject, eventdata, handles)
0532 % hObject    handle to uns_list (see GCBO)
0533 % eventdata  reserved - to be defined in a future version of MATLAB
0534 % handles    empty - handles not created until after all CreateFcns called
0535 
0536 % Hint: listbox controls usually have a white background on Windows.
0537 %       See ISPC and COMPUTER.
0538 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0539     set(hObject,'BackgroundColor','white');
0540 end
0541 
0542 % --- Executes on selection change in sel_list.
0543 function sel_list_Callback(hObject, eventdata, handles)
0544 % hObject    handle to sel_list (see GCBO)
0545 % eventdata  reserved - to be defined in a future version of MATLAB
0546 % handles    structure with handles and user data (see GUIDATA)
0547 
0548 % Hints: contents = get(hObject,'String') returns sel_list contents as cell array
0549 %        contents{get(hObject,'Value')} returns selected item from sel_list
0550 val=get(handles.sel_list,'Value');
0551 indsel=1:length(get(handles.sel_list,'String'));
0552 indok=setdiff(indsel,val);
0553 cl=get(handles.pop_class,'Value');
0554 if cl==0
0555     warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0556     set(handles.pop_classes,'Value',1)
0557 end
0558 cl=get(handles.pop_class,'Value');
0559 cg=get(handles.group_list,'Value');
0560 if handles.clas{cl,2}{cg,1}==0
0561     handles.clas{cl,2}{cg,1}=handles.clas{cl,2}{cg,2}(val);
0562 else
0563     handles.clas{cl,2}{cg,1}=[handles.clas{cl,2}{cg,1}, handles.clas{cl,2}{cg,2}(val)];
0564 end
0565 if isempty(indok)
0566     handles.clas{cl,2}{cg,2}=0;
0567 else
0568     handles.clas{cl,2}{cg,2}=handles.clas{cl,2}{cg,2}(indok);
0569 end
0570 list=handles.condm{1,3}{cg};
0571 %set subjects lists
0572 if handles.clas{cl,2}{cg,1}~=0
0573     set(handles.uns_list,'String',list(handles.clas{cl,2}{cg,1}));
0574     set(handles.uns_list,'Value',length(get(handles.uns_list,'String')));
0575 else
0576     set(handles.uns_list,'Value',0);
0577     set(handles.uns_list,'String',{});
0578 end
0579 if handles.clas{cl,2}{cg,2}~=0
0580     set(handles.sel_list,'String',list(handles.clas{cl,2}{cg,2}));
0581     set(handles.sel_list,'Value',length(get(handles.sel_list,'String')));
0582 else
0583     set(handles.sel_list,'Value',0);
0584     set(handles.sel_list,'String',{});
0585 end
0586 % Update handles structure
0587 guidata(hObject, handles);
0588 
0589 % --- Executes during object creation, after setting all properties.
0590 function sel_list_CreateFcn(hObject, eventdata, handles)
0591 % hObject    handle to sel_list (see GCBO)
0592 % eventdata  reserved - to be defined in a future version of MATLAB
0593 % handles    empty - handles not created until after all CreateFcns called
0594 
0595 % Hint: listbox controls usually have a white background on Windows.
0596 %       See ISPC and COMPUTER.
0597 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0598     set(hObject,'BackgroundColor','white');
0599 end
0600 
0601 
0602 % --- Executes on button press in sel_all.
0603 function sel_all_Callback(hObject, eventdata, handles)
0604 % hObject    handle to sel_all (see GCBO)
0605 % eventdata  reserved - to be defined in a future version of MATLAB
0606 % handles    structure with handles and user data (see GUIDATA)
0607 cl=get(handles.pop_class,'Value');
0608 if cl==0
0609     warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0610     set(handles.pop_classes,'Value',1)
0611 end
0612 cl=get(handles.pop_class,'Value');
0613 cg=get(handles.group_list,'Value');
0614 list=handles.condm{1,3}{cg,1};
0615 indsel=1:length(list);
0616 handles.clas{cl,2}{cg,2}=indsel;
0617 handles.clas{cl,2}{cg,1}=0;
0618 set(handles.uns_list,'String',{});
0619 set(handles.uns_list,'Value',0);
0620 set(handles.sel_list,'String',list(handles.clas{cl,2}{cg,2}));
0621 set(handles.sel_list,'Value',length(get(handles.sel_list,'String')));
0622 % Update handles structure
0623 guidata(hObject, handles);
0624 
0625 
0626 % --- Executes on selection change in uns_cond_list.
0627 function uns_cond_list_Callback(hObject, eventdata, handles)
0628 % hObject    handle to uns_cond_list (see GCBO)
0629 % eventdata  reserved - to be defined in a future version of MATLAB
0630 % handles    structure with handles and user data (see GUIDATA)
0631 
0632 % Hints: contents = get(hObject,'String') returns uns_cond_list contents as cell array
0633 %        contents{get(hObject,'Value')} returns selected item from uns_cond_list
0634 val=get(handles.uns_cond_list,'Value');
0635 induns=1:length(get(handles.uns_cond_list,'String'));
0636 indok=setdiff(induns,val);
0637 cl=get(handles.pop_class,'Value');
0638 if cl==0
0639     warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0640     set(handles.pop_classes,'Value',1)
0641 end
0642 cl=get(handles.pop_class,'Value');
0643 if handles.clas{cl,4}==0
0644     handles.clas{cl,4}=handles.clas{cl,3}(val);
0645 else
0646     handles.clas{cl,4}=[handles.clas{cl,4}, handles.clas{cl,3}(val)];
0647 end
0648 if isempty(indok)
0649     handles.clas{cl,3}=0;
0650 else
0651     handles.clas{cl,3}=handles.clas{cl,3}(indok);
0652 end
0653 %set conditions lists
0654 clist=handles.condm{1,2};
0655 if handles.clas{cl,3}~=0
0656     set(handles.uns_cond_list,'Value',1);
0657     set(handles.uns_cond_list,'String',clist(handles.clas{cl,3}));
0658 else
0659     set(handles.uns_cond_list,'Value',0);
0660     set(handles.uns_cond_list,'String',{});
0661 end
0662 if handles.clas{cl,4}~=0
0663     set(handles.sel_cond_list,'Value',1);
0664     set(handles.sel_cond_list,'String',clist(handles.clas{cl,4}));
0665 else
0666     set(handles.sel_cond_list,'Value',0);
0667     set(handles.sel_cond_list,'String',{});
0668 end
0669 % Update handles structure
0670 guidata(hObject, handles);
0671 
0672 % --- Executes during object creation, after setting all properties.
0673 function uns_cond_list_CreateFcn(hObject, eventdata, handles)
0674 % hObject    handle to uns_cond_list (see GCBO)
0675 % eventdata  reserved - to be defined in a future version of MATLAB
0676 % handles    empty - handles not created until after all CreateFcns called
0677 
0678 % Hint: listbox controls usually have a white background on Windows.
0679 %       See ISPC and COMPUTER.
0680 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0681     set(hObject,'BackgroundColor','white');
0682 end
0683 
0684 % --- Executes on selection change in sel_cond_list.
0685 function sel_cond_list_Callback(hObject, eventdata, handles)
0686 % hObject    handle to sel_cond_list (see GCBO)
0687 % eventdata  reserved - to be defined in a future version of MATLAB
0688 % handles    structure with handles and user data (see GUIDATA)
0689 
0690 % Hints: contents = get(hObject,'String') returns sel_cond_list contents as cell array
0691 %        contents{get(hObject,'Value')} returns selected item from sel_cond_list
0692 val=get(handles.sel_cond_list,'Value');
0693 induns=1:length(get(handles.sel_cond_list,'String'));
0694 indok=setdiff(induns,val);
0695 cl=get(handles.pop_class,'Value');
0696 if cl==0
0697     warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0698     set(handles.pop_classes,'Value',1)
0699 end
0700 cl=get(handles.pop_class,'Value');
0701 if handles.clas{cl,3}==0
0702     handles.clas{cl,3}=handles.clas{cl,4}(val);
0703 else
0704     handles.clas{cl,3}=[handles.clas{cl,3}, handles.clas{cl,4}(val)];
0705 end
0706 if isempty(indok)
0707     handles.clas{cl,4}=0;
0708 else
0709     handles.clas{cl,4}=handles.clas{cl,4}(indok);
0710 end
0711 %set conditions lists
0712 clist=handles.condm{1,2};
0713 if handles.clas{cl,3}~=0
0714     set(handles.uns_cond_list,'String',clist(handles.clas{cl,3}));
0715     set(handles.uns_cond_list,'Value',length(get(handles.uns_cond_list,'String')));
0716 else
0717     set(handles.uns_cond_list,'Value',0);
0718     set(handles.uns_cond_list,'String',{});
0719 end
0720 if handles.clas{cl,4}~=0
0721     set(handles.sel_cond_list,'String',clist(handles.clas{cl,4}));
0722     set(handles.sel_cond_list,'Value',length(get(handles.sel_cond_list,'String')));
0723 else
0724     set(handles.sel_cond_list,'Value',0);
0725     set(handles.sel_cond_list,'String',{});
0726 end
0727 % Update handles structure
0728 guidata(hObject, handles);
0729 
0730 % --- Executes during object creation, after setting all properties.
0731 function sel_cond_list_CreateFcn(hObject, eventdata, handles)
0732 % hObject    handle to sel_cond_list (see GCBO)
0733 % eventdata  reserved - to be defined in a future version of MATLAB
0734 % handles    empty - handles not created until after all CreateFcns called
0735 
0736 % Hint: listbox controls usually have a white background on Windows.
0737 %       See ISPC and COMPUTER.
0738 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0739     set(hObject,'BackgroundColor','white');
0740 end
0741 
0742 
0743 % --- Executes on button press in sel_cond_all.
0744 function sel_cond_all_Callback(hObject, eventdata, handles)
0745 % hObject    handle to sel_cond_all (see GCBO)
0746 % eventdata  reserved - to be defined in a future version of MATLAB
0747 % handles    structure with handles and user data (see GUIDATA)
0748 cl=get(handles.pop_class,'Value');
0749 if cl==0
0750     warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0751     set(handles.pop_classes,'Value',1)
0752 end
0753 cl=get(handles.pop_class,'Value');
0754 list=handles.condm{1,2};
0755 indsel=1:length(list);
0756 handles.clas{cl,4}=indsel;
0757 handles.clas{cl,3}=0;
0758 set(handles.uns_cond_list,'String',{});
0759 set(handles.uns_cond_list,'Value',0);
0760 set(handles.sel_cond_list,'String',list(handles.clas{cl,4}));
0761 set(handles.sel_cond_list,'Value',length(get(handles.sel_cond_list,'String')));
0762 % Update handles structure
0763 guidata(hObject, handles);
0764 
0765 
0766 
0767 % --- Executes on button press in done_button.
0768 function done_button_Callback(hObject, eventdata, handles)
0769 % hObject    handle to done_button (see GCBO)
0770 % eventdata  reserved - to be defined in a future version of MATLAB
0771 % handles    structure with handles and user data (see GUIDATA)
0772 if handles.flagrev
0773     delete(handles.figure1)
0774     return
0775 end
0776 ncc=[];
0777 scc=zeros(size(handles.clas,1),1);
0778 for i=1:size(handles.clas,1)
0779     list=get(handles.group_list,'String');
0780     flag=0;
0781     ncs=[];
0782     for g=1:length(list)
0783         scount=1;
0784         g2=find(strcmpi(list{g},{handles.dat.group(:).gr_name}));
0785         sids=handles.clas{i,2}{g,2};
0786         if ~isempty(sids) && any(sids)
0787             handles.class(i).group(g2).gr_name=list{g};
0788             flag=1;
0789             for s=1:length(sids)
0790                 handles.class(i).group(g2).subj(scount).num=sids(s);
0791                 listm={handles.dat.fs(handles.indfs).modality(:).mod_name};
0792                 for m=1:length(listm)
0793                     handles.class(i).group(g2).subj(scount).modality(m).mod_name=listm{m};
0794                     if isempty(handles.condm{1,2})
0795                         handles.class(i).group(g2).subj(scount).modality(m).all_scans=true;
0796                         ncs=[ncs;0];
0797                     else %design and conditions selected
0798                         if isempty(handles.clas{i,3}) || any(handles.clas{i,3}==0) %all conditions were selected
0799                             handles.class(i).group(g2).subj(scount).modality(m).all_cond=true;
0800                         else
0801                             for ic=1:length(handles.clas{i,4})
0802                                 handles.class(i).group(g2).subj(scount).modality(m).conds(ic).cond_name= ...
0803                                     handles.condm{1,2}{handles.clas{i,4}(ic)};
0804                             end
0805                         end
0806                         ncs=[ncs;length(handles.clas{i,4})];
0807                     end
0808                 end
0809                 scount=scount+1;
0810             end
0811             scc(i)=scc(i)+scount;
0812         end
0813     end
0814     if ~flag
0815         beep
0816         sprintf('No subjects found in the definition of class %d',i)
0817         disp('Please select subjects (and conditions) for that class')
0818         return
0819     end
0820     if length(unique(ncs))~=1
0821         beep
0822         sprintf('Different numbers of conditions found in the definition of class %d',i)
0823         disp('Please select the same conditions for each subject/group of that class')
0824         return
0825     else
0826         ncc=[ncc;unique(ncs)];
0827     end
0828     if ~isempty(find(ncc==0)) && length(find(ncc==0))~=length(ncc)
0829         beep
0830         sprintf('Class %d does not have the same number of conditions as class 1',i)
0831         disp('Please select either at least one condition for each class or none')
0832         return
0833     end
0834 end
0835 
0836 if ~any(ncc) %no conditions specified
0837     handles.design=0;
0838 else
0839     handles.design=1;
0840 end
0841 if length(unique(scc))~=1  %different numbers of subject per class
0842     handles.loospg=0;  %no leave-one-subject per group-out CV
0843 else
0844     handles.loospg=1;
0845 end
0846 
0847 aa=struct();
0848 aa.class=handles.class;
0849 aa.design=handles.design;
0850 aa.loospg=handles.loospg;
0851 %get names of selected groups and conditions for custom CV GUI
0852 lgi=[];
0853 lci=[];
0854 for i=1:size(handles.clas,1)
0855     %get which groups
0856     d=handles.clas{i,2};
0857     for j=1:size(d,1)
0858         if ~isempty(d{j,2}) && any(d{j,2}~=0)
0859             lgi=[lgi,j]; %d{j,2}
0860         end
0861     end
0862     %get which conditions
0863     d=handles.clas{i,4};
0864     if ~isempty(d) && any(d~=0)
0865         lci=[lci,d];
0866     end
0867 end
0868 lg=handles.condm{1}(lgi);
0869 lc=handles.condm{2}(lci);
0870 legends=struct();
0871 legends.lg=lg;
0872 legends.lgi=lgi;
0873 legends.lci=lci;
0874 legends.lc=lc;
0875 aa.legends=legends;
0876 handles.output=aa;
0877 % Update handles structure
0878 guidata(hObject, handles);
0879 if ~handles.flagrev
0880     uiresume(handles.figure1)
0881 end

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