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

Generated on Mon 03-Sep-2012 18:07:18 by m2html © 2005