function []=fmrilm_gui_cb(); Volume = get(gcf,'UserData'); Volume.LM.OutputFile.Base = get(findobj(gcf,'Tag','OutputFileBase'),'String'); Volume.LM.WStats(1) = get(findobj(gcf,'Tag','Tstat'),'Value'); Volume.LM.WStats(2) = get(findobj(gcf,'Tag','Effect'),'Value'); Volume.LM.WStats(3) = get(findobj(gcf,'Tag','SdEffect'),'Value'); Volume.LM.WStats(4) = get(findobj(gcf,'Tag','Fstat'),'Value'); Volume.LM.WStats(5) = get(findobj(gcf,'Tag','Rho'),'Value'); Volume.LM.WStats(6) = get(findobj(gcf,'Tag','Resids'),'Value'); Volume.LM.WStats(7) = get(findobj(gcf,'Tag','Wresids'),'Value'); Volume.LM.WStats(8) = get(findobj(gcf,'Tag','ARp'),'Value'); Volume.LM.FWHM_rho = str2num(get(findobj(gcf,'Tag','FWHMrho'),'String')); Volume.LM.N_Poly = str2num(get(findobj(gcf,'Tag','N_Poly'),'String')); Volume.LM.NumLags = str2num(get(findobj(gcf,'Tag','NumLags'),'String')); callfig = Volume.fig; if strcmp(get(findobj(gcf,'Tag','RefDelay'),'Style'),'edit') Volume.LM.RefDelay.RefDelay= str2num(get(findobj(gcf,'Tag','RefDelay'),'String')); end errchk=1; if (get(findobj(gcf,'Tag','InputFile'),'Value'))==1 if (get(findobj(gcf,'Tag','MultipleInFiles'),'Value'))==0 [filename,filepath]=uigetfile(['*.*'],'Choose Input Image file'); if filename d=fmris_read_image([filepath,filename],0,0); if (d.dim(4)>2) Volume.LM.Input.filename=filename; Volume.LM.Input.filepath=filepath; Volume.LM.Input.numinput=1; Volume.LM.Input.numframes=d.dim(4); set(findobj(gcf,'Tag','InputFileName'),'String',[Volume.LM.Input.filepath,Volume.LM.Input.filename]); else errordlg('Invalid Image File or X_cache Dims dont match','File Load Error'); end end else [filename,filepath]=uigetfile(['*.txt'],'Choose Input File List'); if filename FileList=load([filepath,filename]); if (size(FileList,1)>2) Volume.LM.Input.filename=filename; Volume.LM.Input.filepath=filepath; Volume.LM.Input.filelist=FileList; Volume.LM.Input.numinput=size(Volume.LM.Input.filelist,1); Volume.LM.Input.numframes=size(Volume.LM.Input.filelist,1); set(findobj(gcf,'Tag','InputFileName'),'String',[Volume.LM.Input.filepath,Volume.LM.Input.filename]); else errordlg('Invalid Image File or X_cache Dims dont match','File Load Error'); end end end elseif (get(findobj(gcf,'Tag','X_cache'),'Value'))==1 [filename,filepath]=uigetfile(['*.mat'],'Choose X_cache file'); if filename X_cache=load([filepath,filename]); errchk=1; if isfield(Volume.LM.Input,'numframes') errchk=(size(Volume.LM.Input.numframes,1)==size(X_cache,1)); end if (size(X_cache,1)>2) if ~errchk;warndlg('X_cache has different Dims to Image','X_cache Warning');end Volume.LM.X_cache.filename=filename; Volume.LM.X_cache.filepath=filepath; Volume.LM.X_cache.X_cache=X_cache; Volume.LM.X_cache.string=[Volume.LM.X_cache.filepath,Volume.LM.X_cache.filename]; set(findobj(gcf,'Tag','X_cacheName'),'String',Volume.LM.X_cache.string); else errordlg('Invalid X_cache File','File Load Error'); end end elseif (get(findobj(gcf,'Tag','Contrast'),'Value'))==1 btn=questdlg('Do you wish to manually enter a contrast?','Contrast Input','File','Keyboard','File'); if strcmp('File',btn) [filename,filepath]=uigetfile(['*.txt'],'Choose Contrast file'); if filename Contrast=load([filepath,filename]); if ~isempty(Volume.LM.X_cache.X_cache) errchk=mod(size(Volume.LM.X_cache.X_cache,2),size(Contrast,2))==0; end Volume.LM.Contrast.filename=filename; Volume.LM.Contrast.filepath=filepath; Volume.LM.Contrast.Contrast=Contrast; Volume.LM.Contrast.string=[Volume.LM.Contrast.filepath,Volume.LM.Contrast.filename]; set(findobj(gcf,'Tag','ContrastList'),'String',Volume.LM.Contrast.string); end else Contrast_str=inputdlg('Enter Contrast in Matlab notation ( ; separates lines)','Contrast'); Volume.LM.Contrast.string=(cat(1,Contrast_str{:})); if ~isempty(Contrast_str) str=['Volume.LM.Contrast.Contrast=' cat(1,Contrast_str{:}) ';'];Volume.LM.Contrast.Error=0; Volume.LM.Contrast.filepath=[];Volume.LM.Contrast.filename=[]; eval(str,'errordlg(''Invalid Matlab Command'');Volume.LM.Contrast.Error=1;'); if (Volume.LM.Contrast.Error==1)|(length(size(Volume.LM.Contrast.Contrast))~=2) Volume.LM.Contrast.Contrast=1; Volume.LM.Contrast.string='ERROR - Using Default (1)'; end set(findobj(gcf,'Tag','ContrastList'),'String',Volume.LM.Contrast.string); if ~isempty(Volume.LM.X_cache.X_cache);if mod(size(Volume.LM.X_cache.X_cache,2),size(Volume.LM.Contrast.Contrast,2)-Volume.LM.N_Poly-1)~=0;warndlg('Contrast has different number of rows than expected','Contrast Warning');end;end end end elseif (get(findobj(gcf,'Tag','Exclude'),'Value'))==1 btn=questdlg('Do you wish to manually enter excluded frames?','Exclude Input','File','Keyboard','File'); if strcmp('File',btn) [filename,filepath]=uigetfile(['*.txt'],'Choose Exclude file'); if filename Exclude=load([filepath,filename]); if (isfield(Volume.LM.X_cache,'X_cache')) errchk=(size(Volume.LM.X_cache.X_cache,1)>length(Exclude)); end if errchk&((size(Exclude,1)==1)|(size(Exclude,2)==1)) Volume.LM.Exclude.filename=filename; Volume.LM.Exclude.filepath=filepath; Volume.LM.Exclude.Exclude=Exclude(:)'; Volume.LM.Exclude.string=[Volume.LM.Exclude.filepath,Volume.LM.Exclude.filename]; set(findobj(gcf,'Tag','ExcludeList'),'String',Volume.LM.Exclude.string); else errordlg('Invalid Exclude File or X_cache Dims dont match','File Load Error'); end end else Exclude_str=inputdlg('Enter Exclude in one line','Exclude'); Exclude=str2num(cat(1,Exclude_str{:})); if ~isempty(Volume.LM.X_cache.X_cache) errchk=(size(Volume.LM.X_cache.X_cache,1)>length(Exclude)); end if (size(Exclude,1)==1|size(Exclude,2)==1) Volume.LM.Exclude.Exclude=Exclude(:)'; Volume.LM.Exclude.string=num2str(Volume.LM.Exclude.Exclude); set(findobj(gcf,'Tag','ExcludeList'),'String',Volume.LM.Exclude.string); else errordlg('Invalid Exclude Input or X_cache Dims dont match','Exclude Error'); end end elseif (get(findobj(gcf,'Tag','Confound'),'Value'))==1 btn=questdlg('Do you wish to manually enter confounds?','Confound Input','File','Keyboard','File'); if strcmp('File',btn) [filename,filepath]=uigetfile(['*.txt'],'Choose Confound file'); if filename Confound=load([filepath,filename]); if ~isempty(Volume.LM.X_cache,'X_cache') errchk=(size(Volume.LM.X_cache.X_cache,1)==size(Contrast,1)); end if ~errchk;warndlg('Confound has diff rows to X_cache','Confound Warning');end Volume.LM.Confound.filename=filename; Volume.LM.Confound.filepath=filepath; Volume.LM.Confound.Confound=Confound; Volume.LM.Confound.string=[Volume.LM.Confound.filepath,Volume.LM.Confound.filename]; set(findobj(gcf,'Tag','ConfoundMatrix'),'String',Volume.LM.Confound.string); end else Confound_str=inputdlg('Enter Confound in Matlab notation (no brackets ; separates lines)','Confound'); if ~isempty(Confound_str) Volume.LM.Confound.string=cat(1,Confound_str{:}); str=['Volume.LM.Confound.Confound=' cat(1,Confound_str{:}) ';'];Volume.LM.Confound.Error=0; Volume.LM.Confound.filepath=[];Volume.LM.Confound.filename=[]; eval(str,'errordlg(''Invalid Matlab Command'');Volume.LM.Confound.Error=1;');errchk=1; if isfield(Volume.LM.X_cache,'X_cache')&Volume.LM.Confound.Error==0 errchk=(size(Volume.LM.X_cache.X_cache,1)==size(Volume.LM.Confound.Confound,1)); if ~errchk Volume.LM.Confound.Confound=Volume.LM.Confound.Confound'; errchk=(size(Volume.LM.X_cache.X_cache,1)==size(Volume.LM.Confound.Confound,1)); end elseif Volume.LM.Confound.Error==1 errchk=0; end if ~errchk if Volume.LM.Confound.Error==0 errordlg('Invalid Confound, X_cache Dims dont match','Confound Error'); end Volume.LM.Confound.string='Error';Volume.LM.Confound.Confound=[]; end set(findobj(gcf,'Tag','ConfoundMatrix'),'String',Volume.LM.Confound.string); else errordlg('Invalid Confound','Confound Error'); end end elseif (get(findobj(gcf,'Tag','DelayContrast'),'Value'))==1 Volume.LM.Vect.funct='DC';Volume.LM.Vect.Error=1; if ~isempty(Volume.LM.X_cache.X_cache) Volume.LM.Vect.Error=1;set(gcf,'UserData',Volume);vectget(Volume);Volume = get(gcf,'UserData'); if ~Volume.LM.Vect.Error set(findobj(gcf,'Tag','DelayContrastList'),'String',num2str(Volume.LM.DelayCont)); end else errordlg('Please Define X_cache First','Sequence Error'); end elseif (get(findobj(gcf,'Tag','MultiRefDelay'),'Value'))==1 Volume.LM.Vect.funct='RD';Volume.LM.Vect.Error=1; if ~isempty(Volume.LM.X_cache.X_cache) Volume.LM.Vect.Error=1;set(gcf,'UserData',Volume);vectget(Volume);Volume = get(gcf,'UserData'); if ~Volume.LM.Vect.Error set(findobj(gcf,'Tag','RefDelay'),'Style','listbox','String',Volume.LM.RefDelay.string,'ListboxTop',1); end else errordlg('Please Define X_cache First','Sequence Error'); end elseif (get(findobj(gcf,'Tag','DefineFile'),'Value'))==1 [Volume.LM.Define.filename,Volume.LM.Define.filepath]=uigetfile(['*.mat'],'Choose Definition File (matlab file)'); if Volume.LM.Define.filename Define=load([Volume.LM.Define.filepath,Volume.LM.Define.filename]); if isfield(Define,'Volume') if isfield(Define.Volume,'LM') Volume=Define.Volume; if isfield(Volume.LM.Input,'filename');set(findobj(gcf,'Tag','InputFileName'),'String',[Volume.LM.Input.filepath,Volume.LM.Input.filename]);end if isfield(Volume.LM.Input,'numinputs');if Volume.LM.Input.numinputs > 1;set(findobj(gcf,'Tag','MultipleInFiles'),'Value',1);end;end if isfield(Volume.LM.X_cache,'string');set(findobj(gcf,'Tag','X_cacheName'),'String',Volume.LM.X_cache.string);end if isfield(Volume.LM.Contrast,'string');set(findobj(gcf,'Tag','ContrastList'),'String',Volume.LM.Contrast.string);end if isfield(Volume.LM.Exclude,'string');set(findobj(gcf,'Tag','ExcludeList'),'String',Volume.LM.Exclude.string);end else if isfield(Define.Volume,'X_cache'); Volume.LM.X_cache.string = 'Using previously Defined X_cache from Define File'; Volume.LM.X_cache.X_cache = Define.Volume.X_cache; set(findobj(gcf,'Tag','X_cacheName'),'String',Volume.LM.X_cache.string); else errordlg('Invalid Definitions File','File Load Error'); end end else errordlg('Invalid Definitions File','File Load Error'); end end end if isfield(Volume.LM,'RefDelay') if size(Volume.LM.RefDelay.RefDelay,2)==1; set(findobj(gcf,'Tag','RefDelay'),'Style','edit','String',num2str(Volume.LM.RefDelay.RefDelay)); end end set(findobj(gcf,'Tag','OutputFileBase'),'String',Volume.LM.OutputFile.Base); set(findobj(gcf,'Tag','Tstat'),'Value',Volume.LM.WStats(1)); set(findobj(gcf,'Tag','Effect'),'Value',Volume.LM.WStats(2)); set(findobj(gcf,'Tag','SdEffect'),'Value',Volume.LM.WStats(3)); set(findobj(gcf,'Tag','Fstat'),'Value',Volume.LM.WStats(4)); set(findobj(gcf,'Tag','Rho'),'Value',Volume.LM.WStats(5)); set(findobj(gcf,'Tag','Resids'),'Value',Volume.LM.WStats(6)); set(findobj(gcf,'Tag','Wresids'),'Value',Volume.LM.WStats(7)); set(findobj(gcf,'Tag','ARp'),'Value',Volume.LM.WStats(8)); set(findobj(gcf,'Tag','FWHMrho'),'String',num2str(Volume.LM.FWHM_rho)); set(findobj(gcf,'Tag','N_Poly'),'String',num2str(Volume.LM.N_Poly)); set(findobj(gcf,'Tag','NumLags'),'String',num2str(Volume.LM.NumLags)); Volume.fig=callfig; if isfield(Volume.LM.Input,'numframes')&(~isempty(Volume.LM.OutputFile.Base))&(~isempty(Volume.LM.X_cache.X_cache))&(~isempty(Volume.LM.Contrast.Contrast)) if (Volume.LM.Input.numframes==size(Volume.LM.X_cache.X_cache,1)) Volume.LM.Status='OK'; else Volume.LM.Status='Dimensional Error'; end else Volume.LM.Status='Variable Input Missing'; end set(gcf,'UserData',Volume); return; function vectget(Volume); col1 = [0.2 0.6 0.9];col2 = col1*0.9;col3 = [1 1 1];col4 = col2*1;col5 = col1*.8;screen = get(0,'ScreenSize');font_size = round((screen(3)-400)/200)+3;font_name = 'Helvetica'; Volume.LM.Vect.numvec=size(Volume.LM.X_cache.X_cache,2);numlines=ceil(Volume.LM.Vect.numvec/6);numlast=mod(Volume.LM.Vect.numvec,6);if numlast==0;numlast=6;end hnorm=1/(numlines+1);thnorm=0.05/(0.05+0.05*numlines);Volume.LM.Vect.Error=1; pos=[0.3 0.4 0.5 0.05+0.05*numlines]; if strcmp(Volume.LM.Vect.funct,'DC') figstr='Delay Contrast';boxtype='popupmenu';boxstr=['0';'1']; elseif strcmp(Volume.LM.Vect.funct,'RD') figstr='Reference Delay';boxtype='edit';boxstr='0'; end h2=figure('Units','normalized','Color',col1,'Name',figstr,'NumberTitle','off','Resize','off','Position',pos,'Tag','RespVs');set(gcf,'UserData',Volume); xpos=[0.08 0.23 0.38 0.53 0.68 0.83]; call_str=['Volume=get(gcf,''Userdata'');Volume=fmris_vect_cb(Volume);if ~Volume.LM.Vect.Error;delete(gcf);set(gcf,''Userdata'',Volume);uiresume;end']; h1 = uicontrol('Parent',h2,'Units','normalized','BackgroundColor',col5,'CallBack',call_str ,'ListboxTop',0,'Position',[0.82 0.01 0.15 thnorm*0.4],'String','Accept','Style','pushbutton','Tag','Push1'); for i=1:(numlines-1) for j=1:6 h1 = uicontrol('Parent',h2,'Units','normalized','BackgroundColor',[1 1 1],'ListboxTop',0,'Position',[xpos(j) (numlines-i+0.5)*hnorm 0.11 0.45*thnorm],'Style',boxtype,'String',boxstr,'Tag',['Rep_' num2str((i-1)*6+j)]); h1 = uicontrol('Parent',h2,'Units','normalized','BackgroundColor',col4,'ListboxTop',0,'Position',[xpos(j) (numlines-i+0.5)*hnorm+0.5*thnorm 0.11 0.45*thnorm],'String',['Resp ',num2str((i-1)*6+j)],'Style','text','Tag','StaticText1'); end end i=numlines; for j=1:numlast h1 = uicontrol('Parent',h2,'Units','normalized','BackgroundColor',[1 1 1],'ListboxTop',0,'Position',[xpos(j) (numlines-i+0.5)*hnorm 0.11 0.45*thnorm],'Style',boxtype,'String',boxstr,'Tag',['Rep_' num2str((i-1)*6+j)]); h1 = uicontrol('Parent',h2,'Units','normalized','BackgroundColor',col4,'ListboxTop',0,'Position',[xpos(j) (numlines-i+0.5)*hnorm+0.5*thnorm 0.11 0.45*thnorm],'String',['Resp ',num2str((i-1)*6+j)],'Style','text','Tag','StaticText1'); end set(gcf,'Userdata',Volume); uiwait; return;