Home > . > prt_data_modality.m

prt_data_modality

PURPOSE ^

PRT_DATA_MODALITY M-file for prt_data_modality.fig

SYNOPSIS ^

function varargout = prt_data_modality(varargin)

DESCRIPTION ^

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

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

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

 PRT_DATA_MODALITY('Property','Value',...) creates a new PRT_DATA_MODALITY
 or raises the existing singleton*.  Starting from the left, property value
 pairs are applied to the GUI before prt_data_modality_OpeningFcn gets called.  
 An unrecognized property name or invalid value makes property application
 stop.  All inputs are passed to prt_data_modality_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_data_modality(varargin)
0002 % PRT_DATA_MODALITY M-file for prt_data_modality.fig
0003 %
0004 % PRT_DATA_MODALITY, by itself, creates a new PRT_DATA_MODALITY or raises
0005 % the existing singleton*.
0006 %
0007 % H = PRT_DATA_MODALITY returns the handle to a new PRT_DATA_MODALITY or
0008 % the handle to the existing singleton*.
0009 %
0010 % PRT_DATA_MODALITY('CALLBACK',hObject,eventData,handles,...) calls the local
0011 % function named CALLBACK in PRT_DATA_MODALITY.M with the given input arguments.
0012 %
0013 % PRT_DATA_MODALITY('Property','Value',...) creates a new PRT_DATA_MODALITY
0014 % or raises the existing singleton*.  Starting from the left, property value
0015 % pairs are applied to the GUI before prt_data_modality_OpeningFcn gets called.
0016 % An unrecognized property name or invalid value makes property application
0017 % stop.  All inputs are passed to prt_data_modality_OpeningFcn via varargin.
0018 %
0019 % *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
0020 %  instance to run (singleton)".
0021 %
0022 % See also: GUIDE, GUIDATA, GUIHANDLES
0023 %_______________________________________________________________________
0024 % Copyright (C) 2011 Machine Learning & Neuroimaging Laboratory
0025 
0026 % Written by J.Schrouff
0027 % $Id$
0028 
0029 % Edit the above text to modify the response to help prt_data_modality
0030 
0031 % Last Modified by GUIDE v2.5 25-Oct-2011 18:14:12
0032 
0033 % Begin initialization code - DO NOT EDIT
0034 
0035 
0036 gui_Singleton = 1;
0037 gui_State = struct('gui_Name',       mfilename, ...
0038                    'gui_Singleton',  gui_Singleton, ...
0039                    'gui_OpeningFcn', @prt_data_modality_OpeningFcn, ...
0040                    'gui_OutputFcn',  @prt_data_modality_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_data_modality is made visible.
0056 function prt_data_modality_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_data_modality (see VARARGIN)
0062 
0063 % Choose default command line output for prt_data_modality
0064 handles.output = hObject;
0065 
0066 %if window already exists, just put it as the current figure
0067 Tag='DDmod';
0068 F = findall(allchild(0),'Flat','Tag',Tag);
0069 if length(F) > 1
0070     % Multiple Graphics windows - close all but most recent
0071     close(F(2:end))
0072     F = F(1);
0073     uistack(F,'top')
0074 elseif length(F)==1
0075     uistack(F,'top')
0076 else
0077     set(handles.figure1,'Tag',Tag)
0078 
0079     set(handles.figure1,'Name','PRoNTo :: Specify modality')
0080     set(handles.design_menu,...
0081             'String',{'Load SPM.mat','Specify design','No design'},...
0082             'Value',3);
0083 
0084     %set size of the window, taking screen resolution and platform into account
0085     S0= spm('WinSize','0',1);   %-Screen size (of the current monitor)
0086     if ispc
0087         PF='MS Sans Serif';
0088     else
0089         PF= spm_platform('fonts');     %-Font names (for this platform)
0090         PF=PF.helvetica;
0091     end
0092     tmp  = [S0(3)/1280 (S0(4))/800];
0093     ratio=min(tmp)*[1 1 1 1];
0094     FS = 1 + 0.85*(min(ratio)-1);  %factor to scale the fonts
0095     x=get(handles.figure1,'Position');
0096     set(handles.figure1,'DefaultTextFontSize',FS*8,...
0097         'DefaultUicontrolFontSize',FS*8,...
0098         'DefaultTextFontName',PF,...
0099         'DefaultAxesFontName',PF,...
0100         'DefaultUicontrolFontName',PF)
0101     set(handles.figure1,'Position',ratio.*x)
0102     set(handles.figure1,'Resize','on') 
0103 
0104     % Choose the color of the different backgrounds and figure parameters
0105     color=prt_get_defaults('color');
0106     set(handles.figure1,'Color',color.bg1)
0107     aa=get(handles.figure1,'children');
0108     for i=1:length(aa)
0109         if strcmpi(get(aa(i),'type'),'uipanel')
0110             set(aa(i),'BackgroundColor',color.bg2)
0111             bb=get(aa(i),'children');
0112             if ~isempty(bb)
0113                 for j=1:length(bb)
0114                     if ~isempty(find(strcmpi(get(bb(j),'Style'),{'text',...
0115                             'radiobutton','checkbox'}))) 
0116                         set(bb(j),'BackgroundColor',color.bg2)
0117                     elseif ~isempty(find(strcmpi(get(bb(j),'Style'),'pushbutton'))) 
0118                         set(bb(j),'BackgroundColor',color.fr)
0119                     end
0120                     set(bb(j),'FontUnits','pixel')
0121                     xf=get(bb(j),'FontSize');
0122                     set(bb(j),'FontSize',ceil(FS*xf),'FontName',PF,...
0123                         'FontUnits','normalized','Units','normalized')
0124                 end
0125             end                    
0126         else
0127             if ~isempty(find(strcmpi(get(aa(i),'Style'),{'text',...
0128                     'radiobutton','checkbox','listbox'})))
0129                 set(aa(i),'BackgroundColor',color.bg1)
0130             elseif ~isempty(find(strcmpi(get(aa(i),'Style'),'pushbutton')))
0131                 set(aa(i),'BackgroundColor',color.fr)
0132             end
0133         end
0134         set(aa(i),'FontUnits','pixel')
0135         xf=get(aa(i),'FontSize');
0136         if ispc
0137             set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0138                 'FontUnits','normalized','Units','normalized')
0139         else
0140             set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0141                 'Units','normalized')
0142         end
0143     end
0144 
0145 
0146 
0147 
0148     handles.mod=[];
0149     handles.mod.detrend=1;
0150     handles.mod.design=0;
0151     handles.mod.scans=[];
0152     handles.mod.name={};
0153     handles.mod.covar=[];
0154     handles.mod.rt_subj=[];
0155     handles.subj1=0;
0156 
0157     if ~isempty(varargin) && strcmpi(varargin{1},'UserData')
0158         %Particular options if you select by 'scans'
0159         if ~isempty(varargin{2}{2}) && strcmpi(varargin{2}{2}.subj_name,'Scans')
0160             set(handles.design_menu,'Enable','off')
0161             set(handles.edit_regt,'Enable','on')
0162             set(handles.edit_regt,'Visible','on')
0163             set(handles.edit_covar,'Enable','on')
0164             set(handles.edit_covar,'Visible','on')
0165             set(handles.text7,'Visible','on') % Covariates
0166             set(handles.text6,'Visible','on') %Regression targets
0167         else
0168             set(handles.design_menu,'Enable','on')
0169             set(handles.edit_regt,'Enable','off')
0170             set(handles.edit_regt,'Visible','off')
0171             set(handles.edit_covar,'Enable','off')
0172             set(handles.edit_covar,'Visible','off')
0173             set(handles.text7,'Visible','off')
0174             set(handles.text6,'Visible','off')
0175         end
0176 
0177         if ~isempty(varargin{2}{2}) && isfield(varargin{2}{2},'modality') && ...
0178                 ~isempty(varargin{2}{2}.modality)
0179             handles.subjmod={varargin{2}{2}.modality(:).mod_name};
0180             if length(varargin{2})>=3 && ~isempty(varargin{2}{3})
0181                 nlist=varargin{2}{1};
0182                 modsel=varargin{2}{2}.modality(varargin{2}{3});
0183                 valsel=find(strcmpi(modsel.mod_name,nlist));
0184                 set(handles.modname,'String',nlist);
0185                 set(handles.modname,'Value',valsel);
0186                 if isfield(modsel,'detrend')
0187                     handles.mod.detrend=modsel.detrend;
0188                 else
0189                     handles.mod.detrend=0;
0190                 end
0191                 handles.mod.design=modsel.design;
0192                 if ~isempty(modsel.design)
0193                     set(handles.design_menu,'Value',2)
0194                     handles.desnmenu=2;
0195                 end
0196                 handles.mod.scans=modsel.scans;
0197                 handles.mod.name=modsel.mod_name;
0198                 handles.mod.covar=modsel.covar;
0199                 if ~isempty(modsel.covar)
0200                     set(handles.edit_covar,'Enable','on')
0201                     set(handles.edit_covar,'Visible','on')
0202                     set(handles.text7,'Visible','on')
0203                     set(handles.edit_covar,'String',num2str(modsel.covar(:)))
0204                 end
0205                 handles.mod.rt_subj=modsel.rt_subj;
0206                 if ~isempty(modsel.rt_subj)
0207                     set(handles.edit_regt,'Enable','on')
0208                     set(handles.edit_regt,'Visible','on')
0209                     set(handles.text6,'Visible','on')
0210                     set(handles.edit_regt,'String',num2str(modsel.rt_subj(:)))
0211                 end
0212             else
0213                 nlist=[varargin{2}{1}, {'Enter new'}];
0214                 set(handles.modname,'String',nlist,'Value',length(nlist));  
0215             end
0216         else
0217             nlist=[varargin{2}{1}, {'Enter new'}];
0218             set(handles.modname,'String',nlist,'Value',length(nlist));  
0219             handles.subjmod={};
0220         end
0221     else
0222         nlist={'Enter new'};
0223         handles.subjmod={};
0224         set(handles.modname,'String',nlist,'Value',1);
0225     end
0226     if length(varargin{2})>=4 && ~isempty(varargin{2}{4})
0227         handles.subj1=varargin{2}{4};
0228     end
0229     if length(varargin{2})==5 && ~isempty(varargin{2}{5})
0230         handles.PRT=varargin{2}{5};
0231     end
0232     warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0233 end
0234 % Update handles structure
0235 guidata(hObject, handles);
0236 
0237 % %UIWAIT makes prt_data_modality wait for user response (see UIRESUME)
0238 uiwait(handles.figure1);
0239 
0240 
0241 % --- Outputs from this function are returned to the command line.
0242 function varargout = prt_data_modality_OutputFcn(hObject, eventdata, handles) 
0243 % varargout  cell array for returning output args (see VARARGOUT);
0244 % hObject    handle to figure
0245 % eventdata  reserved - to be defined in a future version of MATLAB
0246 % handles    structure with handles and user data (see GUIDATA)
0247 
0248 % Get default command line output from handles structure
0249 if isfield(handles,'output') && ~isempty(handles.output)
0250     varargout{1} = handles.output;
0251 else
0252     varargout{1}=[];
0253 end
0254 
0255 % The figure can be deleted now
0256 if isfield(handles,'figure1')
0257     delete(handles.figure1);
0258 end
0259 
0260 
0261 % --- Executes on selection change in modname.
0262 function modname_Callback(hObject, eventdata, handles)
0263 % hObject    handle to modname (see GCBO)
0264 % eventdata  reserved - to be defined in a future version of MATLAB
0265 % handles    structure with handles and user data (see GUIDATA)
0266 
0267 % Hints: contents = get(hObject,'String') returns modname contents as cell array
0268 %        contents{get(hObject,'Value')} returns selected item from modname
0269 warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0270 list=get(handles.modname,'String');
0271 %handle particular bug with matlab(7.10.0499) and mac (OSX 10.6.4)
0272 if length(list)==1
0273     set(handles.modname,'Value',1)
0274 end
0275 
0276 if any(strfind(list{get(handles.modname,'Value')}, 'Enter'))
0277     modname=prt_text_input('Title','Enter modality name');
0278     if isnumeric(modname)
0279         return
0280     end
0281     if ~any(strcmpi(list,modname))
0282         nlist=[list;{modname}];
0283     else
0284         beep
0285         disp('This modality has already been set for the selected subject')
0286         set(handles.modname,'String',list);
0287         valall=strfind(list,'Enter');
0288         for i=1:length(valall)
0289             if ~isempty(valall{i})
0290                 val=i;
0291                 break
0292             end
0293         end
0294         set(handles.modname,'Value',val);
0295         return               
0296     end     
0297     set(handles.modname,'String',nlist);
0298     set(handles.modname,'Value',length(nlist));
0299 else
0300     modname=list{get(handles.modname,'Value')};
0301     if ~isempty(handles.subjmod)
0302         if any(strcmpi(handles.subjmod,modname))
0303             set(handles.modname,'String',list);
0304             valall=strfind(list,'Enter');
0305             if length(valall)==1 && isempty(valall{1}) %case of reviewing the modality
0306                 val=1;
0307                 set(handles.modname,'Value',val);
0308             else    %user tries to give a name he already used
0309                 beep
0310                 disp('This modality has already been set for the selected subject')            
0311                 for i=1:length(valall)
0312                     if ~isempty(valall{i})
0313                         val=i;
0314                         break
0315                     end
0316                 end
0317                 set(handles.modname,'Value',val);
0318                 return
0319             end
0320         end
0321     end         
0322 end
0323 
0324 %if a subject was previously entered, then propose to replicate its design
0325 %if the modality is the same
0326 if isstruct(handles.subj1)
0327     if any(strcmpi(modname, {handles.subj1(:).mod_name}))
0328         handles.indmods1=find(strcmpi(modname, {handles.subj1(:).mod_name}));
0329         list=get(handles.design_menu,'String');
0330         list=[list;{'Replicate design of subject 1'}];
0331         set(handles.design_menu,'String',list);
0332     end
0333 end
0334 handles.mod.name=modname;
0335 % Update handles structure
0336 guidata(hObject, handles);
0337 
0338 
0339 % --- Executes during object creation, after setting all properties.
0340 function modname_CreateFcn(hObject, eventdata, handles)
0341 % hObject    handle to modname (see GCBO)
0342 % eventdata  reserved - to be defined in a future version of MATLAB
0343 % handles    empty - handles not created until after all CreateFcns called
0344 
0345 % Hint: popupmenu controls usually have a white background on Windows.
0346 %       See ISPC and COMPUTER.
0347 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0348     set(hObject,'BackgroundColor','white');
0349 end
0350 
0351 % --- Executes on selection change in design_menu.
0352 function design_menu_Callback(hObject, eventdata, handles)
0353 % hObject    handle to design_menu (see GCBO)
0354 % eventdata  reserved - to be defined in a future version of MATLAB
0355 % handles    structure with handles and user data (see GUIDATA)
0356 
0357 % Hints: contents = get(hObject,'String') returns design_menu contents as cell array
0358 %        contents{get(hObject,'Value')} returns selected item from design_menu
0359 choice=get(handles.design_menu,'Value');
0360 %Mac and Matlab versions strange things with popup menus
0361 if choice==0
0362     choice=handles.desnmenu;
0363     set(handles.design_menu,'Value')
0364 end
0365 if choice==1
0366     desn=spm_select(1,'mat','Select SPM.mat file',[],[],'SPM.mat');
0367     try
0368         load(desn);
0369     catch
0370         beep
0371         disp('Can not load SPM.mat file');
0372         return
0373     end
0374     conds=struct();
0375     list={};
0376     for sspm=1:length(SPM.Sess)
0377         ncond = length(SPM.Sess(sspm).U);
0378         for c = 1:ncond
0379             if sspm==1  %set the conditions
0380                 conds(c).cond_name = SPM.Sess(sspm).U(c).name{1};
0381                 list=[list, {conds(c).cond_name}];
0382                 conds(c).onsets = SPM.Sess(sspm).U(c).ons;
0383                 if length(SPM.Sess(sspm).U(c).dur)==1
0384                     conds(c).durations=repmat(SPM.Sess(sspm).U(c).dur,...
0385                         numel(conds(c).onsets),1);
0386                 else
0387                     conds(c).durations = SPM.Sess(sspm).U(c).dur;
0388                 end
0389                 indcond=ncond;
0390             else  %for other sessions, look if the conditions are the same
0391                 name_cond=SPM.Sess(sspm).U(c).name{1};
0392                 itoadd=find(strcmpi(name_cond,list));
0393                 if isempty(itoadd)  % if not, then add condition
0394                     indcond=indcond+1;
0395                     conds(indcond).cond_name = SPM.Sess(sspm).U(c).name{1};
0396                     conds(indcond).onsets = SPM.Sess(sspm).U(c).ons;
0397                     if length(SPM.Sess(sspm).U(c).dur)==1
0398                         conds(indcond).durations=repmat(SPM.Sess(sspm).U(c).dur,...
0399                             numel(conds(indcond).onsets),1);
0400                     else
0401                         conds(indcond).durations = SPM.Sess(sspm).U(c).dur;
0402                     end
0403                     list=[list, {name_cond}];
0404                 else               %if yes, then add the onsets
0405                     conds(itoadd).onsets    = [conds(itoadd).onsets;SPM.Sess(sspm).U(c).ons];
0406                     if length(SPM.Sess(sspm).U(c).dur)==1
0407                         tmp=repmat(SPM.Sess(sspm).U(c).dur,...
0408                             numel(SPM.Sess(sspm).U(c).ons),1);
0409                     else
0410                         tmp = SPM.Sess(sspm).U(c).dur;
0411                     end
0412                     conds(itoadd).durations = [conds(itoadd).durations;tmp];
0413                 end
0414             end
0415         end
0416     end    
0417     if strcmpi(SPM.xBF.UNITS,'scans')
0418         units=0;
0419     else
0420         units=1;
0421     end
0422     def=prt_get_defaults('datad');
0423     if isfield(handles.PRT.group,'hrfoverlap')
0424         overl=handles.PRT.group.hrfoverlap;
0425     else
0426         overl=def.hrfw;
0427     end
0428     if isfield(handles.PRT.group,'hrfdelay')
0429         del=handles.PRT.group.hrfdelay;
0430     else
0431         del=def.hrfd;
0432     end
0433     %check that TR is the same for all sessions
0434     if length(unique([SPM.xX.K(:).RT])) ~=1
0435         beep
0436         disp('Differents TR found in SPM.mat, please separate sessions')
0437         return
0438     end
0439     desn=prt_check_design(conds,SPM.xX.K(1).RT,units,overl,del);
0440     desn.covar = [];
0441 elseif choice==2
0442     if isstruct(handles.mod.design)
0443         desn=prt_data_conditions('UserData',{handles.mod.design,handles.PRT});
0444     else
0445         desn=prt_data_conditions;
0446     end
0447 elseif choice ==3
0448     desn=[];
0449 elseif choice==4
0450     desn=handles.subj1(handles.indmods1).design;
0451 end
0452 handles.mod.design=desn;
0453 if isfield(desn,'covar') && ~isempty(desn.covar)
0454     set(handles.edit_covar,'String','Entered');
0455     set(handles.edit_covar,'Visible','on');
0456     set(handles.text7, 'Visible','on')
0457 end
0458 % Update handles structure
0459 guidata(hObject, handles);
0460 
0461 % --- Executes during object creation, after setting all properties.
0462 function design_menu_CreateFcn(hObject, eventdata, handles)
0463 % hObject    handle to design_menu (see GCBO)
0464 % eventdata  reserved - to be defined in a future version of MATLAB
0465 % handles    empty - handles not created until after all CreateFcns called
0466 
0467 % Hint: popupmenu controls usually have a white background on Windows.
0468 %       See ISPC and COMPUTER.
0469 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0470     set(hObject,'BackgroundColor','white');
0471 end
0472 
0473 % --- Executes on button press in getfiles.
0474 function getfiles_Callback(hObject, eventdata, handles)
0475 % hObject    handle to getfiles (see GCBO)
0476 % eventdata  reserved - to be defined in a future version of MATLAB
0477 % handles    structure with handles and user data (see GUIDATA)
0478 if ~isempty(handles.mod.scans)
0479     sel=cellstr(handles.mod.scans);
0480 else
0481     sel=[];
0482 end
0483 t=spm_select([1 Inf],'image','Select files for the modality',sel);
0484 handles.mod.scans=t;
0485 % Update handles structure
0486 guidata(hObject, handles);
0487 
0488 
0489 function edit_regt_Callback(hObject, eventdata, handles)
0490 % hObject    handle to edit_regt (see GCBO)
0491 % eventdata  reserved - to be defined in a future version of MATLAB
0492 % handles    structure with handles and user data (see GUIDATA)
0493 
0494 % Hints: get(hObject,'String') returns contents of edit_regt as text
0495 %        str2double(get(hObject,'String')) returns contents of edit_regt as a double
0496 
0497 %first option of loading: writing the values
0498 rt=get(handles.edit_regt,'String');
0499 if isempty(rt)
0500     return
0501 end
0502 if strcmp(rt(1),'-'), nrt = 2; else nrt = 1; end
0503 if ~isnan(str2double(rt(nrt)))
0504     eval(['rte=[',rt,'];'])
0505 else
0506     try
0507         load(char(rt));
0508     catch
0509         beep
0510         disp('Could not load file or read the regression targets')
0511         disp('Please enter either a .mat file name or enter the values')
0512         return
0513     end
0514     if ~exist('rt_subj','var')
0515         beep
0516         sprintf('Regression targets file must contain ''rt_subj'' variable! ')
0517         disp('Please correct!')
0518         return
0519     else
0520         rte=rt_subj;
0521     end
0522 end
0523 handles.mod.rt_subj=rte;
0524 % Update handles structure
0525 guidata(hObject, handles);
0526 
0527 % --- Executes during object creation, after setting all properties.
0528 function edit_regt_CreateFcn(hObject, eventdata, handles)
0529 % hObject    handle to edit_regt (see GCBO)
0530 % eventdata  reserved - to be defined in a future version of MATLAB
0531 % handles    empty - handles not created until after all CreateFcns called
0532 
0533 % Hint: edit controls usually have a white background on Windows.
0534 %       See ISPC and COMPUTER.
0535 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0536     set(hObject,'BackgroundColor','white');
0537 end
0538 
0539 function edit_covar_Callback(hObject, eventdata, handles)
0540 % hObject    handle to edit_covar (see GCBO)
0541 % eventdata  reserved - to be defined in a future version of MATLAB
0542 % handles    structure with handles and user data (see GUIDATA)
0543 
0544 % Hints: get(hObject,'String') returns contents of edit_covar as text
0545 %        str2double(get(hObject,'String')) returns contents of edit_covar as a double
0546 %first option of loading: writing the values
0547 rt=get(handles.edit_covar,'String');
0548 if isempty(rt)
0549     return
0550 end
0551 if ~isnan(str2double(rt(1)))
0552     eval(['rte=[',rt,'];'])
0553 else
0554    try
0555         load(char(rt));
0556     catch
0557         beep
0558         disp('Could not load file or read the covariate values')
0559         disp('Please enter either a .mat file name or enter the values')
0560         return
0561     end
0562     if ~exist('R','var')
0563         beep
0564         sprintf('Covariates file must contain ''R'' variable! ')
0565         disp('Please correct!')
0566         return
0567     else
0568         rte=R;
0569     end
0570 end
0571 
0572 handles.mod.covar=rte;
0573 % Update handles structure
0574 guidata(hObject, handles);
0575 
0576 % --- Executes during object creation, after setting all properties.
0577 function edit_covar_CreateFcn(hObject, eventdata, handles)
0578 % hObject    handle to edit_covar (see GCBO)
0579 % eventdata  reserved - to be defined in a future version of MATLAB
0580 % handles    empty - handles not created until after all CreateFcns called
0581 
0582 % Hint: edit controls usually have a white background on Windows.
0583 %       See ISPC and COMPUTER.
0584 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0585     set(hObject,'BackgroundColor','white');
0586 end
0587 
0588 
0589 % --- Executes on button press in okbutton.
0590 function okbutton_Callback(hObject, eventdata, handles)
0591 % hObject    handle to okbutton (see GCBO)
0592 % eventdata  reserved - to be defined in a future version of MATLAB
0593 % handles    structure with handles and user data (see GUIDATA)
0594 
0595 %check that the files were selected
0596 if isempty(handles.mod.scans)
0597     beep
0598     disp('Please, select the files before returning')
0599     return
0600 end
0601 
0602 %check that the regression targets have the same number of elements as the
0603 %number of scans
0604 if ~isempty(handles.mod.rt_subj)
0605     szrt=length(handles.mod.rt_subj);
0606     if  size(handles.mod.scans,1)~=szrt
0607         beep
0608         disp('Number of regression targets must be the number of files selected! ')
0609         disp('Please correct!')
0610         return
0611     end
0612 end
0613 %check that the covariates have the same number of elements as the
0614 %number of scans
0615 if ~isempty(handles.mod.covar)
0616     szrt=size(handles.mod.covar);
0617     if  ~any(size(handles.mod.scans,1)==szrt)
0618         beep
0619         disp('Number of covariates must be the number of files selected! ')
0620         disp('Please correct!')
0621         return
0622     end
0623 end
0624         
0625 modprop=handles.mod;
0626 handles.output=modprop;
0627 % Update handles structure
0628 guidata(hObject, handles);
0629 uiresume(handles.figure1);
0630 
0631 
0632 % --- Executes on button press in cancelbutton.
0633 function cancelbutton_Callback(hObject, eventdata, handles)
0634 % hObject    handle to cancelbutton (see GCBO)
0635 % eventdata  reserved - to be defined in a future version of MATLAB
0636 % handles    structure with handles and user data (see GUIDATA)
0637 uiresume(handles.figure1);

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