function varargout=conn(varargin) connver='13.h'; disp(varargin) global CONN_h CONN_x CONN_refs if nargin<1, connversion={'CONN fMRI connectivity tool',' (',connver,') '}; hfig=findobj('tag',connversion{1}); if ~isempty(hfig),return;end CONN_h=struct; conn init; conn importrois; CONN_x.gui=1; c=.5*[0,0,2/6]+.5*[.5/6,1/6,2/6]; CONN_h.screen.colormap=max(0,min(1, diag((1-linspace(1,0,256)'.^10))*[gray(128);jet(128)]+(linspace(1,0,256)'.^10)*c/2 )); h0=get(0,'screensize'); CONN_h.screen.hfig=figure('units','pixels','position',[2,h0(4)-min(460,.3375*h0(3))-48,h0(3)-2,min(460,.3375*h0(3))],'color',c,'doublebuffer','on','tag',connversion{1},'name',strcat(connversion{:}),'numbertitle','off','menubar','none','resize','on','colormap',CONN_h.screen.colormap); conn_menumanager on; CONN_h.menus.m0=conn_menumanager([], 'n',4,... 'string',{'Setup','Preprocessing','first-level Analyses','second-level Results'},... 'help',{'Define/Edit experiment setup','Define/Edit preprocessing options','Define/Edit first-level analysis options','Define/Edit second-level analyses'},... 'order','horizontal',... 'state',[1,0,0,0],... 'toggle',1,... 'position',[.0,.94,.97,.06],... 'dposition',[0,0],...%-.005],... 'bordertype','square',... 'fontweight','bold',... 'fontangle','italic',... 'fontsize',9,... 'callback',{{@conn,'gui_setup'},{@conn,'gui_preproc'},{@conn,'gui_analyses'},{@conn,'gui_results'}} ); CONN_h.menus.m_setup_07=conn_menumanager([], 'n',6,... 'string',{'Updates','Documentation','Forum','FAQ','NITRC site','SPM site'},... 'help',{'Checks for software updates','Open manual','Browse www.nitrc.org/forum/forum.php?forum_id=1144','Browse www.alfnie.com/software/conn','Browse www.nitrc.org/projects/conn','Browse www.fil.ion.ucl.ac.uk/spm'},... 'order','vertical',... 'toggle',0,... 'position',[.92,.69,.08,6*.04],... 'fontsize',8,... 'fontweight','bold',... 'bordertype','square',... 'callback',{{@conn_update,connver},{@conn,'gui_help','doc'},{@conn,'gui_help','url','http://www.nitrc.org/forum/forum.php?forum_id=1144'},{@conn,'gui_help','url','http://www.alfnie.com/software/conn'},{@conn,'gui_help','url','http://www.nitrc.org/projects/conn'},{@conn,'gui_help','url','http://www.fil.ion.ucl.ac.uk/spm'}} ); CONN_h.menus.m_setup_06=conn_menumanager([], 'n',1,... 'string',{'Help'},... 'help',{'Help'},... 'order','vertical',... 'toggle',0,... 'position',[.97,.94,.03,.06],... 'fontsize',9,... 'bordertype','square',... 'callback',{CONN_h.menus.m_setup_07} ); CONN_h.menus.m_setup_01=conn_menumanager([], 'n',6,... 'string',{'New','Load','Save','Save as','Merge','Import'},... 'help',{'Starts a new experiment','Loads experiment information','Saves current experiment information','Saves current experiment to a different file','Merge other experiment files with the current experiment','Imports experiment information from SPM.mat files'},... 'order','horizontal',... 'toggle',0,... 'position',[.0,.88,6*.06,.05],... 'fontsize',8,... 'callback',{{@conn,'gui_setup_new'},{@conn,'gui_setup_load'},{@conn,'gui_setup_save'},{@conn,'gui_setup_saveas'},{@conn,'gui_setup_merge'},{@conn,'gui_setup_import'}} ); CONN_h.menus.m_setup_01b=conn_menumanager([], 'n',1,... 'string',{'Done'},... 'help',{'Finish setup and prepares data for analysis'},... 'position',[.4,.88,.06,.05],... 'toggle',0,... 'fontsize',8,... 'fontangle','normal',... 'bordertype','round',... 'callback',{{@conn,'gui_setup_finish'}} ); CONN_h.menus.m_setup_03=conn_menumanager([], 'n',2,... 'string',{'First level','Second level'},... 'help',{'Defines 1st level (within subject) covariates','Defines 2nd level (between subject) covariates'},... 'toggle',1,... 'position',[.085,.45,.08,2*.05],... 'fontsize',8,... 'bordertype','square',... 'callback',{{@conn,'gui_setup_covariates'},{@conn,'gui_setup_covariates'}} ); CONN_h.menus.m_setup_02=conn_menumanager([], 'n',7,... 'string',{'Basic','Functional','Structural','ROIs','Conditions','Covariates','Options'},... 'help',{'Defines basic experimental setup','Defines functional data source files','Defines structural data source files','Defines regions of interest','Defines experimental conditions','Defines first or second level covariates','Defines processing options'},... 'state',[1,0,0,0,0,0,0],... 'value',1,... 'toggle',1,... 'position',[.005,.5-.05,.08,7*.05],... 'fontsize',8,... 'bordertype','square',... 'callback',{{@conn,'gui_setup'},{@conn,'gui_setup'},{@conn,'gui_setup'},{@conn,'gui_setup'},{@conn,'gui_setup'},CONN_h.menus.m_setup_03,{@conn,'gui_setup'}} ); CONN_h.menus.m_setup_04=conn_menumanager([], 'n',1,... 'string',{'Done'},... 'help',{'Press ''Done'' to finish importing SPM files'},... 'position',[.0,.88,.05,.05],... 'toggle',0,... 'fontsize',8,... 'fontangle','normal',... 'bordertype','round',... 'callback',{{@conn,'gui_setup_importdone'}} ); CONN_h.menus.m_setup_05=conn_menumanager([], 'n',1,... 'string',{'Done'},... 'help',{'Press ''Done'' to finish selecting CONN_* files'},... 'position',[.0,.88,.05,.05],... 'toggle',0,... 'fontsize',8,... 'fontangle','normal',... 'bordertype','round',... 'callback',{{@conn,'gui_setup_mergedone'}} ); CONN_h.menus.m_preproc_01=conn_menumanager([], 'n',1,... 'string',{'>>'},... 'help',{''},... 'toggle',0,... 'position',[.128,.5,.02,.05],... 'backgroundcolor',get(CONN_h.screen.hfig,'color')/2,... 'callback',{{@conn,'gui_preproc',0}} ); CONN_h.menus.m_preproc_02=conn_menumanager([], 'n',1,... 'string',{'Done'},... 'help',{'Press ''Done'' to start preprocessing all data'},... 'position',[.0,.88,.05,.05],... 'toggle',0,... 'fontsize',8,... 'fontangle','normal',... 'bordertype','round',... 'callback',{{@conn,'gui_preproc_done'}} ); CONN_h.menus.m_analyses_01=conn_menumanager([], 'n',1,... 'string',{'>>'},... 'help',{''},... 'toggle',0,... 'position',[.178,.5,.02,.05],... 'backgroundcolor',get(CONN_h.screen.hfig,'color')/2,... 'callback',{{@conn,'gui_analyses',0}} ); CONN_h.menus.m_analyses_02=conn_menumanager([], 'n',1,... 'string',{'Done'},... 'help',{'Press ''Done'' to start analyzing all data'},... 'position',[.0,.88,.05,.05],... 'toggle',0,... 'fontsize',8,... 'fontangle','normal',... 'bordertype','round',... 'callback',{{@conn,'gui_analyses_done'}} ); CONN_h.menus.m_analyses_03=conn_menumanager([], 'n',2,... 'string',{{'ROI-to-ROI','Seed-to-Voxel'},'Voxel-to-Voxel'},... 'help',{'Define/explore ROI/seed sources for first-level analyses','Define/explore voxel-to-voxel measures for first-level analyses'},... 'order','vertical',... 'position',[.005,.65,.08,3*.05],...%[.0,.68,.07,3*.05],... 'state',[1,0],... 'value',1,... 'toggle',1,... 'fontsize',8,... 'bordertype','square',... 'callback',{{@conn,'gui_analyses'},{@conn,'gui_analyses'}} ); CONN_h.menus.m_analyses_04=conn_menumanager([], 'n',1,... 'string',{'Done'},... 'help',{'Press ''Done'' to start analyzing all data'},... 'position',[.0,.88,.05,.05],... 'toggle',0,... 'fontsize',8,... 'fontangle','normal',... 'bordertype','round',... 'callback',{{@conn,'gui_analyses_done_vv'}} ); CONN_h.menus.m_results_03=conn_menumanager([], 'n',3,... 'string',{'ROI-to-ROI','Seed-to-Voxel','Voxel-to-Voxel'},... 'help',{'Define/explore ROI-to-ROI second-level analyses','Define/explore seed-to-voxel second-level analyses','Define/explore voxel-to-voxel second-level analyses'},... 'order','vertical',... 'position',[.005,.68,.08,3*.05],...%[.0,.68,.07,3*.05],... 'state',[1,0,0],... 'value',1,... 'toggle',1,... 'fontsize',8,... 'bordertype','square',... 'callback',{{@conn,'gui_results'},{@conn,'gui_results'},{@conn,'gui_results'}} ); CONN_h.menus.m_results_04=conn_menumanager([], 'n',2,... 'string',{'ROI-to-ROI results explorer','Graph theory results explorer'},... 'help',{'Graphic display of current ROI-to-ROI second-level results','Graphic display of current graph-theory second-level analyses'},... 'order','horizontal',... 'position',[.0,.88,2*.2,.05],...%[.0,.68,.07,3*.05],... 'toggle',0,... 'fontsize',8,... 'fontangle','normal',... 'bordertype','round',... 'callback',{{@conn,'gui_results_roiview'},{@conn,'gui_results_graphtheory'}} ); CONN_h.menus.m_results_05=conn_menumanager([], 'n',2,... 'string',{'Seed-to-voxel results explorer','Compute results for all sources'},... 'help',{'Whole-brain display of current seed-to-voxel second-level results','Performs group analyses for all sources'},... 'order','horizontal',... 'position',[.0,.88,2*.2,.05],...%[.0,.68,.07,3*.05],... 'toggle',0,... 'fontsize',8,... 'fontangle','normal',... 'bordertype','round',... 'callback',{{@conn,'gui_results_wholebrain'},{@conn,'gui_results_done'}} ); CONN_h.menus.m_results_06=conn_menumanager([], 'n',2,... 'string',{'Voxel-to-voxel results explorer','Compute results for all measures'},... 'help',{'Whole-brain display of current voxel-to-voxel measure second-level results','Performs group analyses for all measures'},... 'order','horizontal',... 'position',[.0,.88,2*.2,.05],...%[.0,.68,.07,3*.05],... 'toggle',0,... 'fontsize',8,... 'fontangle','normal',... 'bordertype','round',... 'callback',{{@conn,'gui_results_wholebrain_vv'},{@conn,'gui_results_done_vv'}} ); conn gui_setup; else switch(lower(varargin{1})), case 'init', CONN_x=struct('name',[],'filename','','gui',1,'state',0,'ver',connver,... 'folders',struct('rois',fullfile(fileparts(which(mfilename)),'rois'),'data',[],'preprocessing',[],'firstlevel',[],'secondlevel',[]),... 'Setup',struct(... 'RT',2,'nsubjects',1,'nsessions',1,'fwhm',12,'reorient',eye(4),'normalized',1,... 'functional',{{}},... 'structural',{{}},... 'spm',{{}},... 'nscans',{{}},.... 'rois', struct('names',{{}},'files',{{}},'dimensions',{{}},'mask',[]),... 'conditions', struct('names',{{}},'values',{{}}),... 'l1covariates', struct('names',{{}},'files',{{}}),... 'l2covariates', struct('names',{{}},'values',{{}}),... 'acquisitiontype',1,... 'steps',[1,1,1],... 'spatialresolution',1,... 'analysismask',1,... 'outputfiles',[0,0,0] ),... 'Preproc',struct(... 'variables', struct('names',{{}},'types',{{}},'deriv',{{}},'dimensions',{{}}),... 'confounds', struct('names',{{}},'types',{{}},'deriv',{{}},'dimensions',{{}}),... 'filter',[0.008,0.09]),... 'Analyses',struct(... 'name','ANALYSIS_01',... 'sourcenames',{{}},... 'variables', struct('names',{{}},'types',{{}},'deriv',{{}},'dimensions',{{}}),... 'regressors', struct('names',{{}},'types',{{}},'deriv',{{}},'dimensions',{{}}),... 'type',[],... 'measure',[],... 'weight',[]),... 'Analysis',1,... 'vvAnalyses',struct(... 'measurenames',{{}},... 'variables', conn_v2v('measures'),... 'regressors', conn_v2v('empty') )); CONN_x.Setup.functional{1}{1}={[],[],[]}; CONN_x.Setup.nscans{1}{1}=0; CONN_x.Setup.spm{1}={[],[],[]}; CONN_x.Setup.conditions.values{1}{1}{1}={}; CONN_x.Setup.conditions.names={' '}; CONN_x.Setup.l1covariates.files{1}{1}{1}={[],[],[]}; CONN_x.Setup.l1covariates.names={' '}; CONN_x.Setup.l2covariates.values{1}{1}=1; CONN_x.Setup.l2covariates.names={'All',' '}; filename=fullfile(fileparts(which('spm')),'canonical','avg152T1.nii'); [V,str,icon]=conn_getinfo(filename); CONN_x.Setup.structural{1}={filename,str,icon}; CONN_refs.canonical=struct('filename',filename,'V',V,'data',spm_read_vols(V)); [x,y,z]=ndgrid(1:CONN_refs.canonical.V.dim(1),1:CONN_refs.canonical.V.dim(2),1:CONN_refs.canonical.V.dim(3)); CONN_refs.canonical.xyz=CONN_refs.canonical.V.mat*[x(:),y(:),z(:),ones(numel(z),1)]'; CONN_x.Setup.rois.files{1}{1}={[],[],[]};%{filename,str,icon}; CONN_x.Setup.rois.files{1}{2}={[],[],[]};%{filename,str,icon}; CONN_x.Setup.rois.files{1}{3}={[],[],[]};%{filename,str,icon}; CONN_x.Setup.rois.names={'Grey Matter','White Matter','CSF',' '}; CONN_x.Setup.rois.dimensions={1,16,16}; CONN_x.Setup.rois.mask=[0,0,0]; CONN_x.Setup.rois.multiplelabels=[0,0,0]; CONN_x.Setup.rois.regresscovariates=[0,1,1]; %filename=fullfile(fileparts(which('conn')),'utils','otherrois','talairach.nii'); %filename=fullfile(fileparts(which('conn')),'utils','otherrois','TDb.img'); %filename=fullfile(fileparts(which('conn')),'rois','aal.nii'); filename=fullfile(fileparts(which('conn')),'rois','BA.img'); [filename_path,filename_name,filename_ext]=fileparts(filename); V=spm_vol(filename); CONN_refs.rois=struct('filename',filename_name,'V',V,'data',spm_read_vols(V),'labels',{textread(fullfile(filename_path,[filename_name,'.txt']),'%s','delimiter','\n')}); case 'close', connversion={'CONN fMRI connectivity tool',' (',connver,') '}; hfig=findobj('tag',connversion{1}); if ~isempty(hfig)&&ishandle(hfig), close(hfig); CONN_h=[];CONN_x=[];CONN_refs=[]; return; end case 'importrois', if ~isfield(CONN_x.folders,'rois'), CONN_x.folders.rois=fullfile(fileparts(which(mfilename)),'rois'); end path=CONN_x.folders.rois; names=cat(1,dir(fullfile(path,'*.nii')),dir(fullfile(path,'*.img')),dir(fullfile(path,'*.tal'))); n0=length(CONN_x.Setup.rois.names)-1; for n1=1:length(names), [nill,name,nameext]=fileparts(names(n1).name); filename=fullfile(path,names(n1).name); [V,str,icon]=conn_getinfo(filename); CONN_x.Setup.rois.names{n0+n1}=name; CONN_x.Setup.rois.names{n0+n1+1}=' '; for nsub=1:CONN_x.Setup.nsubjects, CONN_x.Setup.rois.files{nsub}{n0+n1}={filename,str,icon}; end CONN_x.Setup.rois.dimensions{n0+n1}=1; CONN_x.Setup.rois.mask(n0+n1)=0; CONN_x.Setup.rois.multiplelabels(n0+n1)=(strcmp(nameext,'.img')|strcmp(nameext,'.nii'))&(~isempty(dir(conn_prepend('',filename,'.txt')))|~isempty(dir(conn_prepend('',filename,'.csv')))|~isempty(dir(conn_prepend('',filename,'.xls')))); CONN_x.Setup.rois.regresscovariates(n0+n1)=double(CONN_x.Setup.rois.dimensions{n0+n1}>1); end case 'load', if nargin>1,filename=varargin{2}; else filename=CONN_x.filename;end if isempty(filename)||~ischar(filename), disp('warning: invalid filename, project NOT loaded'); else try load(filename,'CONN_x'); CONN_x.filename=conn_fullfile(filename); catch %#ok<*CTCH> error(['Failed to load file ',filename,'.']); return; end try, conn_updatefilepaths; end conn_updatefolders; end case 'save', if nargin>1, filename=varargin{2}; else filename=CONN_x.filename; end if isempty(filename)||~ischar(filename), error('invalid filename, project NOT saved'); else CONN_x.filename=conn_fullfile(filename); conn_updatefolders; try save(filename,'CONN_x'); % if str2num(version('-release'))>=14, save(filename,'-V6','CONN_x'); % else save(filename,'CONN_x'); end catch error(['Failed to save file ',filename,'. Check file name and/or folder permissions']); end if isfield(CONN_x,'Analyses') for ianalysis=1:numel(CONN_x.Analyses) if isfield(CONN_x.Analyses(ianalysis),'name')&&isfield(CONN_x.Analyses(ianalysis),'sourcenames') filesourcenames=fullfile(CONN_x.folders.firstlevel,CONN_x.Analyses(ianalysis).name,'_list_sources.mat'); sourcenames=CONN_x.Analyses(ianalysis).sourcenames; save(filesourcenames,'sourcenames'); end end end if isfield(CONN_x,'vvAnalyses') if isfield(CONN_x.vvAnalyses,'measurenames') filemeasurenames=fullfile(CONN_x.folders.firstlevel,'_list_measures.mat'); measurenames=CONN_x.vvAnalyses.measurenames; save(filemeasurenames,'measurenames'); end end end case 'gui_help', switch(lower(varargin{2})) case 'url' web(varargin{3},'-browser'); case 'doc' if nargin<3 name=dir(fullfile(fileparts(which(mfilename)),'CONN_fMRI_Functional_connectivity_toolbox_manual*.pdf')); if ~isempty(name) open(fullfile(fileparts(which(mfilename)),name(1).name)); end else open(varargin{3}); end end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'gui_setup', CONN_x.gui=1; state=find(conn_menumanager(CONN_h.menus.m_setup_02,'state')); if nargin<2, conn_menumanager clf; axes('units','norm','position',[0,.935,1,.005]); image(shiftdim(1-get(CONN_h.screen.hfig,'color'),-1)); axis off; tstate=conn_menumanager(CONN_h.menus.m0,'state'); tstate(:)=0;tstate(1)=1; conn_menumanager(CONN_h.menus.m0,'state',tstate); %conn_menu('frame',[.015-.001,.5-.05-.001,.07+.002,7*.05+.002],''); conn_menumanager([CONN_h.menus.m_setup_02,CONN_h.menus.m_setup_01,CONN_h.menus.m_setup_01b,CONN_h.menus.m_setup_06,CONN_h.menus.m0],'on',1); end switch(state), case 1, %basic if nargin<2, conn_menu('frame',[.19,.35,.22,.45],'BASIC SETUP'); CONN_h.menus.m_setup_00{1}=conn_menu('edit',[.2,.7,.2,.04],'Number of subjects',num2str(CONN_x.Setup.nsubjects),'Number of subjects in this experiment','conn(''gui_setup'',1);'); CONN_h.menus.m_setup_00{2}=conn_menu('edit',[.2,.6,.2,.04],'Number of sessions',num2str(CONN_x.Setup.nsessions,'%1.0f '),'Number of scanning sessions per subject (enter a single number if every subject underwent the same number of scanning sessions, or a different number per subject otherwise (e.g. 2 2 3)','conn(''gui_setup'',2);'); CONN_h.menus.m_setup_00{3}=conn_menu('edit',[.2,.5,.2,.04],'Repetition Time (seconds)',num2str(CONN_x.Setup.RT),'Sampling period of fMRI data (time between two conscutive whole volume acquisitions)','conn(''gui_setup'',3);'); analysistypes={'continuous','sparse'}; CONN_h.menus.m_setup_00{4}=conn_menu('popup',[.2,.4,.2,.04],'Acquisition type',analysistypes,'Type of acquisition sequence','conn(''gui_setup'',4);'); set(CONN_h.menus.m_setup_00{2},'value',CONN_x.Setup.acquisitiontype); else switch(varargin{2}), case 1, value0=CONN_x.Setup.nsubjects; txt=get(CONN_h.menus.m_setup_00{1},'string'); value=str2num(txt); if ~isempty(value)&&length(value)==1, CONN_x.Setup.nsubjects=value; end; if CONN_x.Setup.nsubjects~=value0, CONN_x.Setup.nsubjects=conn_merge(value0,CONN_x.Setup.nsubjects); end set(CONN_h.menus.m_setup_00{1},'string',num2str(CONN_x.Setup.nsubjects)); set(CONN_h.menus.m_setup_00{2},'string',num2str(CONN_x.Setup.nsessions,'%1.0f ')) case 2, txt=get(CONN_h.menus.m_setup_00{2},'string'); value=str2num(txt); if isempty(value), try value=evalin('base',txt); catch, value=[]; end; end;if ~isempty(value)&&(length(value)==1||length(value)==CONN_x.Setup.nsubjects), CONN_x.Setup.nsessions=value; end; set(CONN_h.menus.m_setup_00{2},'string',num2str(CONN_x.Setup.nsessions,'%1.0f ')); case 3, txt=get(CONN_h.menus.m_setup_00{3},'string'); value=str2num(txt); if isempty(value), try value=evalin('base',txt); catch, value=[]; end; end;if ~isempty(value)&&length(value)==1, CONN_x.Setup.RT=value; end; set(CONN_h.menus.m_setup_00{3},'string',num2str(CONN_x.Setup.RT)); case 4, value=get(CONN_h.menus.m_setup_00{4},'value'); CONN_x.Setup.acquisitiontype=value; end end case 2, %functional if nargin<2, conn_menu('frame',[.19,.20,.37,.60],'FUNCTIONAL DATA SETUP'); CONN_h.menus.m_setup_00{1}=conn_menu('listbox',[.200,.25,.075,.5],'Subjects','','','conn(''gui_setup'',1);'); CONN_h.menus.m_setup_00{2}=conn_menu('listbox',[.275,.25,.075,.5],'Sessions','','','conn(''gui_setup'',2);'); CONN_h.menus.m_setup_00{3}=conn_menu('filesearch',[],'Select functional data files','*.img; *.nii','',{@conn,'gui_setup',3}); CONN_h.menus.m_setup_00{4}=conn_menu('text',[.35,.56,.2,.19],'File'); CONN_h.menus.m_setup_00{5}=conn_menu('image',[.36,.25,.17,.3]); %CONN_h.menus.m_setup_00{11}=conn_menu('checkbox',[.38,.205,.02,.04],'spatially-normalized images','','','conn(''gui_setup'',11);'); set(CONN_h.menus.m_setup_00{3}.files,'max',2); set(CONN_h.menus.m_setup_00{1},'max',2); set(CONN_h.menus.m_setup_00{1},'string',[repmat('Subject ',[CONN_x.Setup.nsubjects,1]),num2str((1:CONN_x.Setup.nsubjects)')]); nsess=CONN_x.Setup.nsessions(1); set(CONN_h.menus.m_setup_00{2},'string',[repmat('Session ',[nsess,1]),num2str((1:nsess)')],'value',min(nsess,get(CONN_h.menus.m_setup_00{2},'value'))); if ~isfield(CONN_x.Setup,'normalized'), CONN_x.Setup.normalized=1; end %set([CONN_h.menus.m_setup_00{11}],'visible','on','foregroundcolor','w','backgroundcolor',get(CONN_h.screen.hfig,'color')/2,'value',CONN_x.Setup.normalized); else switch(varargin{2}), case 1, value=get(CONN_h.menus.m_setup_00{1},'value'); nsess=max(CONN_x.Setup.nsessions(min(length(CONN_x.Setup.nsessions),value))); set(CONN_h.menus.m_setup_00{2},'string',[repmat('Session ',[nsess,1]),num2str((1:nsess)')],'value',min(nsess,get(CONN_h.menus.m_setup_00{2},'value'))); %nsess=CONN_x.Setup.nsessions(min(length(CONN_x.Setup.nsessions),value)); %set(CONN_h.menus.m_setup_00{2},'string',[repmat('Session ',[nsess,1]),num2str((1:nsess)')],'value',min(nsess,get(CONN_h.menus.m_setup_00{2},'value'))); case 2, case 3, set(CONN_h.screen.hfig,'pointer','watch'); nsubs=get(CONN_h.menus.m_setup_00{1},'value');nsess=get(CONN_h.menus.m_setup_00{2},'value'); filename=fliplr(deblank(fliplr(deblank(varargin{3})))); if size(filename,1)==length(nsubs), for n1=1:length(nsubs), nsub=nsubs(n1); [V,str,icon]=conn_getinfo(deblank(filename(n1,:))); CONN_x.Setup.functional{nsub}{nsess}={deblank(filename(n1,:)),str,icon}; CONN_x.Setup.nscans{nsub}{nsess}=prod(size(V)); end elseif length(nsubs)==1, [V,str,icon]=conn_getinfo(deblank(filename)); CONN_x.Setup.functional{nsubs}{nsess}={deblank(filename),str,icon}; CONN_x.Setup.nscans{nsubs}{nsess}=prod(size(V)); else errordlg('mismatched number of files',''); end set(CONN_h.screen.hfig,'pointer','arrow'); % case 11, % normalized=get(CONN_h.menus.m_setup_00{11},'value'); % if ~normalized, warndlg('Warning: Second-level voxel-level analyses not available for un-normalized data'); end % CONN_x.Setup.normalized=normalized; end end nsubs=get(CONN_h.menus.m_setup_00{1},'value');nsess=get(CONN_h.menus.m_setup_00{2},'value'); for nsub=nsubs(:)', if length(CONN_x.Setup.functional)3, value=get(CONN_h.menus.m_setup_00{9},'value'); CONN_x.Setup.rois.mask(nrois)=value; else set(CONN_h.menus.m_setup_00{9},'value',0);end case 10, nrois=get(CONN_h.menus.m_setup_00{1},'value'); if nrois>3, value=get(CONN_h.menus.m_setup_00{10},'value'); CONN_x.Setup.rois.multiplelabels(nrois)=value; else set(CONN_h.menus.m_setup_00{10},'value',0);end % case 11, % normalized=get(CONN_h.menus.m_setup_00{11},'value'); % if ~normalized, warndlg('Warning: Second-level analyses not available for un-normalized data'); end % CONN_x.Setup.normalized=normalized; case 12 nrois=get(CONN_h.menus.m_setup_00{1},'value'); value=get(CONN_h.menus.m_setup_00{12},'value'); CONN_x.Setup.rois.regresscovariates(nrois)=value; end end names=get(CONN_h.menus.m_setup_00{1},'string'); nrois=get(CONN_h.menus.m_setup_00{1},'value'); nsubs=get(CONN_h.menus.m_setup_00{2},'value'); set(CONN_h.menus.m_setup_00{6},'string',deblank(names{nrois})); if ~isfield(CONN_x.Setup.rois,'dimensions') || length(CONN_x.Setup.rois.dimensions)1); end set(CONN_h.menus.m_setup_00{7},'string',num2str(CONN_x.Setup.rois.dimensions{nrois})); set(CONN_h.menus.m_setup_00{9},'value',CONN_x.Setup.rois.mask(nrois)); set(CONN_h.menus.m_setup_00{10},'value',CONN_x.Setup.rois.multiplelabels(nrois)); set(CONN_h.menus.m_setup_00{12},'value',CONN_x.Setup.rois.regresscovariates(nrois)); %if nrois<=3, set([CONN_h.menus.m_setup_00{6},CONN_h.menus.m_setup_00{9},CONN_h.menus.m_setup_00{10}],'visible','off'); %else set(CONN_h.menus.m_setup_00{6},'visible','on','backgroundcolor','w','foregroundcolor','k'); set([CONN_h.menus.m_setup_00{9},CONN_h.menus.m_setup_00{10}],'visible','on'); end set(CONN_h.menus.m_setup_00{6},'visible','on','backgroundcolor','k','foregroundcolor','w'); set([CONN_h.menus.m_setup_00{9},CONN_h.menus.m_setup_00{10}],'visible','on','foregroundcolor','w','backgroundcolor',get(CONN_h.screen.hfig,'color')/2); ok=1; ko=[]; for nsub=nsubs(:)', if length(CONN_x.Setup.rois.files)0);end analysistypes={'Same as template (2mm isotropic)','Same as structurals','Same as functionals'}; CONN_h.menus.m_setup_00{2}=conn_menu('popup',[.2,.5,.25,.04],'Spatial resolution (voxel-level)',analysistypes,'Choose spatial resolution of voxel-based analyses','conn(''gui_setup'',2);'); set(CONN_h.menus.m_setup_00{2},'value',CONN_x.Setup.spatialresolution); analysistypes={'Template mask (brainmask.nii)','Implicit mask (subject-specific)'}; CONN_h.menus.m_setup_00{3}=conn_menu('popup',[.2,.4,.25,.04],'Analysis mask (voxel-level)',analysistypes,'Choose analysis mask for voxel-based analyses','conn(''gui_setup'',3);'); set(CONN_h.menus.m_setup_00{3},'value',CONN_x.Setup.analysismask); if any(CONN_x.Setup.steps([2,3])), set([CONN_h.menus.m_setup_00{2},CONN_h.menus.m_setup_00{3}],'enable','on'); else set([CONN_h.menus.m_setup_00{2},CONN_h.menus.m_setup_00{3}],'enable','off'); end analysistypes={'Create confound beta-maps','Create confound-corrected time-series','Create seed-to-voxel r-maps'}; CONN_h.menus.m_setup_00{4}=conn_menu('checkbox2',[.2,.275,.25,.04],'Optional ouput files',analysistypes,'Choose optional output files to be generated during the analyses','conn(''gui_setup'',4);'); for n1=1:numel(analysistypes),set(CONN_h.menus.m_setup_00{4}(n1),'value',CONN_x.Setup.outputfiles(n1));end else switch(varargin{2}), case 1, for n1=1:numel(CONN_h.menus.m_setup_00{1}),value=get(CONN_h.menus.m_setup_00{1}(n1),'value');CONN_x.Setup.steps(n1)=value; end if any(CONN_x.Setup.steps([2,3])), set([CONN_h.menus.m_setup_00{2},CONN_h.menus.m_setup_00{3},CONN_h.menus.m_setup_00{4}],'enable','on'); else set([CONN_h.menus.m_setup_00{2},CONN_h.menus.m_setup_00{3},CONN_h.menus.m_setup_00{4}],'enable','off'); end if any(CONN_x.Setup.steps(2)), set(CONN_h.menus.m_setup_00{4}(3),'enable','on'); else set(CONN_h.menus.m_setup_00{4}(3),'enable','off'); end case 2, value=get(CONN_h.menus.m_setup_00{2},'value'); CONN_x.Setup.spatialresolution=value; case 3, value=get(CONN_h.menus.m_setup_00{3},'value'); CONN_x.Setup.analysismask=value; case 4, for n1=1:numel(CONN_h.menus.m_setup_00{4}),value=get(CONN_h.menus.m_setup_00{4}(n1),'value');CONN_x.Setup.outputfiles(n1)=value; end end end end case 'gui_setup_covariates', state=conn_menumanager(CONN_h.menus.m_setup_02,'state');state=0*state;state(6)=1;conn_menumanager(CONN_h.menus.m_setup_02,'state',state,'on',1); state=find(conn_menumanager(CONN_h.menus.m_setup_03,'state')); if nargin<2, conn_menumanager clf; axes('units','norm','position',[0,.935,1,.005]); image(shiftdim(1-get(CONN_h.screen.hfig,'color'),-1)); axis off; conn_menumanager([CONN_h.menus.m_setup_02,CONN_h.menus.m_setup_01,CONN_h.menus.m_setup_01b,CONN_h.menus.m_setup_06,CONN_h.menus.m0],'on',1); end if isempty(state) return; end switch(state), case 1, % first-level covariates if nargin<2, conn_menu('frame',[.19,.23,.44,.57],'FIRST-LEVEL COVARIATES SETUP'); CONN_h.menus.m_setup_00{1}=conn_menu('listbox',[.200,.25,.075,.5],'Covariates','','','conn(''gui_setup_covariates'',1);'); CONN_h.menus.m_setup_00{2}=conn_menu('listbox',[.275,.25,.075,.5],'Subjects','','','conn(''gui_setup_covariates'',2);'); CONN_h.menus.m_setup_00{3}=conn_menu('listbox',[.350,.25,.075,.5],'Sessions','','','conn(''gui_setup_covariates'',3);'); CONN_h.menus.m_setup_00{4}=conn_menu('filesearch',[],'Select covariate files','*.mat; *.txt;','',{@conn,'gui_setup_covariates',4}); CONN_h.menus.m_setup_00{5}=conn_menu('text', [.425,.51,.2,.09],'Files'); CONN_h.menus.m_setup_00{6}=conn_menu('image',[.435,.25,.17,.25]); CONN_h.menus.m_setup_00{7}=conn_menu('edit',[.455,.66,.14,.04],'covariate name','','First-level covariate name','conn(''gui_setup_covariates'',7);'); set(CONN_h.menus.m_setup_00{4}.files,'max',2); set(CONN_h.menus.m_setup_00{3},'max',2); set(CONN_h.menus.m_setup_00{2},'string',[repmat('Subject ',[CONN_x.Setup.nsubjects,1]),num2str((1:CONN_x.Setup.nsubjects)')],'max',2); set(CONN_h.menus.m_setup_00{1},'string',CONN_x.Setup.l1covariates.names,'max',1); nsess=CONN_x.Setup.nsessions(1); set(CONN_h.menus.m_setup_00{3},'string',[repmat('Session ',[nsess,1]),num2str((1:nsess)')],'value',min(nsess,get(CONN_h.menus.m_setup_00{3},'value'))); hc1=uicontextmenu;uimenu(hc1,'Label','remove selected covariate','callback','conn(''gui_setup_covariates'',8);');set(CONN_h.menus.m_setup_00{1},'uicontextmenu',hc1); else switch(varargin{2}), case 2, value=get(CONN_h.menus.m_setup_00{2},'value'); nsess=max(CONN_x.Setup.nsessions(min(length(CONN_x.Setup.nsessions),value))); set(CONN_h.menus.m_setup_00{3},'string',[repmat('Session ',[nsess,1]),num2str((1:nsess)')],'value',min(nsess,get(CONN_h.menus.m_setup_00{3},'value'))); case 4, nl1covariates=get(CONN_h.menus.m_setup_00{1},'value'); nsubs=get(CONN_h.menus.m_setup_00{2},'value'); nsess=get(CONN_h.menus.m_setup_00{3},'value'); filename=fliplr(deblank(fliplr(deblank(varargin{3})))); if size(filename,1)==length(nsubs)*length(nsess), n3=1;for n1=1:length(nsubs), for n2=1:length(nsess), nsub=nsubs(n1);nses=nsess(n2); [V,str,icon]=conn_getinfo(deblank(filename(n3,:))); CONN_x.Setup.l1covariates.files{nsub}{nl1covariates}{nses}={deblank(filename(n3,:)),str,icon}; n3=n3+1; end;end elseif size(filename,1)==1, [V,str,icon]=conn_getinfo(filename); for nsub=nsubs(:)', for nses=nsess(:)', if nses<=CONN_x.Setup.nsessions(min(length(CONN_x.Setup.nsessions),nsub)), CONN_x.Setup.l1covariates.files{nsub}{nl1covariates}{nses}={filename,str,icon}; end; end; end else errordlg('mismatched number of files',''); end case 7, nl1covariates=get(CONN_h.menus.m_setup_00{1},'value'); names=get(CONN_h.menus.m_setup_00{1},'string'); name=fliplr(deblank(fliplr(deblank(get(CONN_h.menus.m_setup_00{7},'string'))))); if isempty(strmatch(name,names,'exact')), names{nl1covariates}=name; CONN_x.Setup.l1covariates.names{nl1covariates}=name; if nl1covariates==length(CONN_x.Setup.l1covariates.names), CONN_x.Setup.l1covariates.names{nl1covariates+1}=' '; names{nl1covariates+1}=' '; end set(CONN_h.menus.m_setup_00{1},'string',names); end case 8, nl1covariates1=get(CONN_h.menus.m_setup_00{1},'value'); nl1covariates0=length(CONN_x.Setup.l1covariates.names); nl1covariates=setdiff(nl1covariates1,[nl1covariates0]); nl1covariates=setdiff(1:nl1covariates0,nl1covariates); CONN_x.Setup.l1covariates.names={CONN_x.Setup.l1covariates.names{nl1covariates}}; nl1covariates=setdiff(nl1covariates,nl1covariates0); for n1=1:length(CONN_x.Setup.l1covariates.files), CONN_x.Setup.l1covariates.files{n1}={CONN_x.Setup.l1covariates.files{n1}{nl1covariates}}; end set(CONN_h.menus.m_setup_00{1},'string',CONN_x.Setup.l1covariates.names,'value',max(1,min(length(CONN_x.Setup.l1covariates.names)-1,max(nl1covariates1)))); end end names=get(CONN_h.menus.m_setup_00{1},'string'); nl1covariates=get(CONN_h.menus.m_setup_00{1},'value'); nsubs=get(CONN_h.menus.m_setup_00{2},'value'); nsess=get(CONN_h.menus.m_setup_00{3},'value'); set(CONN_h.menus.m_setup_00{7},'string',deblank(names{nl1covariates})); ok=1; ko=[]; for nsub=nsubs(:)', if length(CONN_x.Setup.l1covariates.files)=14, save(filename,'-V6','CONN_x'); % % else save(filename,'CONN_x'); end % catch % CONN_x.filename=pathname; waitfor(errordlg(['Failed to save file ',filename,'. Check file name and/or folder permissions'],mfilename)); % end % if isfield(CONN_x,'Analyses') % for ianalysis=1:numel(CONN_x.Analyses) % if isfield(CONN_x.Analyses(ianalysis),'name')&&isfield(CONN_x.Analyses(ianalysis),'sourcenames') % filesourcenames=fullfile(CONN_x.folders.firstlevel,CONN_x.Analyses(ianalysis).name,'_list_sources.mat'); % sourcenames=CONN_x.Analyses(ianalysis).sourcenames; % save(filesourcenames,'sourcenames'); % end % end % end set(CONN_h.screen.hfig,'pointer','arrow'); end case 'gui_setup_new', Answ=questdlg('Do you want to spatially preprocess your data now (realignment/coregistration/normalization/smoothing)?','conn','Yes','No','Yes'); if strcmp(Answ,'Yes'), conn_setup_wizard; else conn init; conn importrois; conn gui_setup; end case 'gui_setup_import', if nargin<2 conn_menumanager clf; axes('units','norm','position',[0,.935,1,.005]); image(shiftdim(1-get(CONN_h.screen.hfig,'color'),-1)); axis off; conn_menumanager([CONN_h.menus.m_setup_04,CONN_h.menus.m_setup_06,CONN_h.menus.m0],'on',1); conn_menu('frame',[.19,.13,.295,.67],'IMPORT SETUP FROM SPM'); CONN_h.menus.m_setup_00{1}=conn_menu('listbox',[.2,.15,.075,.5],'Subjects','','','conn(''gui_setup_import'',1);'); CONN_h.menus.m_setup_00{2}=conn_menu('edit',[.2,.7,.2,.04],'Number of subjects',num2str(CONN_x.Setup.nsubjects),'Number of subjects in this experiment','conn(''gui_setup_import'',2);'); CONN_h.menus.m_setup_00{3}=conn_menu('filesearch',[],'Select SPM.mat subject files','SPM.mat','',{@conn,'gui_setup_import',3}); CONN_h.menus.m_setup_00{4}=conn_menu('text', [.275,.46,.2,.19],'Files'); CONN_h.menus.m_setup_00{5}=conn_menu('image',[.285,.15,.17,.3]); set(CONN_h.menus.m_setup_00{1},'string',[repmat('Subject ',[CONN_x.Setup.nsubjects,1]),num2str((1:CONN_x.Setup.nsubjects)')],'max',1); else switch(varargin{2}), case 1, case 2, value0=CONN_x.Setup.nsubjects; txt=get(CONN_h.menus.m_setup_00{2},'string'); value=str2num(txt); if ~isempty(value)&&length(value)==1, CONN_x.Setup.nsubjects=value; end; if CONN_x.Setup.nsubjects~=value0, CONN_x.Setup.nsubjects=conn_merge(value0,CONN_x.Setup.nsubjects); end set(CONN_h.menus.m_setup_00{2},'string',num2str(CONN_x.Setup.nsubjects)); set(CONN_h.menus.m_setup_00{1},'string',[repmat('Subject ',[CONN_x.Setup.nsubjects,1]),num2str((1:CONN_x.Setup.nsubjects)')],'max',1,'value',min(CONN_x.Setup.nsubjects,get(CONN_h.menus.m_setup_00{1},'value'))); case 3, if nargin<4, nsubs=get(CONN_h.menus.m_setup_00{1},'value'); else nsubs=varargin{4}; end filename=fliplr(deblank(fliplr(deblank(varargin{3})))); [V,str,icon]=conn_getinfo(filename); CONN_x.Setup.spm{nsubs}={filename,str,icon}; end end nsubs=get(CONN_h.menus.m_setup_00{1},'value'); conn_menu('update',CONN_h.menus.m_setup_00{5},CONN_x.Setup.spm{nsubs}{3}); set(CONN_h.menus.m_setup_00{4},'string',CONN_x.Setup.spm{nsubs}{2}); case 'gui_setup_importdone', conn_importspm; conn gui_setup; %conn_menumanager clf; %axes('units','norm','position',[0,.935,1,.005]); image(shiftdim(1-get(CONN_h.screen.hfig,'color'),-1)); axis off; %conn_menumanager([CONN_h.menus.m_setup_02,CONN_h.menus.m_setup_01,CONN_h.menus.m_setup_01b,CONN_h.menus.m0],'on',1); case 'gui_setup_merge', if nargin<2 conn_menumanager clf; axes('units','norm','position',[0,.935,1,.005]); image(shiftdim(1-get(CONN_h.screen.hfig,'color'),-1)); axis off; conn_menumanager([CONN_h.menus.m_setup_05,CONN_h.menus.m_setup_06,CONN_h.menus.m0],'on',1); CONN_x.Setup.merge.nprojs=1; CONN_x.Setup.merge.files={{[],[],[]}}; conn_menu('frame',[.19,.13,.295,.67],'MERGE WITH OTHER CONN_* PROJECTS'); CONN_h.menus.m_setup_00{1}=conn_menu('listbox',[.2,.15,.075,.5],'Projects','','','conn(''gui_setup_merge'',1);'); CONN_h.menus.m_setup_00{2}=conn_menu('edit',[.2,.7,.2,.04],'Number of projects',num2str(1),'Number of projects to merge the current experiment with','conn(''gui_setup_merge'',2);'); CONN_h.menus.m_setup_00{3}=conn_menu('filesearch',[],'Select conn_*.mat project files','conn_*.mat','',{@conn,'gui_setup_merge',3}); CONN_h.menus.m_setup_00{4}=conn_menu('text', [.275,.46,.2,.19],'Files'); CONN_h.menus.m_setup_00{5}=conn_menu('image',[.285,.15,.17,.3]); set(CONN_h.menus.m_setup_00{1},'string',[repmat('Project ',[CONN_x.Setup.merge.nprojs,1]),num2str((1:CONN_x.Setup.merge.nprojs)')],'max',1); else switch(varargin{2}), case 1, case 2, value0=CONN_x.Setup.merge.nprojs; txt=get(CONN_h.menus.m_setup_00{2},'string'); value=str2num(txt); if ~isempty(value)&&length(value)==1, CONN_x.Setup.merge.nprojs=value; end; for n0=value0+1:CONN_x.Setup.merge.nprojs,CONN_x.Setup.merge.files{n0}={[],[],[]};end CONN_x.Setup.merge.files={CONN_x.Setup.merge.files{1:CONN_x.Setup.merge.nprojs}}; set(CONN_h.menus.m_setup_00{2},'string',num2str(CONN_x.Setup.merge.nprojs)); set(CONN_h.menus.m_setup_00{1},'string',[repmat('Project ',[CONN_x.Setup.merge.nprojs,1]),num2str((1:CONN_x.Setup.merge.nprojs)')],'max',1,'value',min(CONN_x.Setup.merge.nprojs,get(CONN_h.menus.m_setup_00{1},'value'))); case 3, if nargin<4, nprojs=get(CONN_h.menus.m_setup_00{1},'value'); else nprojs=varargin{4}; end filename=fliplr(deblank(fliplr(deblank(varargin{3})))); [V,str,icon]=conn_getinfo(filename); CONN_x.Setup.merge.files{nprojs}={filename,str,icon}; end end nprojs=get(CONN_h.menus.m_setup_00{1},'value'); conn_menu('update',CONN_h.menus.m_setup_00{5},CONN_x.Setup.merge.files{nprojs}{3}); set(CONN_h.menus.m_setup_00{4},'string',CONN_x.Setup.merge.files{nprojs}{2}); case 'gui_setup_mergedone', filenames=[];for n1=1:CONN_x.Setup.merge.nprojs,filenames=strvcat(filenames,CONN_x.Setup.merge.files{n1}{1});end hm=msgbox('Merging projects... please wait','conn_display'); value0=CONN_x.Setup.nsubjects; value=conn_merge(filenames); if value~=value0, conn_process('prepare_results'); close(hm); conn gui_setup; else close(hm); hm=msgbox('There were problems importing the new subject data. Check the command line for further information','conn_display'); end %conn_menumanager clf; %axes('units','norm','position',[0,.935,1,.005]); image(shiftdim(1-get(CONN_h.screen.hfig,'color'),-1)); axis off; %conn_menumanager([CONN_h.menus.m_setup_02,CONN_h.menus.m_setup_01,CONN_h.menus.m_setup_01b,CONN_h.menus.m0],'on',1); case 'gui_setup_finish', if isempty(CONN_x.filename), conn gui_setup_save; end conn_menumanager clf; axes('units','norm','position',[0,.935,1,.005]); image(shiftdim(1-get(CONN_h.screen.hfig,'color'),-1)); axis off; conn_menumanager([CONN_h.menus.m0],'on',1); conn_process('setup'); conn gui_setup_save; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'gui_preproc', CONN_x.gui=1; model=0; if nargin<2, conn_menumanager clf; axes('units','norm','position',[0,.935,1,.005]); image(shiftdim(1-get(CONN_h.screen.hfig,'color'),-1)); axis off; conn_menumanager([CONN_h.menus.m_preproc_02,CONN_h.menus.m_setup_06,CONN_h.menus.m0],'on',1); if isempty(CONN_x.Preproc.variables.names), uiwait(errordlg('Data not prepared for analyses. Press "done" in the Setup window','')); return; end conn_menu('frame',[.04,.13,.37,.67],'GLM - DEFINE POSSIBLE CONFOUNDS'); CONN_h.menus.m_preproc_00{1}=conn_menu('listbox',[.05,.25,.075,.5],'','','','conn(''gui_preproc'',1);'); CONN_h.menus.m_preproc_00{2}=conn_menu('listbox',[.15,.25,.075,.5],'Confounds','','','conn(''gui_preproc'',2);'); CONN_h.menus.m_preproc_00{3}=conn_menu('image',[.25,.25,.14,.31],''); CONN_h.menus.m_preproc_00{4}=conn_menu('edit',[.25,.7,.14,.04],'derivatives order','','Include derivates up to n-th order (0 for no derivatives, 1 for first-order derivatives,...)','conn(''gui_preproc'',4);'); CONN_h.menus.m_preproc_00{5}=conn_menu('edit',[.05,.15,.175,.04],'band-pass filter (Hz)',num2str(CONN_x.Preproc.filter),'Band pass filter threshold (two values, low-pass and high-pass thresholds, respectively)','conn(''gui_preproc'',5);'); CONN_h.menus.m_preproc_00{6}=conn_menu('edit',[.25,.6,.14,.04],'dimensions','','Number of dimensions','conn(''gui_preproc'',6);'); conn_menu('frame',[.44,.16,.47,.64],'PREVIEW RESULTS'); CONN_h.menus.m_preproc_00{11}=conn_menu('listbox',[.45,.45,.075,.3],'Subject','','','conn(''gui_preproc'',11);'); CONN_h.menus.m_preproc_00{12}=conn_menu('listbox',[.525,.45,.075,.3],'Sessions','','','conn(''gui_preproc'',12);'); CONN_h.menus.m_preproc_00{13}=conn_menu('listbox',[.6,.45,.075,.3],'Effect','','','conn(''gui_preproc'',13);'); CONN_h.menus.m_preproc_00{14}=conn_menu('image',[.7,.25,.17,.5],'BOLD % variance explained'); [CONN_h.menus.m_preproc_00{16},CONN_h.menus.m_preproc_00{17}]=conn_menu('hist',[.45,.20,.225,.20],'Voxel-to-voxel connectivity (r)'); pos=[.7,.25,.17,.5]; if any(CONN_x.Setup.steps([2,3])), uicontrol('style','text','units','norm','position',[pos(1)+pos(3)-.170,pos(2)-2*.04,.070,.04],'string','threshold','fontname','default','fontsize',8,'backgroundcolor',get(CONN_h.screen.hfig,'color')/2,'foregroundcolor',1-get(CONN_h.screen.hfig,'color')); pos=[.7,.25,.17,.5]; CONN_h.menus.m_preproc_00{15}=uicontrol('style','slider','units','norm','position',[pos(1)+pos(3)-0*.015,pos(2),.015,pos(4)],'callback','conn(''gui_preproc'',15);','backgroundcolor',get(CONN_h.screen.hfig,'color')/2); end set([CONN_h.menus.m_preproc_00{1},CONN_h.menus.m_preproc_00{2}],'max',2); set(CONN_h.menus.m_preproc_00{1},'string',CONN_x.Preproc.variables.names); set(CONN_h.menus.m_preproc_00{2},'string',CONN_x.Preproc.confounds.names); conn_menumanager(CONN_h.menus.m_preproc_01,'on',1); set([CONN_h.menus.m_preproc_00{1},CONN_h.menus.m_preproc_00{2}],'value',[]); set(CONN_h.menus.m_preproc_00{4},'visible','off');% set(CONN_h.menus.m_preproc_00{6},'visible','off');% set([CONN_h.menus.m_preproc_00{11},CONN_h.menus.m_preproc_00{12},CONN_h.menus.m_preproc_00{13}],'max',1); set(CONN_h.menus.m_preproc_00{11},'string',[repmat('Subject ',[CONN_x.Setup.nsubjects,1]),num2str((1:CONN_x.Setup.nsubjects)')]); nsess=CONN_x.Setup.nsessions(1); set(CONN_h.menus.m_preproc_00{12},'string',[repmat('Session ',[nsess,1]),num2str((1:nsess)')],'value',min(nsess,get(CONN_h.menus.m_preproc_00{12},'value'))); set(CONN_h.menus.m_preproc_00{13},'string',{'TOTAL',CONN_x.Preproc.confounds.names{:}}); %set(CONN_h.screen.hfig,'pointer','watch'); [path,name,ext]=fileparts(CONN_x.filename); % filepath=fullfile(path,name,'data'); filepath=CONN_x.folders.data; if any(CONN_x.Setup.steps([2,3])),%~isfield(CONN_x.Setup,'doROIonly')||~CONN_x.Setup.doROIonly, filename=fullfile(filepath,['DATA_Subject',num2str(1,'%03d'),'_Session',num2str(1,'%03d'),'.mat']); CONN_h.menus.m_preproc.Y=conn_vol(filename); CONN_h.menus.m_preproc.y.slice=ceil(CONN_h.menus.m_preproc.Y.matdim.dim(3)/2); [CONN_h.menus.m_preproc.y.data,CONN_h.menus.m_preproc.y.idx]=conn_get_slice(CONN_h.menus.m_preproc.Y,CONN_h.menus.m_preproc.y.slice); end filename=fullfile(filepath,['ROI_Subject',num2str(1,'%03d'),'_Session',num2str(1,'%03d'),'.mat']); CONN_h.menus.m_preproc.X1=load(filename); filename=fullfile(filepath,['COV_Subject',num2str(1,'%03d'),'_Session',num2str(1,'%03d'),'.mat']); CONN_h.menus.m_preproc.X2=load(filename); try CONN_h.menus.m_preproc.XS=spm_vol(deblank(CONN_x.Setup.structural{1}{1})); catch CONN_h.menus.m_preproc.XS=spm_vol(fullfile(fileparts(which('spm')),'canonical','single_subj_T1.nii')); end if any(CONN_x.Setup.steps([2,3])),%~isfield(CONN_x.Setup,'doROIonly')||~CONN_x.Setup.doROIonly, xyz=conn_convertcoordinates('idx2tal',prod(CONN_h.menus.m_preproc.Y.matdim.dim(1:2))*(CONN_h.menus.m_preproc.y.slice-1)+(1:prod(CONN_h.menus.m_preproc.Y.matdim.dim(1:2))),CONN_h.menus.m_preproc.Y.matdim.mat,CONN_h.menus.m_preproc.Y.matdim.dim); CONN_h.menus.m_preproc.Xs=spm_get_data(CONN_h.menus.m_preproc.XS(1),pinv(CONN_h.menus.m_preproc.XS(1).mat)*xyz'); CONN_h.menus.m_preproc.Xs=permute(reshape(CONN_h.menus.m_preproc.Xs,CONN_h.menus.m_preproc.Y.matdim.dim(1:2)),[2,1,3]); set(CONN_h.menus.m_preproc_00{15},'min',1,'max',CONN_h.menus.m_preproc.Y.matdim.dim(3),'sliderstep',min(.5,[1,10]/(CONN_h.menus.m_preproc.Y.matdim.dim(3)-1)),'value',CONN_h.menus.m_preproc.y.slice); end model=1; else switch(varargin{2}), case 0, str=conn_menumanager(CONN_h.menus.m_preproc_01,'string'); switch(str{1}(1)), case '>', ncovariates=get(CONN_h.menus.m_preproc_00{1},'value'); for ncovariate=ncovariates(:)', if isempty(strmatch(CONN_x.Preproc.variables.names{ncovariate},CONN_x.Preproc.confounds.names,'exact')), CONN_x.Preproc.confounds.names{end+1}=CONN_x.Preproc.variables.names{ncovariate}; CONN_x.Preproc.confounds.types{end+1}=CONN_x.Preproc.variables.types{ncovariate}; CONN_x.Preproc.confounds.deriv{end+1}=CONN_x.Preproc.variables.deriv{ncovariate}; CONN_x.Preproc.confounds.dimensions{end+1}=CONN_x.Preproc.variables.dimensions{ncovariate}; end end set(CONN_h.menus.m_preproc_00{2},'string',CONN_x.Preproc.confounds.names); set(CONN_h.menus.m_preproc_00{13},'string',{'TOTAL',CONN_x.Preproc.confounds.names{:}}); case '<', ncovariates=get(CONN_h.menus.m_preproc_00{2},'value'); idx=setdiff(1:length(CONN_x.Preproc.confounds.names),ncovariates); CONN_x.Preproc.confounds.names={CONN_x.Preproc.confounds.names{idx}}; CONN_x.Preproc.confounds.types={CONN_x.Preproc.confounds.types{idx}}; CONN_x.Preproc.confounds.deriv={CONN_x.Preproc.confounds.deriv{idx}}; CONN_x.Preproc.confounds.dimensions={CONN_x.Preproc.confounds.dimensions{idx}}; set(CONN_h.menus.m_preproc_00{2},'string',CONN_x.Preproc.confounds.names,'value',min(max(ncovariates),length(CONN_x.Preproc.confounds.names))); set(CONN_h.menus.m_preproc_00{13},'string',{'TOTAL',CONN_x.Preproc.confounds.names{:}},'value',min(max(get(CONN_h.menus.m_preproc_00{13},'value')),length(CONN_x.Preproc.confounds.names)+1)); end model=1; case 1, conn_menumanager(CONN_h.menus.m_preproc_01,'string',{'>>'},'on',1); set(CONN_h.menus.m_preproc_00{2},'value',[]); set([CONN_h.menus.m_preproc_00{4},CONN_h.menus.m_preproc_00{6}],'visible','off');% case 2, conn_menumanager(CONN_h.menus.m_preproc_01,'string',{'<<'},'on',1); set(CONN_h.menus.m_preproc_00{1},'value',[]); set([CONN_h.menus.m_preproc_00{4},CONN_h.menus.m_preproc_00{6}],'visible','on','backgroundcolor','k','foregroundcolor','w');% case 4, nconfounds=get(CONN_h.menus.m_preproc_00{2},'value'); value=str2num(get(CONN_h.menus.m_preproc_00{4},'string')); if length(value)==1, for nconfound=nconfounds(:)', CONN_x.Preproc.confounds.deriv{nconfound}=min(2,value); end; end model=1; case 5, value=str2num(get(CONN_h.menus.m_preproc_00{5},'string')); if length(value)==2 && value(2)>value(1), CONN_x.Preproc.filter=value; end model=1; case 6, nconfounds=get(CONN_h.menus.m_preproc_00{2},'value'); value=str2num(get(CONN_h.menus.m_preproc_00{6},'string')); if length(value)==1, for nconfound=nconfounds(:)', CONN_x.Preproc.confounds.dimensions{nconfound}(1)=max(1,min(CONN_x.Preproc.confounds.dimensions{nconfound}(2),value)); end; end model=1; case {11,12}, nsubs=get(CONN_h.menus.m_preproc_00{11},'value'); if varargin{2}==11, nsess=CONN_x.Setup.nsessions(min(length(CONN_x.Setup.nsessions),nsubs)); set(CONN_h.menus.m_preproc_00{12},'string',[repmat('Session ',[nsess,1]),num2str((1:nsess)')],'value',min(nsess,get(CONN_h.menus.m_preproc_00{12},'value'))); end nsess=get(CONN_h.menus.m_preproc_00{12},'value'); %set(CONN_h.screen.hfig,'pointer','watch'); [path,name,ext]=fileparts(CONN_x.filename); % filepath=fullfile(path,name,'data'); filepath=CONN_x.folders.data; if any(CONN_x.Setup.steps([2,3])),%~isfield(CONN_x.Setup,'doROIonly')||~CONN_x.Setup.doROIonly, filename=fullfile(filepath,['DATA_Subject',num2str(nsubs,'%03d'),'_Session',num2str(nsess,'%03d'),'.mat']); CONN_h.menus.m_preproc.Y=conn_vol(filename); [CONN_h.menus.m_preproc.y.data,CONN_h.menus.m_preproc.y.idx]=conn_get_slice(CONN_h.menus.m_preproc.Y,CONN_h.menus.m_preproc.y.slice); end filename=fullfile(filepath,['ROI_Subject',num2str(nsubs,'%03d'),'_Session',num2str(nsess,'%03d'),'.mat']); CONN_h.menus.m_preproc.X1=load(filename); filename=fullfile(filepath,['COV_Subject',num2str(nsubs,'%03d'),'_Session',num2str(nsess,'%03d'),'.mat']); CONN_h.menus.m_preproc.X2=load(filename); try CONN_h.menus.m_preproc.XS=spm_vol(deblank(CONN_x.Setup.structural{nsubs}{1})); catch CONN_h.menus.m_preproc.XS=spm_vol(fullfile(fileparts(which('spm')),'canonical','single_subj_T1.nii')); end if any(CONN_x.Setup.steps([2,3])),%~isfield(CONN_x.Setup,'doROIonly')||~CONN_x.Setup.doROIonly, xyz=conn_convertcoordinates('idx2tal',prod(CONN_h.menus.m_preproc.Y.matdim.dim(1:2))*(CONN_h.menus.m_preproc.y.slice-1)+(1:prod(CONN_h.menus.m_preproc.Y.matdim.dim(1:2))),CONN_h.menus.m_preproc.Y.matdim.mat,CONN_h.menus.m_preproc.Y.matdim.dim); CONN_h.menus.m_preproc.Xs=spm_get_data(CONN_h.menus.m_preproc.XS(1),pinv(CONN_h.menus.m_preproc.XS(1).mat)*xyz'); CONN_h.menus.m_preproc.Xs=permute(reshape(CONN_h.menus.m_preproc.Xs,CONN_h.menus.m_preproc.Y.matdim.dim(1:2)),[2,1,3]); end model=1; case 13, model=2; case 15, nsubs=get(CONN_h.menus.m_preproc_00{11},'value'); CONN_h.menus.m_preproc.y.slice=round(get(CONN_h.menus.m_preproc_00{15},'value')); [CONN_h.menus.m_preproc.y.data,CONN_h.menus.m_preproc.y.idx]=conn_get_slice(CONN_h.menus.m_preproc.Y,CONN_h.menus.m_preproc.y.slice); xyz=conn_convertcoordinates('idx2tal',prod(CONN_h.menus.m_preproc.Y.matdim.dim(1:2))*(CONN_h.menus.m_preproc.y.slice-1)+(1:prod(CONN_h.menus.m_preproc.Y.matdim.dim(1:2))),CONN_h.menus.m_preproc.Y.matdim.mat,CONN_h.menus.m_preproc.Y.matdim.dim); CONN_h.menus.m_preproc.Xs=spm_get_data(CONN_h.menus.m_preproc.XS(1),pinv(CONN_h.menus.m_preproc.XS(1).mat)*xyz'); CONN_h.menus.m_preproc.Xs=permute(reshape(CONN_h.menus.m_preproc.Xs,CONN_h.menus.m_preproc.Y.matdim.dim(1:2)),[2,1,3]); model=1; end end nsubs=get(CONN_h.menus.m_preproc_00{11},'value'); nconfounds=get(CONN_h.menus.m_preproc_00{2},'value'); nview=get(CONN_h.menus.m_preproc_00{13},'value')-1; [CONN_h.menus.m_preproc.X,CONN_h.menus.m_preproc.select]=conn_designmatrix(CONN_x.Preproc.confounds,CONN_h.menus.m_preproc.X1,CONN_h.menus.m_preproc.X2,{nconfounds,nview}); if isempty(nconfounds), conn_menu('update',CONN_h.menus.m_preproc_00{3},[]); else conn_menu('update',CONN_h.menus.m_preproc_00{3},CONN_h.menus.m_preproc.X); end if ~isempty(nconfounds)&&all(nconfounds>0), temp=cat(1,CONN_x.Preproc.confounds.deriv{nconfounds}); if length(temp)==1 || ~any(diff(temp)),set(CONN_h.menus.m_preproc_00{4},'string',num2str(CONN_x.Preproc.confounds.deriv{nconfounds(1)})); else set(CONN_h.menus.m_preproc_00{4},'string','MULTIPLE VALUES'); end temp=cat(1,CONN_x.Preproc.confounds.dimensions{nconfounds}); if size(temp,1)==1 || ~any(any(diff(temp,1,1))),set(CONN_h.menus.m_preproc_00{6},'string',num2str(CONN_x.Preproc.confounds.dimensions{nconfounds(1)}(1))); else set(CONN_h.menus.m_preproc_00{6},'string','MULTIPLE VALUES'); end end set(CONN_h.menus.m_preproc_00{5},'string',num2str(CONN_x.Preproc.filter)); if size(CONN_h.menus.m_preproc.X,2)<=500, offon={'off','on'}; for n1=1:size(CONN_h.menus.m_preproc.X,2), set(CONN_h.menus.m_preproc_00{3}.h4(n1),'visible',offon{1+CONN_h.menus.m_preproc.select{1}(n1)}); end xtemp=CONN_h.menus.m_preproc.X(:,find(CONN_h.menus.m_preproc.select{1})); if ~isempty(xtemp), set(CONN_h.menus.m_preproc_00{3}.h3,'ylim',[min(min(xtemp))-1e-4,max(max(xtemp))+1e-4]); end end if model==1, if any(CONN_x.Setup.steps([2,3])),%~isfield(CONN_x.Setup,'doROIonly')||~CONN_x.Setup.doROIonly, xf=CONN_h.menus.m_preproc.X;%conn_filter(CONN_x.Setup.RT,CONN_x.Preproc.filter,CONN_h.menus.m_preproc.X,'partial'); yf=CONN_h.menus.m_preproc.y.data;%conn_filter(CONN_x.Setup.RT,CONN_x.Preproc.filter,CONN_h.menus.m_preproc.y.data,'partial'); [CONN_h.menus.m_preproc.B,CONN_h.menus.m_preproc.opt]=conn_glmunivariate('estimate',xf,yf); if CONN_h.menus.m_preproc.opt.dof<=0, disp(['Warning: Over-determined model (no degrees of freedom for this subject). Please consider reducing the number, dimensions, or covariates order of the confounds or disregarding this subject/session']); end end if isfield(CONN_h.menus.m_preproc.X1,'sampledata'), xf=CONN_h.menus.m_preproc.X;%conn_filter(CONN_x.Setup.RT,CONN_x.Preproc.filter,CONN_h.menus.m_preproc.X,'partial'); if ~any(CONN_x.Setup.steps([2,3])),%isfield(CONN_x.Setup,'doROIonly')&&CONN_x.Setup.doROIonly, CONN_h.menus.m_preproc.opt.dof=size(CONN_h.menus.m_preproc.X1.sampledata,1)-size(xf,2); end x0=detrend(CONN_h.menus.m_preproc.X1.sampledata);x0=x0(:,~all(abs(x0)<1e-4,1));x1=x0-xf*(pinv(xf)*x0);z0=corrcoef(x0);z1=corrcoef(x1);z0=(z0(z0~=1));z1=(z1(z1~=1)); [a0,b0]=hist(z0(:),linspace(-1,1,100));[a1,b1]=hist(z1(:),linspace(-1,1,100)); conn_menu('updatehist',CONN_h.menus.m_preproc_00{16},{[b1(1),b1,b1(end)],[0,a1,0],[0,a0,0]}); set(CONN_h.menus.m_preproc_00{17},'string',['Voxel-to-voxel connectivity (r) (dof=',num2str(CONN_h.menus.m_preproc.opt.dof),')']); else conn_menu('updatehist',CONN_h.menus.m_preproc_00{16},[]);end end if model, if any(CONN_x.Setup.steps([2,3])),%~isfield(CONN_x.Setup,'doROIonly')||~CONN_x.Setup.doROIonly, t1=zeros(CONN_h.menus.m_preproc.Y.matdim.dim(1:2)); t2=nan+zeros(CONN_h.menus.m_preproc.Y.matdim.dim(1:2)); idx=find(CONN_h.menus.m_preproc.select{2}); C=eye(size(CONN_h.menus.m_preproc.X,2)); if ~isempty(idx), C=pinv(CONN_h.menus.m_preproc.opt.X(:,[1,idx]))*CONN_h.menus.m_preproc.opt.X; C=C(2:end,:); % unique + shared variance %C=C(idx,:); % unique variance end [h,F,p,dof,R]=conn_glmunivariate('evaluate',CONN_h.menus.m_preproc.opt,[],C); t1(CONN_h.menus.m_preproc.y.idx)=R; t1=permute(t1,[2,1,3]); %f=conn_hanning(5)/sum(conn_hanning(5)); t1=convn(convn(convn(t1,f,'same'),f','same'),shiftdim(f,-2),'same'); t2(CONN_h.menus.m_preproc.y.idx)=abs(R); t2=permute(t2,[2,1,3]); %f=conn_hanning(5)/sum(conn_hanning(5)); t2=convn(convn(convn(t2,f,'same'),f','same'),shiftdim(f,-2),'same'); %t(CONN_h.menus.m_preproc.Y.voxels)=sqrt(sum(abs(CONN_h.menus.m_preproc.B(find(CONN_h.menus.m_preproc.select{2}),:)).^2,1))'; conn_menu('update',CONN_h.menus.m_preproc_00{14},{CONN_h.menus.m_preproc.Xs,t1,t2},{CONN_h.menus.m_preproc.Y.matdim,CONN_h.menus.m_preproc.y.slice}); end end case 'gui_preproc_done', if isempty(CONN_x.filename), conn gui_setup_save; end conn_menumanager clf; axes('units','norm','position',[0,.935,1,.005]); image(shiftdim(1-get(CONN_h.screen.hfig,'color'),-1)); axis off; conn_menumanager([CONN_h.menus.m0],'on',1); conn_process('preprocessing_gui'); conn gui_setup_save; conn gui_preproc; conn gui_setup_save; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'gui_analyses', CONN_x.gui=1; model=0; if ~isfield(CONN_x,'Analysis'), CONN_x.Analysis=1; end ianalysis=CONN_x.Analysis; if ~isfield(CONN_x.Analyses(ianalysis),'name'),CONN_x.Analyses(ianalysis).name='ANALYSIS_01'; end state=find(conn_menumanager(CONN_h.menus.m_analyses_03,'state')); states={[1,2],3};istates=[1,1,2]; state=states{state}; if ~any(CONN_x.Setup.steps(state)) state=find(CONN_x.Setup.steps,1,'first'); if isempty(state), uiwait(errordlg('No ROI-to-ROI, seed-to-voxel, or voxel-to-voxel analyses prepared. Select these options in ''Setup->Options'' to perform additional analyses','')); conn gui_setup; return; end tstate=zeros(size(conn_menumanager(CONN_h.menus.m_analyses_03,'state')));tstate(istates(state))=1; conn_menumanager(CONN_h.menus.m_analyses_03,'state',tstate); end if state(1)==1, %SEED-TO-VOXEL or ROI-TO-ROI if nargin<2, if ~any(CONN_x.Setup.steps(state)), uiwait(errordlg('No seed-to-voxel or ROI-to-ROI analyses computed. Select these options in ''Setup->Options'' to perform additional analyses','')); conn gui_setup; return; end conn_menumanager clf; axes('units','norm','position',[0,.935,1,.005]); image(shiftdim(1-get(CONN_h.screen.hfig,'color'),-1)); axis off; conn_menumanager([CONN_h.menus.m_analyses_02,CONN_h.menus.m_analyses_03,CONN_h.menus.m_setup_06,CONN_h.menus.m0],'on',1); if isempty(CONN_x.Analyses(ianalysis).variables.names), uiwait(errordlg('Data not prepared for analyses. Press "done" in the Preprocessing window','')); return; end conn_menu('frame',[.09,.13,.33,.67],'GLM CONNECTIVITY - DEFINE SOURCES'); CONN_h.menus.m_analyses_00{1}=conn_menu('listbox',[.10,.25,.075,.5],'','','','conn(''gui_analyses'',1);'); CONN_h.menus.m_analyses_00{2}=conn_menu('listbox',[.20,.25,.075,.5],'Sources','','','conn(''gui_analyses'',2);'); CONN_h.menus.m_analyses_00{3}=conn_menu('image',[.30,.25,.11,.31],''); CONN_h.menus.m_analyses_00{4}=conn_menu('edit',[.30,.7,.11,.04],'derivatives order','','Include derivates up to n-th order (0 for no derivatives, 1 for first-order derivatives,...)','conn(''gui_analyses'',4);'); %CONN_h.menus.m_analyses_00{5}=conn_menu('edit',[.05,.15,.175,.04],'band-pass filter (Hz)',num2str(CONN_x.Analyses(ianalysis).filter),'Band pass filter threshold (two values, low-pass and high-pass thresholds, respectively)','conn(''gui_analyses'',5);'); CONN_h.menus.m_analyses_00{6}=conn_menu('edit',[.30,.6,.11,.04],'dimensions','','Number of dimensions','conn(''gui_analyses'',6);'); connmeasures={'correlation (bivariate)','correlation (semipartial)','regression (bivariate)','regression (multivariate)'}; CONN_h.menus.m_analyses_00{7}=conn_menu('popup',[.10,.15,.1,.04],'Measure',connmeasures,'Choose outcome measure of connectivity for second level analyses','conn(''gui_analyses'',7);'); CONN_h.menus.m_analyses_00{8}=conn_menu('popup',[.20,.15,.1,.04],'Weights',{'none','hrf','hanning'},'Choose method for weighting samples within each condition block','conn(''gui_analyses'',8);'); CONN_h.menus.m_analyses_00{9}=conn_menu('popup',[.30,.15,.1,.04],'Analyses',{'ROI-to-ROI','Seed-to-Voxel','all'},'Choose analysis type','conn(''gui_analyses'',9);'); conn_menu('frame',[.44,.16,.47,.64],'PREVIEW RESULTS'); CONN_h.menus.m_analyses_00{11}=conn_menu('listbox',[.45,.25,.075,.5],'Subject','','','conn(''gui_analyses'',11);'); CONN_h.menus.m_analyses_00{12}=conn_menu('listbox',[.525,.25,.075,.5],'Conditions','','','conn(''gui_analyses'',12);'); CONN_h.menus.m_analyses_00{13}=conn_menu('listbox',[.6,.25,.075,.5],'Sources','','','conn(''gui_analyses'',13);'); CONN_h.menus.m_analyses_00{14}=conn_menu('image',[.7,.25,.17,.5],'connectivity'); pos=[.7,.25,.17,.5]; if any(CONN_x.Setup.steps([2,3])), uicontrol('style','text','units','norm','position',[pos(1)+pos(3)-.170,pos(2)-2*.04,.070,.04],'string','threshold','fontname','default','fontsize',8,'backgroundcolor',get(CONN_h.screen.hfig,'color')/2,'foregroundcolor',1-get(CONN_h.screen.hfig,'color')); CONN_h.menus.m_analyses_00{15}=uicontrol('style','slider','units','norm','position',[pos(1)+pos(3)-0*.015,pos(2),.015,pos(4)],'callback','conn(''gui_analyses'',15);','backgroundcolor',get(CONN_h.screen.hfig,'color')/2); end txt=strvcat(CONN_x.Analyses(:).name,'new'); CONN_h.menus.m_analyses_00{20}=uicontrol('units','norm','position',[.76,.88,.15,.05],'style','popupmenu','string',txt,'value',ianalysis,'backgroundcolor',get(CONN_h.screen.hfig,'color'),'foregroundcolor',1-get(CONN_h.screen.hfig,'color'),'callback','conn(''gui_analyses'',20);'); if ~isfield(CONN_x.Analyses(ianalysis),'measure') || isempty(CONN_x.Analyses(ianalysis).measure), CONN_x.Analyses(ianalysis).measure=1; end set(CONN_h.menus.m_analyses_00{7},'value',CONN_x.Analyses(ianalysis).measure); if ~isfield(CONN_x.Analyses(ianalysis),'weight') || isempty(CONN_x.Analyses(ianalysis).weight), CONN_x.Analyses(ianalysis).weight=2; end if ~isfield(CONN_x.Analyses(ianalysis),'type') || isempty(CONN_x.Analyses(ianalysis).type), CONN_x.Analyses(ianalysis).type=3; end set(CONN_h.menus.m_analyses_00{8},'value',CONN_x.Analyses(ianalysis).weight); set(CONN_h.menus.m_analyses_00{9},'value',CONN_x.Analyses(ianalysis).type); set([CONN_h.menus.m_analyses_00{1},CONN_h.menus.m_analyses_00{2}],'max',2); set(CONN_h.menus.m_analyses_00{1},'string',CONN_x.Analyses(ianalysis).variables.names); set(CONN_h.menus.m_analyses_00{2},'string',CONN_x.Analyses(ianalysis).regressors.names); conn_menumanager(CONN_h.menus.m_analyses_01,'on',1); set([CONN_h.menus.m_analyses_00{1},CONN_h.menus.m_analyses_00{2}],'value',[]); set(CONN_h.menus.m_analyses_00{4},'visible','off');% set(CONN_h.menus.m_analyses_00{6},'visible','off');% set([CONN_h.menus.m_analyses_00{11},CONN_h.menus.m_analyses_00{12},CONN_h.menus.m_analyses_00{13}],'max',1); set(CONN_h.menus.m_analyses_00{11},'string',[repmat('Subject ',[CONN_x.Setup.nsubjects,1]),num2str((1:CONN_x.Setup.nsubjects)')]); nconditions=length(CONN_x.Setup.conditions.names)-1; set(CONN_h.menus.m_analyses_00{12},'string',{CONN_x.Setup.conditions.names{1:end-1}},'value',min(nconditions,get(CONN_h.menus.m_analyses_00{12},'value'))); set(CONN_h.menus.m_analyses_00{13},'string',{'TOTAL',CONN_x.Analyses(ianalysis).regressors.names{:}}); %set(CONN_h.screen.hfig,'pointer','watch'); %[path,name,ext]=fileparts(CONN_x.filename); % filepath=fullfile(path,name,'data'); filepath=CONN_x.folders.preprocessing; if any(CONN_x.Setup.steps([2,3])),%~isfield(CONN_x.Setup,'doROIonly')||~CONN_x.Setup.doROIonly, filename=fullfile(filepath,['DATA_Subject',num2str(1,'%03d'),'_Condition',num2str(1,'%03d'),'.mat']); CONN_h.menus.m_analyses.Y=conn_vol(filename); CONN_h.menus.m_analyses.y.slice=ceil(CONN_h.menus.m_analyses.Y.matdim.dim(3)/2); [CONN_h.menus.m_analyses.y.data,CONN_h.menus.m_analyses.y.idx]=conn_get_slice(CONN_h.menus.m_analyses.Y,CONN_h.menus.m_analyses.y.slice); end filename=fullfile(filepath,['ROI_Subject',num2str(1,'%03d'),'_Condition',num2str(1,'%03d'),'.mat']); CONN_h.menus.m_analyses.X1=load(filename); try CONN_h.menus.m_analyses.XS=spm_vol(deblank(CONN_x.Setup.structural{1}{1})); catch CONN_h.menus.m_analyses.XS=spm_vol(fullfile(fileparts(which('spm')),'canonical','single_subj_T1.nii')); end if any(CONN_x.Setup.steps([2,3])),%~isfield(CONN_x.Setup,'doROIonly')||~CONN_x.Setup.doROIonly, xyz=conn_convertcoordinates('idx2tal',prod(CONN_h.menus.m_analyses.Y.matdim.dim(1:2))*(CONN_h.menus.m_analyses.y.slice-1)+(1:prod(CONN_h.menus.m_analyses.Y.matdim.dim(1:2))),CONN_h.menus.m_analyses.Y.matdim.mat,CONN_h.menus.m_analyses.Y.matdim.dim); CONN_h.menus.m_analyses.Xs=spm_get_data(CONN_h.menus.m_analyses.XS(1),pinv(CONN_h.menus.m_analyses.XS(1).mat)*xyz'); CONN_h.menus.m_analyses.Xs=permute(reshape(CONN_h.menus.m_analyses.Xs,CONN_h.menus.m_analyses.Y.matdim.dim(1:2)),[2,1,3]); set(CONN_h.menus.m_analyses_00{15},'min',1,'max',CONN_h.menus.m_analyses.Y.matdim.dim(3),'sliderstep',min(.5,[1,10]/(CONN_h.menus.m_analyses.Y.matdim.dim(3)-1)),'value',CONN_h.menus.m_analyses.y.slice); end model=1; else switch(varargin{2}), case 0, str=conn_menumanager(CONN_h.menus.m_analyses_01,'string'); switch(str{1}(1)), case '>', ncovariates=get(CONN_h.menus.m_analyses_00{1},'value'); for ncovariate=ncovariates(:)', if isempty(strmatch(CONN_x.Analyses(ianalysis).variables.names{ncovariate},CONN_x.Analyses(ianalysis).regressors.names,'exact')), CONN_x.Analyses(ianalysis).regressors.names{end+1}=CONN_x.Analyses(ianalysis).variables.names{ncovariate}; CONN_x.Analyses(ianalysis).regressors.types{end+1}=CONN_x.Analyses(ianalysis).variables.types{ncovariate}; CONN_x.Analyses(ianalysis).regressors.deriv{end+1}=CONN_x.Analyses(ianalysis).variables.deriv{ncovariate}; CONN_x.Analyses(ianalysis).regressors.dimensions{end+1}=CONN_x.Analyses(ianalysis).variables.dimensions{ncovariate}; end end set(CONN_h.menus.m_analyses_00{2},'string',CONN_x.Analyses(ianalysis).regressors.names); set(CONN_h.menus.m_analyses_00{13},'string',{'TOTAL',CONN_x.Analyses(ianalysis).regressors.names{:}}); case '<', ncovariates=get(CONN_h.menus.m_analyses_00{2},'value'); idx=setdiff(1:length(CONN_x.Analyses(ianalysis).regressors.names),ncovariates); CONN_x.Analyses(ianalysis).regressors.names={CONN_x.Analyses(ianalysis).regressors.names{idx}}; CONN_x.Analyses(ianalysis).regressors.types={CONN_x.Analyses(ianalysis).regressors.types{idx}}; CONN_x.Analyses(ianalysis).regressors.deriv={CONN_x.Analyses(ianalysis).regressors.deriv{idx}}; CONN_x.Analyses(ianalysis).regressors.dimensions={CONN_x.Analyses(ianalysis).regressors.dimensions{idx}}; set(CONN_h.menus.m_analyses_00{2},'string',CONN_x.Analyses(ianalysis).regressors.names,'value',min(max(ncovariates),length(CONN_x.Analyses(ianalysis).regressors.names))); set(CONN_h.menus.m_analyses_00{13},'string',{'TOTAL',CONN_x.Analyses(ianalysis).regressors.names{:}},'value',min(max(get(CONN_h.menus.m_analyses_00{13},'value')),length(CONN_x.Analyses(ianalysis).regressors.names)+1)); end model=1; case 1, conn_menumanager(CONN_h.menus.m_analyses_01,'string',{'>>'},'on',1); set(CONN_h.menus.m_analyses_00{2},'value',[]); set([CONN_h.menus.m_analyses_00{4},CONN_h.menus.m_analyses_00{6}],'visible','off');% case 2, conn_menumanager(CONN_h.menus.m_analyses_01,'string',{'<<'},'on',1); set(CONN_h.menus.m_analyses_00{1},'value',[]); set([CONN_h.menus.m_analyses_00{4},CONN_h.menus.m_analyses_00{6}],'visible','on','backgroundcolor','k','foregroundcolor','w');% case 4, nregressors=get(CONN_h.menus.m_analyses_00{2},'value'); value=str2num(get(CONN_h.menus.m_analyses_00{4},'string')); if length(value)==1, for nregressor=nregressors(:)', CONN_x.Analyses(ianalysis).regressors.deriv{nregressor}=min(2,value); end; end model=1; case 6, nregressors=get(CONN_h.menus.m_analyses_00{2},'value'); value=str2num(get(CONN_h.menus.m_analyses_00{6},'string')); if length(value)==1, for nregressor=nregressors(:)', CONN_x.Analyses(ianalysis).regressors.dimensions{nregressor}(1)=max(1,min(CONN_x.Analyses(ianalysis).regressors.dimensions{nregressor}(2),value)); end; end model=1; case 7, CONN_x.Analyses(ianalysis).measure=get(CONN_h.menus.m_analyses_00{7},'value'); model=2; case 8, CONN_x.Analyses(ianalysis).weight=get(CONN_h.menus.m_analyses_00{8},'value'); model=1; case 9, CONN_x.Analyses(ianalysis).type=get(CONN_h.menus.m_analyses_00{9},'value'); model=1; case {11,12}, nsubs=get(CONN_h.menus.m_analyses_00{11},'value'); nconditions=get(CONN_h.menus.m_analyses_00{12},'value'); %[path,name,ext]=fileparts(CONN_x.filename); filepath=CONN_x.folders.preprocessing; if any(CONN_x.Setup.steps([2,3])),%~isfield(CONN_x.Setup,'doROIonly')||~CONN_x.Setup.doROIonly, filename=fullfile(filepath,['DATA_Subject',num2str(nsubs,'%03d'),'_Condition',num2str(nconditions,'%03d'),'.mat']); CONN_h.menus.m_analyses.Y=conn_vol(filename); [CONN_h.menus.m_analyses.y.data,CONN_h.menus.m_analyses.y.idx]=conn_get_slice(CONN_h.menus.m_analyses.Y,CONN_h.menus.m_analyses.y.slice); end filename=fullfile(filepath,['ROI_Subject',num2str(nsubs,'%03d'),'_Condition',num2str(nconditions,'%03d'),'.mat']); CONN_h.menus.m_analyses.X1=load(filename); %filename=fullfile(filepath,['COV_Subject',num2str(nsubs,'%03d'),'_Session',num2str(nconditions,'%03d'),'.mat']); %CONN_h.menus.m_analyses.X2=load(filename); try CONN_h.menus.m_analyses.XS=spm_vol(deblank(CONN_x.Setup.structural{nsubs}{1})); catch CONN_h.menus.m_analyses.XS=spm_vol(fullfile(fileparts(which('spm')),'canonical','single_subj_T1.nii')); end if any(CONN_x.Setup.steps([2,3])),%~isfield(CONN_x.Setup,'doROIonly')||~CONN_x.Setup.doROIonly, xyz=conn_convertcoordinates('idx2tal',prod(CONN_h.menus.m_analyses.Y.matdim.dim(1:2))*(CONN_h.menus.m_analyses.y.slice-1)+(1:prod(CONN_h.menus.m_analyses.Y.matdim.dim(1:2))),CONN_h.menus.m_analyses.Y.matdim.mat,CONN_h.menus.m_analyses.Y.matdim.dim); CONN_h.menus.m_analyses.Xs=spm_get_data(CONN_h.menus.m_analyses.XS(1),pinv(CONN_h.menus.m_analyses.XS(1).mat)*xyz'); CONN_h.menus.m_analyses.Xs=permute(reshape(CONN_h.menus.m_analyses.Xs,CONN_h.menus.m_analyses.Y.matdim.dim(1:2)),[2,1,3]); end model=1; case 13, model=2; case 15, CONN_h.menus.m_analyses.y.slice=round(get(CONN_h.menus.m_analyses_00{15},'value')); [CONN_h.menus.m_analyses.y.data,CONN_h.menus.m_analyses.y.idx]=conn_get_slice(CONN_h.menus.m_analyses.Y,CONN_h.menus.m_analyses.y.slice); xyz=conn_convertcoordinates('idx2tal',prod(CONN_h.menus.m_analyses.Y.matdim.dim(1:2))*(CONN_h.menus.m_analyses.y.slice-1)+(1:prod(CONN_h.menus.m_analyses.Y.matdim.dim(1:2))),CONN_h.menus.m_analyses.Y.matdim.mat,CONN_h.menus.m_analyses.Y.matdim.dim); CONN_h.menus.m_analyses.Xs=spm_get_data(CONN_h.menus.m_analyses.XS(1),pinv(CONN_h.menus.m_analyses.XS(1).mat)*xyz'); CONN_h.menus.m_analyses.Xs=permute(reshape(CONN_h.menus.m_analyses.Xs,CONN_h.menus.m_analyses.Y.matdim.dim(1:2)),[2,1,3]); model=1; case 20, tianalysis=get(CONN_h.menus.m_analyses_00{20},'value'); analysisname=get(CONN_h.menus.m_analyses_00{20},'string'); if strcmp(deblank(analysisname(tianalysis,:)),'new'), ok=0; while ~ok, txt=inputdlg('New analysis name:','conn',1,{['ANALYSIS_',num2str(tianalysis,'%02d')]}); if isempty(txt), break; end txt{1}(txt{1}==' ')='_'; [ok,nill]=mkdir(CONN_x.folders.firstlevel,txt{1}); if ~ok, errordlg('Analysis name must be a valid name for a folder','conn');end end if ok, CONN_x.Analyses(tianalysis)=CONN_x.Analyses(ianalysis); CONN_x.Analyses(tianalysis).name=txt{1}; CONN_x.Analyses(tianalysis).sourcenames={}; CONN_x.Analysis=tianalysis; conn gui_analyses; return; else set(CONN_h.menus.m_analyses_00{20},'value',ianalysis); end else CONN_x.Analysis=tianalysis; conn gui_analyses; return; end end end nsubs=get(CONN_h.menus.m_analyses_00{11},'value'); nregressors=get(CONN_h.menus.m_analyses_00{2},'value'); nview=get(CONN_h.menus.m_analyses_00{13},'value')-1; [CONN_h.menus.m_analyses.X,CONN_h.menus.m_analyses.select]=conn_designmatrix(CONN_x.Analyses(ianalysis).regressors,CONN_h.menus.m_analyses.X1,[],{nregressors,nview}); if isempty(nregressors), conn_menu('update',CONN_h.menus.m_analyses_00{3},[]); else conn_menu('update',CONN_h.menus.m_analyses_00{3},CONN_h.menus.m_analyses.X); end if ~isempty(nregressors)&&all(nregressors>0), temp=cat(1,CONN_x.Analyses(ianalysis).regressors.deriv{nregressors}); if length(temp)==1 || ~any(any(diff(temp,1,1))),set(CONN_h.menus.m_analyses_00{4},'string',num2str(CONN_x.Analyses(ianalysis).regressors.deriv{nregressors(1)})); else set(CONN_h.menus.m_analyses_00{4},'string','MULTIPLE VALUES'); end temp=cat(1,CONN_x.Analyses(ianalysis).regressors.dimensions{nregressors}); if size(temp,1)==1 || ~any(any(diff(temp,1,1))),set(CONN_h.menus.m_analyses_00{6},'string',num2str(CONN_x.Analyses(ianalysis).regressors.dimensions{nregressors(1)}(1))); else set(CONN_h.menus.m_analyses_00{6},'string','MULTIPLE VALUES'); end end if size(CONN_h.menus.m_analyses.X,2)<=500, offon={'off','on'}; for n1=1:size(CONN_h.menus.m_analyses.X,2), set(CONN_h.menus.m_analyses_00{3}.h4(n1),'visible',offon{1+CONN_h.menus.m_analyses.select{1}(n1)}); end xtemp=CONN_h.menus.m_analyses.X(:,find(CONN_h.menus.m_analyses.select{1})); if ~isempty(xtemp), set(CONN_h.menus.m_analyses_00{3}.h3,'ylim',[min(min(xtemp))-1e-4,max(max(xtemp))+1e-4]); end end if model==1, if any(CONN_x.Setup.steps([2,3])),%~isfield(CONN_x.Setup,'doROIonly')||~CONN_x.Setup.doROIonly, xf=CONN_h.menus.m_analyses.X; yf=CONN_h.menus.m_analyses.y.data; switch(CONN_x.Analyses(ianalysis).weight), case 1, case 2, xf=xf.*repmat(CONN_h.menus.m_analyses.X1.conditionweights{1},[1,size(xf,2)]);yf=yf.*repmat(CONN_h.menus.m_analyses.X1.conditionweights{1},[1,size(yf,2)]); case 3, xf=xf.*repmat(CONN_h.menus.m_analyses.X1.conditionweights{2},[1,size(xf,2)]);yf=yf.*repmat(CONN_h.menus.m_analyses.X1.conditionweights{2},[1,size(yf,2)]); end [CONN_h.menus.m_analyses.B,CONN_h.menus.m_analyses.opt]=conn_glmunivariate('estimate',xf,yf); else xf=CONN_h.menus.m_analyses.X; switch(CONN_x.Analyses(ianalysis).weight), case 1, case 2, xf=xf.*repmat(CONN_h.menus.m_analyses.X1.conditionweights{1},[1,size(xf,2)]); case 3, xf=xf.*repmat(CONN_h.menus.m_analyses.X1.conditionweights{2},[1,size(xf,2)]); end end %CONN_h.menus.m_analyses.B=pinv(CONN_h.menus.m_analyses.X)*CONN_h.menus.m_analyses.Y.data; end if model, if any(CONN_x.Setup.steps([2,3])),%~isfield(CONN_x.Setup,'doROIonly')||~CONN_x.Setup.doROIonly, t1=zeros(CONN_h.menus.m_analyses.Y.matdim.dim(1:2)); t2=0+zeros(CONN_h.menus.m_analyses.Y.matdim.dim(1:2)); idx=find(CONN_h.menus.m_analyses.select{2}); C=eye(size(CONN_h.menus.m_analyses.X,2)); if ~isempty(idx), switch(CONN_x.Analyses(ianalysis).measure), case {1,3}, %bivariate C=pinv(CONN_h.menus.m_analyses.opt.X(:,[1,idx]))*CONN_h.menus.m_analyses.opt.X; C=C(2:end,:); % unique + shared variance case {2,4}, %partial C=C(idx,:); % unique variance end end [h,F,p,dof,R]=conn_glmunivariate('evaluate',CONN_h.menus.m_analyses.opt,[],C); switch(CONN_x.Analyses(ianalysis).measure), case {1,2}, %correlation S1=sign(R).*sqrt(abs(R)); S2=abs(S1); case {3,4}, %regression S1=h; if size(S1,1)>1, S1=sqrt(sum(abs(S1).^2,1)); end; S2=abs(S1); end t1(CONN_h.menus.m_analyses.y.idx)=S1; t1=permute(t1,[2,1,3]); t2(CONN_h.menus.m_analyses.y.idx)=S2; t2=permute(t2,[2,1,3]); conn_menu('update',CONN_h.menus.m_analyses_00{14},{CONN_h.menus.m_analyses.Xs,t1,t2},{CONN_h.menus.m_analyses.Y.matdim,CONN_h.menus.m_analyses.y.slice}); end end else % VOXEL-TO-VOXEL if nargin<2, if ~any(CONN_x.Setup.steps(state)), uiwait(errordlg('No seed-to-voxel or ROI-to-ROI analyses computed. Select these options in ''Setup->Options'' to perform additional analyses','')); conn gui_setup; return; end conn_menumanager clf; axes('units','norm','position',[0,.935,1,.005]); image(shiftdim(1-get(CONN_h.screen.hfig,'color'),-1)); axis off; conn_menumanager([CONN_h.menus.m_analyses_04,CONN_h.menus.m_analyses_03,CONN_h.menus.m_setup_06,CONN_h.menus.m0],'on',1); if isempty(CONN_x.vvAnalyses.variables.names), uiwait(errordlg('Data not prepared for analyses. Press "done" in the Preprocessing window','')); return; end conn_menu('frame',[.09,.16,.33,.64],'DEFINE VOXEL-TO-VOXEL MEASURES'); CONN_h.menus.m_analyses_00{1}=conn_menu('listbox',[.10,.25,.075,.5],'','','','conn(''gui_analyses'',1);'); CONN_h.menus.m_analyses_00{2}=conn_menu('listbox',[.20,.25,.075,.5],'Measures','','','conn(''gui_analyses'',2);'); [CONN_h.menus.m_analyses_00{4}(1),CONN_h.menus.m_analyses_00{4}(2)]=conn_menu('edit',[.30,.6,.11,.04],'Kernel size (mm)','','Define integration kernel size (FWHM of Gaussian kernel) (note, special cases: 0 for single voxel; inf for entire brain)','conn(''gui_analyses'',4);'); measuretypes={'Local','Global'}; [CONN_h.menus.m_analyses_00{5}(1),CONN_h.menus.m_analyses_00{5}(2)]=conn_menu('popup',[.30,.3,.11,.04],'Measure type',measuretypes,'Select type of voxel-to-voxel measure (local for analyses of local connectivity patterns; global for analyses of global connectivity patterns)','conn(''gui_analyses'',5);'); measuretypes={'Gaussian','Gradient','Laplacian'}; [CONN_h.menus.m_analyses_00{6}(1),CONN_h.menus.m_analyses_00{6}(2)]=conn_menu('popup',[.30,.2,.11,.04],'Kernel shape',measuretypes,'Define integration kernel shape','conn(''gui_analyses'',6);'); [CONN_h.menus.m_analyses_00{7}(1),CONN_h.menus.m_analyses_00{7}(2)]=conn_menu('edit',[.30,.7,.11,.04],'Name','','name of voxel-to-voxel measure','conn(''gui_analyses'',7);'); [CONN_h.menus.m_analyses_00{8}(1),CONN_h.menus.m_analyses_00{8}(2)]=conn_menu('edit',[.30,.5,.11,.04],'1st-level dimens.','','Define number of subject-level SVD components to retain (set to inf for no dimensionality reduction)','conn(''gui_analyses'',8);'); [CONN_h.menus.m_analyses_00{9}(1),CONN_h.menus.m_analyses_00{9}(2)]=conn_menu('edit',[.30,.4,.11,.04],'2nd-level dimens.','','Define number of group-level SVD components to retain','conn(''gui_analyses'',9);'); conn_menu('frame',[.44,.16,.47,.64],'PREVIEW RESULTS'); CONN_h.menus.m_analyses_00{11}=conn_menu('listbox',[.45,.25,.075,.5],'Subject','','','conn(''gui_analyses'',11);'); CONN_h.menus.m_analyses_00{12}=conn_menu('listbox',[.525,.25,.075,.5],'Conditions','','','conn(''gui_analyses'',12);'); CONN_h.menus.m_analyses_00{13}=conn_menu('listbox',[.6,.25,.075,.5],'Measures','','','conn(''gui_analyses'',13);'); CONN_h.menus.m_analyses_00{14}=conn_menu('image',[.7,.25,.17,.5],'connectivity'); pos=[.7,.25,.17,.5]; if any(CONN_x.Setup.steps([2,3])), uicontrol('style','text','units','norm','position',[pos(1)+pos(3)-.170,pos(2)-2*.04,.070,.04],'string','threshold','fontname','default','fontsize',8,'backgroundcolor',get(CONN_h.screen.hfig,'color')/2,'foregroundcolor',1-get(CONN_h.screen.hfig,'color')); CONN_h.menus.m_analyses_00{15}=uicontrol('style','slider','units','norm','position',[pos(1)+pos(3)-0*.015,pos(2),.015,pos(4)],'callback','conn(''gui_analyses'',15);','backgroundcolor',get(CONN_h.screen.hfig,'color')/2); end %set([CONN_h.menus.m_analyses_00{1}],'max',2); set([CONN_h.menus.m_analyses_00{1},CONN_h.menus.m_analyses_00{2}],'max',2); set(CONN_h.menus.m_analyses_00{1},'string',CONN_x.vvAnalyses.variables.names); set(CONN_h.menus.m_analyses_00{2},'string',CONN_x.vvAnalyses.regressors.names); conn_menumanager(CONN_h.menus.m_analyses_01,'on',1); set([CONN_h.menus.m_analyses_00{11},CONN_h.menus.m_analyses_00{12},CONN_h.menus.m_analyses_00{13}],'max',1); set(CONN_h.menus.m_analyses_00{11},'string',[repmat('Subject ',[CONN_x.Setup.nsubjects,1]),num2str((1:CONN_x.Setup.nsubjects)')]); nconditions=length(CONN_x.Setup.conditions.names)-1; set(CONN_h.menus.m_analyses_00{12},'string',{CONN_x.Setup.conditions.names{1:end-1}},'value',1); set(CONN_h.menus.m_analyses_00{13},'string',CONN_x.vvAnalyses.regressors.names,'value',1); nsubs=1; nconditions=1; filepath=CONN_x.folders.preprocessing; if any(CONN_x.Setup.steps(3)),%~isfield(CONN_x.Setup,'doROIonly')||~CONN_x.Setup.doROIonly, filename=fullfile(filepath,['vvPC_Subject',num2str(nsubs,'%03d'),'_Condition',num2str(nconditions,'%03d'),'.mat']); CONN_h.menus.m_analyses.Y=conn_vol(filename); CONN_h.menus.m_analyses.y.slice=ceil(CONN_h.menus.m_analyses.Y.matdim.dim(3)/2); filename=fullfile(filepath,['vvPCeig_Subject',num2str(nsubs,'%03d'),'_Condition',num2str(nconditions,'%03d'),'.mat']); CONN_h.menus.m_analyses.y.data=load(filename,'D'); end try CONN_h.menus.m_analyses.XS=spm_vol(deblank(CONN_x.Setup.structural{nsubs}{1})); catch CONN_h.menus.m_analyses.XS=spm_vol(fullfile(fileparts(which('spm')),'canonical','single_subj_T1.nii')); end if any(CONN_x.Setup.steps(3)),%~isfield(CONN_x.Setup,'doROIonly')||~CONN_x.Setup.doROIonly, xyz=conn_convertcoordinates('idx2tal',prod(CONN_h.menus.m_analyses.Y.matdim.dim(1:2))*(CONN_h.menus.m_analyses.y.slice-1)+(1:prod(CONN_h.menus.m_analyses.Y.matdim.dim(1:2))),CONN_h.menus.m_analyses.Y.matdim.mat,CONN_h.menus.m_analyses.Y.matdim.dim); CONN_h.menus.m_analyses.Xs=spm_get_data(CONN_h.menus.m_analyses.XS(1),pinv(CONN_h.menus.m_analyses.XS(1).mat)*xyz'); CONN_h.menus.m_analyses.Xs=permute(reshape(CONN_h.menus.m_analyses.Xs,CONN_h.menus.m_analyses.Y.matdim.dim(1:2)),[2,1,3]); set(CONN_h.menus.m_analyses_00{15},'min',1,'max',CONN_h.menus.m_analyses.Y.matdim.dim(3),'sliderstep',min(.5,[1,10]/(CONN_h.menus.m_analyses.Y.matdim.dim(3)-1)),'value',CONN_h.menus.m_analyses.y.slice); end set(CONN_h.menus.m_analyses_00{14}.h10,'string','eps'); model=1; else switch(varargin{2}), case 0, str=conn_menumanager(CONN_h.menus.m_analyses_01,'string'); switch(str{1}(1)), case '>', ncovariates=get(CONN_h.menus.m_analyses_00{1},'value'); for ncovariate=ncovariates(:)', if 1,%isempty(strmatch(CONN_x.vvAnalyses.variables.names{ncovariate},CONN_x.vvAnalyses.regressors.names,'exact'))||strcmp(CONN_x.vvAnalyses.variables.names{ncovariate},'other (Generalized Functional form)'), optionsnames=fieldnames(CONN_x.vvAnalyses.variables); for n1=1:numel(optionsnames), CONN_x.vvAnalyses.regressors.(optionsnames{n1}){end+1}=CONN_x.vvAnalyses.variables.(optionsnames{n1}){ncovariate}; end end end set(CONN_h.menus.m_analyses_00{2},'string',CONN_x.vvAnalyses.regressors.names,'value',max(1,min(max(get(CONN_h.menus.m_analyses_00{2},'value')),length(CONN_x.vvAnalyses.regressors.names)))); set(CONN_h.menus.m_analyses_00{13},'string',CONN_x.vvAnalyses.regressors.names,'value',max(1,min(max(get(CONN_h.menus.m_analyses_00{13},'value')),length(CONN_x.vvAnalyses.regressors.names)))); case '<', ncovariates=get(CONN_h.menus.m_analyses_00{2},'value'); idx=setdiff(1:length(CONN_x.vvAnalyses.regressors.names),ncovariates); optionsnames=fieldnames(CONN_x.vvAnalyses.regressors); for n1=1:numel(optionsnames), CONN_x.vvAnalyses.regressors.(optionsnames{n1})={CONN_x.vvAnalyses.regressors.(optionsnames{n1}){idx}}; end set(CONN_h.menus.m_analyses_00{2},'string',CONN_x.vvAnalyses.regressors.names,'value',max(1,min(max(ncovariates),length(CONN_x.vvAnalyses.regressors.names)))); set(CONN_h.menus.m_analyses_00{13},'string',CONN_x.vvAnalyses.regressors.names,'value',max(1,min(max(get(CONN_h.menus.m_analyses_00{13},'value')),length(CONN_x.vvAnalyses.regressors.names)))); end model=1; case 1, conn_menumanager(CONN_h.menus.m_analyses_01,'string',{'>>'},'on',1); set(CONN_h.menus.m_analyses_00{2},'value',[]); set([CONN_h.menus.m_analyses_00{4},CONN_h.menus.m_analyses_00{5},CONN_h.menus.m_analyses_00{6},CONN_h.menus.m_analyses_00{7},CONN_h.menus.m_analyses_00{8}],'visible','off');% case 2, conn_menumanager(CONN_h.menus.m_analyses_01,'string',{'<<'},'on',1); set(CONN_h.menus.m_analyses_00{1},'value',[]); set([CONN_h.menus.m_analyses_00{4},CONN_h.menus.m_analyses_00{5},CONN_h.menus.m_analyses_00{6},CONN_h.menus.m_analyses_00{7},CONN_h.menus.m_analyses_00{8},CONN_h.menus.m_analyses_00{9}],'visible','on');%,'backgroundcolor','k','foregroundcolor','w');% case 4, nregressors=get(CONN_h.menus.m_analyses_00{2},'value'); value=str2num(get(CONN_h.menus.m_analyses_00{4}(1),'string')); if length(value)==1, for nregressor=nregressors(:)', CONN_x.vvAnalyses.regressors.localsupport{nregressor}=value; end; end nview=get(CONN_h.menus.m_analyses_00{13},'value'); model=any(nregressors==nview); case 5, nregressors=get(CONN_h.menus.m_analyses_00{2},'value'); value=get(CONN_h.menus.m_analyses_00{5}(1),'value')-1; if length(value)==1, for nregressor=nregressors(:)', CONN_x.vvAnalyses.regressors.global{nregressor}=value; end; end nview=get(CONN_h.menus.m_analyses_00{13},'value'); model=any(nregressors==nview); case 6, nregressors=get(CONN_h.menus.m_analyses_00{2},'value'); value=get(CONN_h.menus.m_analyses_00{6}(1),'value')-1; if length(value)==1, for nregressor=nregressors(:)', CONN_x.vvAnalyses.regressors.deriv{nregressor}=value; if CONN_x.vvAnalyses.regressors.deriv{nregressor}==1, CONN_x.vvAnalyses.regressors.dimensions_out{nregressor}=3; else CONN_x.vvAnalyses.regressors.dimensions_out{nregressor}=1; end; end; end nview=get(CONN_h.menus.m_analyses_00{13},'value'); model=any(nregressors==nview); case 7, nregressors=get(CONN_h.menus.m_analyses_00{2},'value'); txt=deblank(get(CONN_h.menus.m_analyses_00{7}(1),'string')); for nregressor=nregressors(:)', CONN_x.vvAnalyses.regressors.names{nregressor}=txt; end; set(CONN_h.menus.m_analyses_00{2},'string',CONN_x.vvAnalyses.regressors.names,'value',max(1,min(max(get(CONN_h.menus.m_analyses_00{2},'value')),length(CONN_x.vvAnalyses.regressors.names)))); set(CONN_h.menus.m_analyses_00{13},'string',CONN_x.vvAnalyses.regressors.names,'value',max(1,min(max(get(CONN_h.menus.m_analyses_00{13},'value')),length(CONN_x.vvAnalyses.regressors.names)))); case 8, nregressors=get(CONN_h.menus.m_analyses_00{2},'value'); value=str2num(get(CONN_h.menus.m_analyses_00{8}(1),'string')); if length(value)==1, for nregressor=nregressors(:)', CONN_x.vvAnalyses.regressors.dimensions_in{nregressor}=value; end; end nview=get(CONN_h.menus.m_analyses_00{13},'value'); model=any(nregressors==nview); case 9, nregressors=get(CONN_h.menus.m_analyses_00{2},'value'); value=str2num(get(CONN_h.menus.m_analyses_00{9}(1),'string')); if length(value)==1, for nregressor=nregressors(:)', CONN_x.vvAnalyses.regressors.dimensions_out{nregressor}=value; end; end nview=get(CONN_h.menus.m_analyses_00{13},'value'); model=any(nregressors==nview); case {11,12} nsubs=get(CONN_h.menus.m_analyses_00{11},'value'); nconditions=get(CONN_h.menus.m_analyses_00{12},'value'); filepath=CONN_x.folders.preprocessing; if any(CONN_x.Setup.steps([2,3])),%~isfield(CONN_x.Setup,'doROIonly')||~CONN_x.Setup.doROIonly, filename=fullfile(filepath,['vvPC_Subject',num2str(nsubs,'%03d'),'_Condition',num2str(nconditions,'%03d'),'.mat']); CONN_h.menus.m_analyses.Y=conn_vol(filename); filename=fullfile(filepath,['vvPCeig_Subject',num2str(nsubs,'%03d'),'_Condition',num2str(nconditions,'%03d'),'.mat']); CONN_h.menus.m_analyses.y.data=load(filename,'D'); end try CONN_h.menus.m_analyses.XS=spm_vol(deblank(CONN_x.Setup.structural{nsubs}{1})); catch CONN_h.menus.m_analyses.XS=spm_vol(fullfile(fileparts(which('spm')),'canonical','single_subj_T1.nii')); end if any(CONN_x.Setup.steps(3)),%~isfield(CONN_x.Setup,'doROIonly')||~CONN_x.Setup.doROIonly, xyz=conn_convertcoordinates('idx2tal',prod(CONN_h.menus.m_analyses.Y.matdim.dim(1:2))*(CONN_h.menus.m_analyses.y.slice-1)+(1:prod(CONN_h.menus.m_analyses.Y.matdim.dim(1:2))),CONN_h.menus.m_analyses.Y.matdim.mat,CONN_h.menus.m_analyses.Y.matdim.dim); CONN_h.menus.m_analyses.Xs=spm_get_data(CONN_h.menus.m_analyses.XS(1),pinv(CONN_h.menus.m_analyses.XS(1).mat)*xyz'); CONN_h.menus.m_analyses.Xs=permute(reshape(CONN_h.menus.m_analyses.Xs,CONN_h.menus.m_analyses.Y.matdim.dim(1:2)),[2,1,3]); end model=1; case 13 model=1; case 15 CONN_h.menus.m_analyses.y.slice=round(get(CONN_h.menus.m_analyses_00{15},'value')); % [CONN_h.menus.m_analyses.y.data,CONN_h.menus.m_analyses.y.idx]=conn_get_slice(CONN_h.menus.m_analyses.Y,CONN_h.menus.m_analyses.y.slice); xyz=conn_convertcoordinates('idx2tal',prod(CONN_h.menus.m_analyses.Y.matdim.dim(1:2))*(CONN_h.menus.m_analyses.y.slice-1)+(1:prod(CONN_h.menus.m_analyses.Y.matdim.dim(1:2))),CONN_h.menus.m_analyses.Y.matdim.mat,CONN_h.menus.m_analyses.Y.matdim.dim); CONN_h.menus.m_analyses.Xs=spm_get_data(CONN_h.menus.m_analyses.XS(1),pinv(CONN_h.menus.m_analyses.XS(1).mat)*xyz'); CONN_h.menus.m_analyses.Xs=permute(reshape(CONN_h.menus.m_analyses.Xs,CONN_h.menus.m_analyses.Y.matdim.dim(1:2)),[2,1,3]); model=1; end end nsubs=get(CONN_h.menus.m_analyses_00{11},'value'); nregressors=min(get(CONN_h.menus.m_analyses_00{2},'value'),numel(get(CONN_h.menus.m_analyses_00{2},'string'))); nview=get(CONN_h.menus.m_analyses_00{13},'value'); nmeasure=nview; % [CONN_h.menus.m_analyses.X,CONN_h.menus.m_analyses.select]=conn_designmatrix(CONN_x.Analyses(ianalysis).regressors,CONN_h.menus.m_analyses.X1,[],{nregressors,nview}); % if isempty(nregressors), conn_menu('update',CONN_h.menus.m_analyses_00{3},[]); % else conn_menu('update',CONN_h.menus.m_analyses_00{3},CONN_h.menus.m_analyses.X); end if ~isempty(nregressors)&&all(nregressors>0), temp=cat(1,CONN_x.vvAnalyses.regressors.localsupport{nregressors}); if length(temp)==1 || ~any(any(diff(temp,1,1))),set(CONN_h.menus.m_analyses_00{4}(1),'string',num2str(CONN_x.vvAnalyses.regressors.localsupport{nregressors(1)})); else set(CONN_h.menus.m_analyses_00{4}(1),'string','MULTIPLE VALUES'); end temp=cat(1,CONN_x.vvAnalyses.regressors.global{nregressors}); if 0,%size(temp,1)==1 || ~any(any(diff(temp,1,1))),set(CONN_h.menus.m_analyses_00{5}(1),'value',1+CONN_x.vvAnalyses.regressors.global{nregressors(1)}(1));set(CONN_h.menus.m_analyses_00{5},'visible','on'); else set(CONN_h.menus.m_analyses_00{5},'visible','off'); end temp=cat(1,CONN_x.vvAnalyses.regressors.deriv{nregressors}); if 0,%size(temp,1)==1 || ~any(any(diff(temp,1,1))),set(CONN_h.menus.m_analyses_00{6}(1),'value',1+CONN_x.vvAnalyses.regressors.deriv{nregressors(1)}(1));set(CONN_h.menus.m_analyses_00{6},'visible','on'); else set(CONN_h.menus.m_analyses_00{6},'visible','off'); end temp=strvcat(CONN_x.vvAnalyses.regressors.names{nregressors}); if size(temp,1)==1 || ~any(any(diff(temp,1,1))),set(CONN_h.menus.m_analyses_00{7}(1),'string',deblank(CONN_x.vvAnalyses.regressors.names{nregressors(1)}(1,:))); else set(CONN_h.menus.m_analyses_00{7}(1),'string','MULTIPLE VALUES'); end temp=cat(1,CONN_x.vvAnalyses.regressors.dimensions_in{nregressors}); if length(temp)==1 || ~any(any(diff(temp,1,1))),set(CONN_h.menus.m_analyses_00{8}(1),'string',num2str(CONN_x.vvAnalyses.regressors.dimensions_in{nregressors(1)})); else set(CONN_h.menus.m_analyses_00{8}(1),'string','MULTIPLE VALUES'); end temp=cat(1,CONN_x.vvAnalyses.regressors.dimensions_out{nregressors}); if length(temp)==1 || ~any(any(diff(temp,1,1))),set(CONN_h.menus.m_analyses_00{9}(1),'string',num2str(CONN_x.vvAnalyses.regressors.dimensions_out{nregressors(1)})); else set(CONN_h.menus.m_analyses_00{9}(1),'string','MULTIPLE VALUES'); end temp=cat(1,CONN_x.vvAnalyses.regressors.measuretype{nregressors}); if any(temp>1), set([CONN_h.menus.m_analyses_00{4},CONN_h.menus.m_analyses_00{5},CONN_h.menus.m_analyses_00{6}],'visible','off'); end if any(temp==1), set([CONN_h.menus.m_analyses_00{9}],'visible','off'); end else set([CONN_h.menus.m_analyses_00{4},CONN_h.menus.m_analyses_00{5},CONN_h.menus.m_analyses_00{6},CONN_h.menus.m_analyses_00{7},CONN_h.menus.m_analyses_00{8},CONN_h.menus.m_analyses_00{9}],'visible','off');% end value=get(CONN_h.menus.m_analyses_00{13},'value');if isempty(value),set(CONN_h.menus.m_analyses_00{13},'value',1); end if model&&any(CONN_x.Setup.steps(3)),%~isfield(CONN_x.Setup,'doROIonly')||~CONN_x.Setup.doROIonly, measures=CONN_x.vvAnalyses.regressors; if numel(measures.names)>0 if measures.measuretype{nmeasure}==1 set(CONN_h.screen.hfig,'pointer','watch');drawnow d=conn_v2v('compute_slice',measures,nmeasure,CONN_h.menus.m_analyses.Y,CONN_h.menus.m_analyses.y.data.D,CONN_h.menus.m_analyses.y.slice); set(CONN_h.screen.hfig,'pointer','arrow'); % t1=zeros(CONN_h.menus.m_analyses.Y(1).dim(1:2)); % t2=0+zeros(CONN_h.menus.m_analyses.Y(1).dim(1:2)); t1=d; t1=permute(t1,[2,1,3]); t2=abs(d); t2=permute(t2,[2,1,3]); set(CONN_h.menus.m_analyses_00{14}.h9,'string',num2str(max(t2(:)))); conn_menu('update',CONN_h.menus.m_analyses_00{14},{CONN_h.menus.m_analyses.Xs,t1,t2},{CONN_h.menus.m_analyses.Y.matdim,CONN_h.menus.m_analyses.y.slice}); conn_menu('updatecscale',[],[],CONN_h.menus.m_analyses_00{14}.h9); conn_menu('updatethr',[],[],CONN_h.menus.m_analyses_00{14}.h10); else conn_menu('update',CONN_h.menus.m_analyses_00{14},[]); end end end end case 'gui_analyses_done', if isempty(CONN_x.filename), conn gui_setup_save; end conn_menumanager clf; axes('units','norm','position',[0,.935,1,.005]); image(shiftdim(1-get(CONN_h.screen.hfig,'color'),-1)); axis off; conn_menumanager([CONN_h.menus.m0],'on',1); conn_process('analyses_gui_seed',CONN_x.Analysis); conn gui_setup_save; conn gui_analyses; conn gui_setup_save; case 'gui_analyses_done_vv', if isempty(CONN_x.filename), conn gui_setup_save; end conn_menumanager clf; axes('units','norm','position',[0,.935,1,.005]); image(shiftdim(1-get(CONN_h.screen.hfig,'color'),-1)); axis off; conn_menumanager([CONN_h.menus.m0],'on',1); conn_process('analyses_gui_vv'); conn gui_setup_save; conn gui_analyses; conn gui_setup_save; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'gui_results', CONN_x.gui=1; model=0;modelroi=0; if ~isfield(CONN_x.Setup,'normalized'), CONN_x.Setup.normalized=1; end if ~isfield(CONN_x,'Analysis'), CONN_x.Analysis=1; end ianalysis=CONN_x.Analysis; if ~isfield(CONN_x.Analyses(ianalysis),'name'),CONN_x.Analyses(ianalysis).name='ANALYSIS_01'; end state=find(conn_menumanager(CONN_h.menus.m_results_03,'state')); if isempty(CONN_x.Analyses(ianalysis).type), okstate=[true,true,true]; else okstate=[any(CONN_x.Analyses(ianalysis).type==[1,3]),any(CONN_x.Analyses(ianalysis).type==[2,3]),true]; end okstate=CONN_x.Setup.steps&okstate; if ~okstate(state) state=find(okstate,1,'first'); if isempty(state), uiwait(errordlg('No ROI-to-ROI, seed-to-voxel, or voxel-to-voxel analyses computed. Select these options in ''Setup->Options'' to perform additional analyses','')); conn gui_setup; return; end tstate=zeros(size(conn_menumanager(CONN_h.menus.m_results_03,'state')));tstate(state)=1; conn_menumanager(CONN_h.menus.m_results_03,'state',tstate); end if nargin<2, %if ~any(CONN_x.Setup.steps([1,2])), uiwait(errordlg('No seed-to-voxel or ROI-to-ROI analyses computed. Select these options in ''Setup->Options'' to perform additional analyses','')); conn gui_setup; return; end conn_menumanager clf; axes('units','norm','position',[0,.935,1,.005]); image(shiftdim(1-get(CONN_h.screen.hfig,'color'),-1)); axis off; tstate=conn_menumanager(CONN_h.menus.m0,'state'); tstate(:)=0;tstate(4)=1; conn_menumanager(CONN_h.menus.m0,'state',tstate); %conn_menumanager([CONN_h.menus.m0],'on',1); switch(state) case 1, conn_menumanager([CONN_h.menus.m_setup_06,CONN_h.menus.m_results_03,CONN_h.menus.m0,CONN_h.menus.m_results_04],'on',1); dp1=0;dp2=.27; case 2, conn_menumanager([CONN_h.menus.m_setup_06,CONN_h.menus.m_results_03,CONN_h.menus.m0,CONN_h.menus.m_results_05],'on',1); dp1=.4;dp2=0; case 3, conn_menumanager([CONN_h.menus.m_setup_06,CONN_h.menus.m_results_03,CONN_h.menus.m0,CONN_h.menus.m_results_06],'on',1); dp1=.4;dp2=0; end if (state==1||state==2) && (~isfield(CONN_x.Analyses(ianalysis),'sources')||isempty(CONN_x.Analyses(ianalysis).sources)), uiwait(errordlg('Data not prepared for results. Press "done" in the Analyses window','')); return; end if (state==3) && (~isfield(CONN_x.vvAnalyses,'measures')||isempty(CONN_x.vvAnalyses.measures)), uiwait(errordlg('Data not prepared for results. Press "done" in the Analyses window','')); return; end if ~isfield(CONN_x,'Results')||~isfield(CONN_x.Results,'xX'), CONN_x.Results.xX=[]; end conn_menu('frame',[.09,.06,.82,.77],'FUNCTIONAL CONNECTIVITY RESULTS'); CONN_h.menus.m_results_00{11}=conn_menu('listbox',[.10,.63-dp1,.175,.15+dp1],'Subject effects','','select subject effect(s) characterizing second-level analysis model','conn(''gui_results'',11);'); CONN_h.menus.m_results_00{12}=conn_menu('listbox',[.275,.63-dp1,.175,.15+dp1],'Conditions','','select condition(s) of interest','conn(''gui_results'',12);'); %connmeasures={'correlation (bivariate)','correlation (semipartial)','regression (bivariate)','regression (multivariate)'}; if state==3 CONN_h.menus.m_results_00{13}=conn_menu('listbox',[.45,.63-dp1,.175,.15+dp1],'Measures','','select voxel-to-voxel measure(s) of interest','conn(''gui_results'',13);'); else CONN_h.menus.m_results_00{13}=conn_menu('listbox',[.45,.63-dp1,.175,.15+dp1],'Sources','','select source ROI(s) of interest','conn(''gui_results'',13);'); end if state==2||state==3, pos=[.675,.15,.215,.59]; if state==2, [CONN_h.menus.m_results_00{14}]=conn_menu('image2',pos,'');%['Analysis results (voxel-level)']);%,connmeasures{CONN_x.Results.measure}]); else [CONN_h.menus.m_results_00{14}]=conn_menu('image2',pos,'');%['Connectivity measure (voxel-level)']); end if ~isfield(CONN_x.Results.xX,'displayvoxels'), CONN_x.Results.xX.displayvoxels=1; end CONN_h.menus.m_results_00{24}=uicontrol('style','text','units','norm','position',[pos(1)+pos(3)-.195,pos(2)-2*.04,.095,.04],'string','threshold (p-value)','fontname','default','fontsize',8,'backgroundcolor',get(CONN_h.screen.hfig,'color')/2,'foregroundcolor',1-get(CONN_h.screen.hfig,'color')); CONN_h.menus.m_results_00{15}=uicontrol('style','slider','units','norm','position',[pos(1)+pos(3)-0*.015,pos(2),.015,pos(4)],'callback','conn(''gui_results'',15);','backgroundcolor',get(CONN_h.screen.hfig,'color')/2); strstr3={'Analysis results preview (voxel-level)','Do not show analysis results preview'}; CONN_h.menus.m_results_00{32}=uicontrol('style','popupmenu','units','norm','position',[.70,.77,.205,.045],'string',strstr3,'value',CONN_x.Results.xX.displayvoxels,'backgroundcolor',get(CONN_h.screen.hfig,'color')/2,'foregroundcolor',1-get(CONN_h.screen.hfig,'color'),'tooltipstring','Display options','callback','conn(''gui_results'',32);'); end if state==1 [CONN_h.menus.m_results_00{18},CONN_h.menus.m_results_00{22}]=conn_menu('listbox2',[.10,.08,.55,.35],sprintf('%-32s%10s%10s%12s%12s','Targets','beta','T','p-unc','p-FDR'),'','browse target ROIs -or right click for more options-','conn(''gui_results'',18);'); set(CONN_h.menus.m_results_00{18},'max',2); hc1=uicontextmenu; %uimenu(hc1,'Label','Select target-ROIs set','callback','conn(''gui_results'',27)'); uimenu(hc1,'Label','Export stats','callback',@conn_exporttable); set(CONN_h.menus.m_results_00{18},'uicontextmenu',hc1); uicontrol('style','text','units','norm','position',[.10,.47,.55,.04],'string','Analysis results (ROI-level)','backgroundcolor',get(CONN_h.screen.hfig,'color')/2,'foregroundcolor',1-get(CONN_h.screen.hfig,'color'),'fontweight','bold','fontname','default','fontsize',8,'horizontalalignment','center'); if ~isfield(CONN_x.Results.xX,'inferencetype'), CONN_x.Results.xX.inferencetype=1; end if ~isfield(CONN_x.Results.xX,'inferencelevel'), CONN_x.Results.xX.inferencelevel=.05; end if ~isfield(CONN_x.Results.xX,'inferenceleveltype'), CONN_x.Results.xX.inferenceleveltype=1; end if ~isfield(CONN_x.Results.xX,'displayrois'), CONN_x.Results.xX.displayrois=1; end strstr1={'Two-sided','One-sided (positive)','One-sided (negative)'}; strstr2={'p-FDR corrected','p-uncorrected'}; strstr3={'Analysis results : Targets are all ROIs','Analysis results : Targets are source ROIs only','Analysis results : Targets are selected ROIs only'}; %CONN_h.menus.m_results_00{24}=uicontrol('style','text','units','norm','position',[.675,.08,.05,.045],'string','threshold','fontname','default','fontsize',8,'backgroundcolor',get(CONN_h.screen.hfig,'color')/2,'foregroundcolor',1-get(CONN_h.screen.hfig,'color')); CONN_h.menus.m_results_00{28}=uicontrol('style','popupmenu','units','norm','position',[.81,.08,.09,.045],'string',strstr1,'value',CONN_x.Results.xX.inferencetype,'backgroundcolor',get(CONN_h.screen.hfig,'color')/2,'foregroundcolor',1-get(CONN_h.screen.hfig,'color'),'tooltipstring','choose inference directionality','callback','conn(''gui_results'',28);'); CONN_h.menus.m_results_00{29}=uicontrol('style','popupmenu','units','norm','position',[.71,.08,.10,.045],'string',strstr2,'value',CONN_x.Results.xX.inferenceleveltype,'backgroundcolor',get(CONN_h.screen.hfig,'color')/2,'foregroundcolor',1-get(CONN_h.screen.hfig,'color'),'tooltipstring','choose type of false-positive control','callback','conn(''gui_results'',29);'); CONN_h.menus.m_results_00{30}=uicontrol('style','edit','units','norm','position',[.66,.08,.05,.045],'string',num2str(CONN_x.Results.xX.inferencelevel),'backgroundcolor',get(CONN_h.screen.hfig,'color')/2,'foregroundcolor',1-get(CONN_h.screen.hfig,'color'),'tooltipstring','enter false-positive threshold value','callback','conn(''gui_results'',30);'); CONN_h.menus.m_results_00{31}=uicontrol('style','popupmenu','units','norm','position',[.66,.77,.24,.045],'string',strstr3,'value',CONN_x.Results.xX.displayrois,'backgroundcolor',get(CONN_h.screen.hfig,'color')/2,'foregroundcolor',1-get(CONN_h.screen.hfig,'color'),'tooltipstring','choose target ROIs','callback','conn(''gui_results'',31);'); CONN_h.menus.m_results_00{25}=conn_menu('axes',[.65,.1,.25,.67]); h0=get(CONN_h.screen.hfig,'color')/2; %[nill,xs]=max(CONN_refs.canonical.data(:,:,end:-1:1)>.25,[],3); xs(~-nill)=max(xs(:)); xs=max(0,min(1, 1-xs/max(xs(:)) ))'; %a=spm_vol(CONN_x.Setup.rois.files{1}{1}{1});b=spm_read_vols(a); %[nill,idx]=max(b(:,:,end:-1:1)>.25,[],3); idx=max(idx(:))-idx;idx(~nill)=0;xs=(idx'/max(idx(:))).^2; %xs=conn_conv(mean(CONN_refs.canonical.data,3)',[0,0]);xs=max(0,min(1,xs/max(xs(:)))).^1; xs=conn_conv(mean(CONN_refs.canonical.data,3)',[0,0]);xs=max(0,min(1,xs/max(xs(:)))).^3; xs=bsxfun(@plus,shiftdim(h0,-1),bsxfun(@times,xs,shiftdim((1-h0),-1))); %h0=get(CONN_h.screen.hfig,'color')/2;xs=max(0,min(1,.5*abs(convn(mean(CONN_refs.canonical.data>.5&CONN_refs.canonical.data<.8,3)',[1;0;-1]*[1,0,-1],'same')))); xs=bsxfun(@plus,shiftdim(h0,-1),bsxfun(@times,xs,shiftdim((1-h0),-1))); hi=image(xs); set(gca,'xdir','reverse','ydir','normal'); axis(gca,'equal','tight','off'); hold on; CONN_h.menus.m_results_00{26}=patch(nan,nan,'k'); hc1=uicontextmenu;uimenu(hc1,'Label','3d view','callback','conn(''gui_results_roi3d'');');set(hi,'uicontextmenu',hc1); hold off; end [path,name,ext]=fileparts(CONN_x.filename); if state==1||state==2 filepathresults=fullfile(CONN_x.folders.firstlevel,CONN_x.Analyses(ianalysis).name); else filepathresults=CONN_x.folders.firstlevel; end ncovariates=length(CONN_x.Setup.l2covariates.names)-1; nconditions=length(CONN_x.Setup.conditions.names)-1; % filename=fullfile(filepathresults,['resultsROI_Condition',num2str(1,'%03d'),'.mat']); % if isempty(dir(filename)),Ransw=questdlg('First-level ROI analyses have not completed. Perform now?','warning','Yes','No','Yes');if strcmp(Ransw,'Yes'), conn_process('analyses_ROI'); end;end % load(filename,'names','xyz'); if state==1||state==2 CONN_h.menus.m_results.outcomenames=CONN_x.Analyses(ianalysis).sources; CONN_h.menus.m_results.outcomeisource=[];for n1=1:length(CONN_h.menus.m_results.outcomenames), CONN_h.menus.m_results.outcomeisource(n1)=conn_sourcenames(CONN_h.menus.m_results.outcomenames{n1},'-'); end else CONN_h.menus.m_results.outcomenames=CONN_x.vvAnalyses.measures;%CONN_x.vvAnalyses.regressors.names; CONN_h.menus.m_results.outcomeisource=[];for n1=1:length(CONN_h.menus.m_results.outcomenames), [CONN_h.menus.m_results.outcomeisource(n1),nill,CONN_h.menus.m_results.outcomencompsource(n1)]=conn_v2v('match_extended',CONN_h.menus.m_results.outcomenames{n1}); end end CONN_h.menus.m_results_00{16}=conn_menu('edit',[.10,.54-dp1,.175,.04],'Between-subjects contrast',num2str(1),'Enter contrast vector/matrix (as many columns as subject-effects selected)','conn(''gui_results'',16);'); CONN_h.menus.m_results_00{19}=conn_menu('edit',[.275,.54-dp1,.175,.04],'Between-conditions contrast',num2str(1),'Enter contrast vector/matrix (as many columns as conditions selected)','conn(''gui_results'',19);'); if state==1||state==2 CONN_h.menus.m_results_00{17}=conn_menu('edit',[.45,.54-dp1,.175,.04],'Between-sources contrast',num2str(1),'Enter contrast vector/matrix (as many columns as sources selected)','conn(''gui_results'',17);'); else CONN_h.menus.m_results_00{17}=conn_menu('edit',[.45,.54-dp1,.175,.04],'Between-measures contrast',num2str(1),'Enter contrast vector/matrix (as many columns as measures selected)','conn(''gui_results'',17);'); end set(CONN_h.menus.m_results_00{11},'max',2);set(CONN_h.menus.m_results_00{12},'max',2);set(CONN_h.menus.m_results_00{13},'max',2); set(CONN_h.menus.m_results_00{11},'string',{CONN_x.Setup.l2covariates.names{1:end-1}},'value',min(ncovariates,get(CONN_h.menus.m_results_00{11},'value'))); set(CONN_h.menus.m_results_00{12},'string',{CONN_x.Setup.conditions.names{1:end-1}},'value',min(nconditions,get(CONN_h.menus.m_results_00{12},'value'))); if state==1||state==2, temptxt={CONN_h.menus.m_results.outcomenames{:}}; else temptxt=conn_v2v('cleartext',{CONN_h.menus.m_results.outcomenames{:}}); end set(CONN_h.menus.m_results_00{13},'string',temptxt,'value',1); modeltypes={'Random effects','Fixed effects'}; modeltype=1;%+(CONN_x.Setup.nsubjects==1); %CONN_h.menus.m_results_00{21}=conn_menu('popup',[.10,.44-dp1,.125,.04],'Between-subjects model',modeltypes,'Select model type','conn(''gui_results'',21);'); %set(CONN_h.menus.m_results_00{21},'value',modeltype); nconditions=1;nsources=1; if isfield(CONN_x.Results.xX,'nsubjecteffects')&&isfield(CONN_x.Results.xX,'csubjecteffects')&&size(CONN_x.Results.xX.csubjecteffects,2)==numel(CONN_x.Results.xX.nsubjecteffects)&&numel(get(CONN_h.menus.m_results_00{11},'string'))>=max(CONN_x.Results.xX.nsubjecteffects), ncovariates=CONN_x.Results.xX.nsubjecteffects; set(CONN_h.menus.m_results_00{11},'value',min(CONN_x.Results.xX.nsubjecteffects,numel(get(CONN_h.menus.m_results_00{11},'string')))); set(CONN_h.menus.m_results_00{16},'string',mat2str(CONN_x.Results.xX.csubjecteffects)); end if isfield(CONN_x.Results.xX,'nconditions')&&isfield(CONN_x.Results.xX,'cconditions')&&size(CONN_x.Results.xX.cconditions,2)==numel(CONN_x.Results.xX.nconditions)&&numel(get(CONN_h.menus.m_results_00{12},'string'))>=max(CONN_x.Results.xX.nconditions), nconditions=CONN_x.Results.xX.nconditions; set(CONN_h.menus.m_results_00{12},'value',min(CONN_x.Results.xX.nconditions,numel(get(CONN_h.menus.m_results_00{12},'string')))); set(CONN_h.menus.m_results_00{19},'string',mat2str(CONN_x.Results.xX.cconditions)); end % if isfield(CONN_x.Results.xX,'nsubjecteffects'), ncovariates=CONN_x.Results.xX.nsubjecteffects; set(CONN_h.menus.m_results_00{11},'value',min(CONN_x.Results.xX.nsubjecteffects,numel(get(CONN_h.menus.m_results_00{11},'string')))); end % if isfield(CONN_x.Results.xX,'csubjecteffects'), set(CONN_h.menus.m_results_00{16},'string',num2str(CONN_x.Results.xX.csubjecteffects)); end % if isfield(CONN_x.Results.xX,'nconditions'), nconditions=CONN_x.Results.xX.nconditions; set(CONN_h.menus.m_results_00{12},'value',min(CONN_x.Results.xX.nconditions,numel(get(CONN_h.menus.m_results_00{12},'string')))); end % if isfield(CONN_x.Results.xX,'cconditions'), set(CONN_h.menus.m_results_00{19},'string',num2str(CONN_x.Results.xX.cconditions)); end if state==1||state==2 if isfield(CONN_x.Results.xX,'nsources')&&isfield(CONN_x.Results.xX,'csources')&&size(CONN_x.Results.xX.csources,2)==numel(CONN_x.Results.xX.nsources)&&numel(get(CONN_h.menus.m_results_00{13},'string'))>=max(CONN_x.Results.xX.nsources), nsources=CONN_x.Results.xX.nsources; set(CONN_h.menus.m_results_00{13},'value',nsources); set(CONN_h.menus.m_results_00{17},'string',mat2str(CONN_x.Results.xX.csources)); end else if isfield(CONN_x.Results.xX,'nmeasures')&&isfield(CONN_x.Results.xX,'cmeasures')&&size(CONN_x.Results.xX.cmeasures,2)==numel(CONN_x.Results.xX.nmeasures)&&numel(get(CONN_h.menus.m_results_00{13},'string'))>=max(CONN_x.Results.xX.nmeasures), nsources=CONN_x.Results.xX.nmeasures; set(CONN_h.menus.m_results_00{13},'value',nsources); set(CONN_h.menus.m_results_00{17},'string',mat2str(CONN_x.Results.xX.cmeasures)); end end modeltype=1;%if isfield(CONN_x.Results.xX,'modeltype'), modeltype=CONN_x.Results.xX.modeltype; set(CONN_h.menus.m_results_00{21},'value',min(CONN_x.Results.xX.modeltype,numel(get(CONN_h.menus.m_results_00{21},'string')))); end %c=str2num(get(CONN_h.menus.m_results_00{17},'string')); %txt=get(CONN_h.menus.m_results_00{17},'string'); value=str2num(txt); if isempty(value), try value=evalin('base',txt); set(CONN_h.menus.m_results_00{17},'string',mat2str(value)); catch, value=[]; end; end;c=value; CONN_h.menus.m_results.X=zeros(CONN_x.Setup.nsubjects,length(CONN_x.Setup.l2covariates.names)-1); for nsub=1:CONN_x.Setup.nsubjects, for ncovariate=1:length(CONN_x.Setup.l2covariates.names)-1; CONN_h.menus.m_results.X(nsub,ncovariate)=CONN_x.Setup.l2covariates.values{nsub}{ncovariate}; end end if state==1||state==2 txt=strvcat(CONN_x.Analyses(:).name); CONN_h.menus.m_results_00{20}=uicontrol('units','norm','position',[.76,.88,.15,.05],'style','popupmenu','string',txt,'value',ianalysis,'backgroundcolor',get(CONN_h.screen.hfig,'color'),'foregroundcolor',1-get(CONN_h.screen.hfig,'color'),'callback','conn(''gui_results'',20);'); end CONN_h.menus.m_results.y.data=[]; txt=get(CONN_h.menus.m_results_00{16},'string'); value=str2num(txt); if isempty(value), try value=evalin('base',txt); set(CONN_h.menus.m_results_00{16},'string',mat2str(value)); catch, value=[]; end; end; b=value; txt=get(CONN_h.menus.m_results_00{17},'string'); value=str2num(txt); if isempty(value), try value=evalin('base',txt); set(CONN_h.menus.m_results_00{17},'string',mat2str(value)); catch, value=[]; end; end; c=value; txt=get(CONN_h.menus.m_results_00{19},'string'); value=str2num(txt); if isempty(value), try value=evalin('base',txt); set(CONN_h.menus.m_results_00{19},'string',mat2str(value)); catch, value=[]; end; end; d=value; if (state==2||state==3)&&CONN_x.Setup.normalized&&any(CONN_x.Setup.steps([2,3]))&&CONN_x.Results.xX.displayvoxels==1&&size(c,1)==1&&size(d,1)==1,%(~isfield(CONN_x.Setup,'doROIonly')||~CONN_x.Setup.doROIonly), set(CONN_h.screen.hfig,'pointer','watch');drawnow CONN_h.menus.m_results.y.data=0; % CONN_h.menus.m_results.se.data=0; % CONN_h.menus.m_results.se.dof=0; for ncondition=1:length(nconditions), for nsource=1:length(nsources), filename=cell(1,CONN_x.Setup.nsubjects); for nsub=1:CONN_x.Setup.nsubjects if state==1||state==2 filename{nsub}=fullfile(filepathresults,['BETA_Subject',num2str(nsub),'_Condition',num2str(nconditions(ncondition),'%03d'),'_Source',num2str(CONN_h.menus.m_results.outcomeisource(nsources(nsource)),'%03d'),'.nii']); else filename{nsub}=fullfile(filepathresults,['BETA_Subject',num2str(nsub,'%03d'),'_Condition',num2str(nconditions(ncondition),'%03d'),'_Measure',num2str(CONN_h.menus.m_results.outcomeisource(nsources(nsource)),'%03d'),'_Component',num2str(CONN_h.menus.m_results.outcomencompsource(nsources(nsource)),'%03d'),'.nii']); end end CONN_h.menus.m_results.Y=spm_vol(char(filename)); if ~isfield(CONN_h.menus.m_results.y,'slice')||CONN_h.menus.m_results.y.slice<1||CONN_h.menus.m_results.y.slice>CONN_h.menus.m_results.Y(1).dim(3), CONN_h.menus.m_results.y.slice=ceil(CONN_h.menus.m_results.Y(1).dim(3)/2); end set(CONN_h.menus.m_results_00{15},'min',1,'max',CONN_h.menus.m_results.Y(1).dim(3),'sliderstep',min(.5,[1,10]/(CONN_h.menus.m_results.Y(1).dim(3)-1)),'value',CONN_h.menus.m_results.y.slice); % filename=fullfile(filepathresults,['resultsDATA_Condition',num2str(nconditions(ncondition),'%03d'),'_Source',num2str(CONN_h.menus.m_results.outcomeisource(nsources(nsource)),'%03d'),'.mat']); % CONN_h.menus.m_results.Y=conn_vol(filename); if ncondition==1&&nsource==1 [ndgridx,ndgridy]=ndgrid(1:CONN_h.menus.m_results.Y(1).dim(1),1:CONN_h.menus.m_results.Y(1).dim(2)); CONN_h.menus.m_results.y.xyz=[ndgridx(:),ndgridy(:),ones(numel(ndgridx),2)]'; end CONN_h.menus.m_results.y.xyz(3,:)=CONN_h.menus.m_results.y.slice; temp=spm_get_data(CONN_h.menus.m_results.Y,CONN_h.menus.m_results.y.xyz); % [temp,CONN_h.menus.m_results.y.idx]=conn_get_slice(CONN_h.menus.m_results.Y,CONN_h.menus.m_results.y.slice); CONN_h.menus.m_results.y.data=CONN_h.menus.m_results.y.data+temp*c(nsource)*d(ncondition); end; % filename=fullfile(filepathresults,['seDATA_Condition',num2str(nconditions(ncondition),'%03d'),'.mat']); % CONN_h.menus.m_results.SE=conn_vol(filename); % [temp,nill]=conn_get_slice(CONN_h.menus.m_results.SE,CONN_h.menus.m_results.y.slice); % CONN_h.menus.m_results.se.data=CONN_h.menus.m_results.se.data+sum(c.^2)*(d(ncondition)*temp).^2; % CONN_h.menus.m_results.se.dof=CONN_h.menus.m_results.se.dof+CONN_h.menus.m_results.SE.DOF; end % CONN_h.menus.m_results.se.data=sqrt(CONN_h.menus.m_results.se.data); CONN_h.menus.m_results.XS=CONN_refs.canonical.V; xyz=conn_convertcoordinates('idx2tal',prod(CONN_h.menus.m_results.Y(1).dim(1:2))*(CONN_h.menus.m_results.y.slice-1)+(1:prod(CONN_h.menus.m_results.Y(1).dim(1:2))),CONN_h.menus.m_results.Y(1).mat,CONN_h.menus.m_results.Y(1).dim); txyz=pinv(CONN_h.menus.m_results.XS(1).mat)*xyz'; CONN_h.menus.m_results.Xs=spm_sample_vol(CONN_h.menus.m_results.XS(1),txyz(1,:),txyz(2,:),txyz(3,:),1); CONN_h.menus.m_results.Xs=permute(reshape(CONN_h.menus.m_results.Xs,CONN_h.menus.m_results.Y(1).dim(1:2)),[2,1,3]); CONN_h.menus.m_results.Xs=(CONN_h.menus.m_results.Xs/max(CONN_h.menus.m_results.Xs(:))).^3; set(CONN_h.screen.hfig,'pointer','arrow'); strstr3={'Analysis results preview (voxel-level)','Do not show analysis results preview'}; set(CONN_h.menus.m_results_00{32},'string',strstr3,'value',CONN_x.Results.xX.displayvoxels,'enable','on'); elseif state==2||state==3 CONN_h.menus.m_results.y.data=[]; end model=1; modelroi=1; else switch(varargin{2}), case 11, model=2;modelroi=1; ncovariates=get(CONN_h.menus.m_results_00{11},'value'); if length(ncovariates)==1, set(CONN_h.menus.m_results_00{16},'string','1'); else set(CONN_h.menus.m_results_00{16},'string',['eye(',num2str(length(ncovariates)),')']); end case {12,13,15,17,18,19,32} modelroi=1; nconditions=get(CONN_h.menus.m_results_00{12},'value'); nsources=get(CONN_h.menus.m_results_00{13},'value'); if varargin{2}==18, ntarget=get(CONN_h.menus.m_results_00{18},'value'); ntarget=CONN_h.menus.m_results.roiresults.idx(ntarget); if state==2&&CONN_x.Setup.normalized&&any(CONN_x.Setup.steps([2,3])),%(~isfield(CONN_x.Setup,'doROIonly')||~CONN_x.Setup.doROIonly), CONN_h.menus.m_results.y.slice=ceil(conn_convertcoordinates('tal2idx',CONN_h.menus.m_results.roiresults.xyz2{ntarget},CONN_h.menus.m_results.Y.matdim.mat,CONN_h.menus.m_results.Y.matdim.dim)/prod(CONN_h.menus.m_results.Y.matdim.dim(1:2))); if ~isfield(CONN_h.menus.m_results.y,'slice')||CONN_h.menus.m_results.y.slice<1||CONN_h.menus.m_results.y.slice>CONN_h.menus.m_results.Y(1).dim(3), CONN_h.menus.m_results.y.slice=ceil(CONN_h.menus.m_results.Y(1).dim(3)/2); end set(CONN_h.menus.m_results_00{15},'value',CONN_h.menus.m_results.y.slice); end elseif state==2||state==3 CONN_h.menus.m_results.y.slice=round(get(CONN_h.menus.m_results_00{15},'value')); if ~isfield(CONN_h.menus.m_results.y,'slice')||CONN_h.menus.m_results.y.slice<1||(isfield(CONN_h.menus.m_results,'Y')&&CONN_h.menus.m_results.y.slice>CONN_h.menus.m_results.Y(1).dim(3)), CONN_h.menus.m_results.y.slice=ceil(CONN_h.menus.m_results.Y(1).dim(3)/2); end set(CONN_h.menus.m_results_00{15},'value',CONN_h.menus.m_results.y.slice); end if varargin{2}==12,if length(nconditions)==1, set(CONN_h.menus.m_results_00{19},'string','1'); else set(CONN_h.menus.m_results_00{19},'string',['eye(',num2str(length(nconditions)),')']);end; end if varargin{2}==13,if length(nsources)==1, set(CONN_h.menus.m_results_00{17},'string','1'); else set(CONN_h.menus.m_results_00{17},'string',['eye(',num2str(length(nsources)),')']);end; end if state==1||state==2 filepathresults=fullfile(CONN_x.folders.firstlevel,CONN_x.Analyses(ianalysis).name); else filepathresults=CONN_x.folders.firstlevel; end %c=str2num(get(CONN_h.menus.m_results_00{17},'string')); %d=str2num(get(CONN_h.menus.m_results_00{19},'string')); txt=get(CONN_h.menus.m_results_00{16},'string'); value=str2num(txt); if isempty(value), try value=evalin('base',txt); set(CONN_h.menus.m_results_00{16},'string',mat2str(value)); catch, value=[]; end; end; b=value; txt=get(CONN_h.menus.m_results_00{17},'string'); value=str2num(txt); if isempty(value), try value=evalin('base',txt); set(CONN_h.menus.m_results_00{17},'string',mat2str(value)); catch, value=[]; end; end; if state==1||state==2, if isempty(value)||size(value,2)~=numel(nsources), value=CONN_x.Results.xX.csources; set(CONN_h.menus.m_results_00{17},'string',mat2str(value)); end else if isempty(value)||size(value,2)~=numel(nsources), value=CONN_x.Results.xX.cmeasures; set(CONN_h.menus.m_results_00{17},'string',mat2str(value)); end; end c=value; txt=get(CONN_h.menus.m_results_00{19},'string'); value=str2num(txt); if isempty(value), try value=evalin('base',txt); set(CONN_h.menus.m_results_00{19},'string',mat2str(value)); catch, value=[]; end; end; if isempty(value)||size(value,2)~=numel(nconditions), value=CONN_x.Results.xX.cconditions; set(CONN_h.menus.m_results_00{19},'string',mat2str(value)); end d=value; if varargin{2}==32, CONN_x.Results.xX.displayvoxels=get(CONN_h.menus.m_results_00{32},'value'); end if (state==2||state==3)&&CONN_x.Setup.normalized&&any(CONN_x.Setup.steps([2,3]))&&CONN_x.Results.xX.displayvoxels==1&&size(c,1)==1&&size(d,1)==1,%(~isfield(CONN_x.Setup,'doROIonly')||~CONN_x.Setup.doROIonly), set(CONN_h.screen.hfig,'pointer','watch');drawnow CONN_h.menus.m_results.y.xyz(3,:)=CONN_h.menus.m_results.y.slice; CONN_h.menus.m_results.y.data=0; % CONN_h.menus.m_results.se.data=0; % CONN_h.menus.m_results.se.dof=0; for ncondition=1:length(nconditions), for nsource=1:length(nsources), filename=cell(1,CONN_x.Setup.nsubjects); for nsub=1:CONN_x.Setup.nsubjects if state==1||state==2 filename{nsub}=fullfile(filepathresults,['BETA_Subject',num2str(nsub),'_Condition',num2str(nconditions(ncondition),'%03d'),'_Source',num2str(CONN_h.menus.m_results.outcomeisource(nsources(nsource)),'%03d'),'.nii']); else filename{nsub}=fullfile(filepathresults,['BETA_Subject',num2str(nsub,'%03d'),'_Condition',num2str(nconditions(ncondition),'%03d'),'_Measure',num2str(CONN_h.menus.m_results.outcomeisource(nsources(nsource)),'%03d'),'_Component',num2str(CONN_h.menus.m_results.outcomencompsource(nsources(nsource)),'%03d'),'.nii']); end end CONN_h.menus.m_results.Y=spm_vol(char(filename)); if ~isfield(CONN_h.menus.m_results.y,'slice')||CONN_h.menus.m_results.y.slice<1||CONN_h.menus.m_results.y.slice>CONN_h.menus.m_results.Y(1).dim(3), CONN_h.menus.m_results.y.slice=ceil(CONN_h.menus.m_results.Y(1).dim(3)/2); end set(CONN_h.menus.m_results_00{15},'min',1,'max',CONN_h.menus.m_results.Y(1).dim(3),'sliderstep',min(.5,[1,10]/(CONN_h.menus.m_results.Y(1).dim(3)-1)),'value',CONN_h.menus.m_results.y.slice); temp=spm_get_data(CONN_h.menus.m_results.Y,CONN_h.menus.m_results.y.xyz); CONN_h.menus.m_results.y.data=CONN_h.menus.m_results.y.data+temp*c(nsource)*d(ncondition); % filename=fullfile(filepathresults,['resultsDATA_Condition',num2str(nconditions(ncondition),'%03d'),'_Source',num2str(CONN_h.menus.m_results.outcomeisource(nsources(nsource)),'%03d'),'.mat']); % CONN_h.menus.m_results.Y=conn_vol(filename); % [temp,CONN_h.menus.m_results.y.idx]=conn_get_slice(CONN_h.menus.m_results.Y,CONN_h.menus.m_results.y.slice); % CONN_h.menus.m_results.y.data=CONN_h.menus.m_results.y.data+temp*c(nsource)*d(ncondition); end; % filename=fullfile(filepathresults,['seDATA_Condition',num2str(nconditions(ncondition),'%03d'),'.mat']); % CONN_h.menus.m_results.SE=conn_vol(filename); % [temp,nill]=conn_get_slice(CONN_h.menus.m_results.SE,CONN_h.menus.m_results.y.slice); % CONN_h.menus.m_results.se.data=CONN_h.menus.m_results.se.data+sum(c.^2)*(d(ncondition)*temp).^2; % CONN_h.menus.m_results.se.dof=CONN_h.menus.m_results.se.dof+CONN_h.menus.m_results.SE.DOF; end % CONN_h.menus.m_results.se.data=sqrt(CONN_h.menus.m_results.se.data); if varargin{2}==15||varargin{2}==18, xyz=conn_convertcoordinates('idx2tal',prod(CONN_h.menus.m_results.Y(1).dim(1:2))*(CONN_h.menus.m_results.y.slice-1)+(1:prod(CONN_h.menus.m_results.Y(1).dim(1:2))),CONN_h.menus.m_results.Y(1).mat,CONN_h.menus.m_results.Y(1).dim); txyz=pinv(CONN_h.menus.m_results.XS(1).mat)*xyz'; CONN_h.menus.m_results.Xs=spm_sample_vol(CONN_h.menus.m_results.XS(1),txyz(1,:),txyz(2,:),txyz(3,:),1); CONN_h.menus.m_results.Xs=permute(reshape(CONN_h.menus.m_results.Xs,CONN_h.menus.m_results.Y(1).dim(1:2)),[2,1,3]); set(CONN_h.menus.m_results_00{15},'min',1,'max',CONN_h.menus.m_results.Y(1).dim(3),'sliderstep',min(.5,[1,10]/(CONN_h.menus.m_results.Y(1).dim(3)-1)),'value',CONN_h.menus.m_results.y.slice); CONN_h.menus.m_results.Xs=(CONN_h.menus.m_results.Xs/max(CONN_h.menus.m_results.Xs(:))).^3; modelroi=0; end set(CONN_h.screen.hfig,'pointer','arrow'); elseif state==2||state==3 CONN_h.menus.m_results.y.data=[]; end model=1; case 16, ncovariates=get(CONN_h.menus.m_results_00{11},'value'); txt=get(CONN_h.menus.m_results_00{16},'string'); value=str2num(txt); if isempty(value), try value=evalin('base',txt); set(CONN_h.menus.m_results_00{16},'string',mat2str(value)); catch, value=[]; end; end; if isempty(value)||size(value,2)~=numel(ncovariates), value=CONN_x.Results.xX.csubjecteffects; set(CONN_h.menus.m_results_00{16},'string',mat2str(value)); end model=2;modelroi=1; case 20, tianalysis=get(CONN_h.menus.m_results_00{20},'value'); CONN_x.Analysis=tianalysis; conn gui_results; return; case 21, model=1;modelroi=1; case 28 CONN_x.Results.xX.inferencetype=get(CONN_h.menus.m_results_00{28},'value'); modelroi=2; case 29 CONN_x.Results.xX.inferenceleveltype=get(CONN_h.menus.m_results_00{29},'value'); modelroi=2; case 30 txt=get(CONN_h.menus.m_results_00{30},'string'); value=str2num(txt); if isempty(value), try value=evalin('base',txt); set(CONN_h.menus.m_results_00{30},'string',num2str(value)); catch, value=[]; end; end; if ~isempty(value), CONN_x.Results.xX.inferencelevel=value; else set(CONN_h.menus.m_results_00{30},'string',num2str(CONN_x.Results.xX.inferencelevel)); end modelroi=2; case 31, CONN_x.Results.xX.displayrois=get(CONN_h.menus.m_results_00{31},'value'); if ~isfield(CONN_x.Results.xX,'roiselected2'), CONN_x.Results.xX.roiselected2=1:numel(CONN_h.menus.m_results.roiresults.names2); end if CONN_x.Results.xX.displayrois==3 answ=listdlg('Promptstring','Select target ROIs','selectionmode','multiple','liststring',CONN_h.menus.m_results.roiresults.names2,'initialvalue',CONN_x.Results.xX.roiselected2); if ~isempty(answ), CONN_x.Results.xX.roiselected2=answ; end end modelroi=2; end end ncovariates=get(CONN_h.menus.m_results_00{11},'value'); nconditions=get(CONN_h.menus.m_results_00{12},'value'); nsources=get(CONN_h.menus.m_results_00{13},'value'); modeltype=1;%get(CONN_h.menus.m_results_00{21},'value'); %set([CONN_h.menus.m_results_00{24},CONN_h.menus.m_results_00{15},CONN_h.menus.m_results_00{23}],'visible','off'); if (state==2||state==3)&&model==1&&CONN_x.Setup.normalized&&any(CONN_x.Setup.steps([2,3])),%(~isfield(CONN_x.Setup,'doROIonly')||~CONN_x.Setup.doROIonly), xf=CONN_h.menus.m_results.X; yf=CONN_h.menus.m_results.y.data; nsubjects=find(any(xf~=0,2)); xf=xf(nsubjects,:); if ~isempty(yf) yf=yf(nsubjects,:); if modeltype==1, [CONN_h.menus.m_results.B,CONN_h.menus.m_results.opt]=conn_glmunivariate('estimate',xf,yf); else [CONN_h.menus.m_results.B,CONN_h.menus.m_results.opt]=conn_glmunivariate('estimatefixed',xf,yf,CONN_h.menus.m_results.se); end end CONN_h.menus.m_results.ncovariates=1:size(xf,2); CONN_x.Results.xX.X=xf; elseif (state==1)&&model==1, xf=CONN_h.menus.m_results.X; nsubjects=find(any(xf~=0,2)); xf=xf(nsubjects,:); CONN_h.menus.m_results.ncovariates=1:size(xf,2); CONN_x.Results.xX.X=xf; end if model idx=ncovariates; if ~isempty(idx), CONN_x.Results.xX.nsubjecteffects=ncovariates; CONN_x.Results.xX.nconditions=nconditions; txt=get(CONN_h.menus.m_results_00{16},'string'); value=str2num(txt); if isempty(value), try value=evalin('base',txt); set(CONN_h.menus.m_results_00{16},'string',mat2str(value)); catch, value=[]; end; end; CONN_x.Results.xX.csubjecteffects=value; txt=get(CONN_h.menus.m_results_00{17},'string'); value=str2num(txt); if isempty(value), try value=evalin('base',txt); set(CONN_h.menus.m_results_00{17},'string',mat2str(value)); catch, value=[]; end; end; if state==1||state==2 CONN_x.Results.xX.nsources=nsources; CONN_x.Results.xX.csources=value; else CONN_x.Results.xX.nmeasures=nsources; CONN_x.Results.xX.cmeasures=value; end txt=get(CONN_h.menus.m_results_00{19},'string'); value=str2num(txt); if isempty(value), try value=evalin('base',txt); set(CONN_h.menus.m_results_00{19},'string',mat2str(value)); catch, value=[]; end; end; CONN_x.Results.xX.cconditions=value; CONN_x.Results.xX.modeltype=modeltype; if (state==2||state==3)&&CONN_x.Setup.normalized&&any(CONN_x.Setup.steps([2,3])),%(~isfield(CONN_x.Setup,'doROIonly')||~CONN_x.Setup.doROIonly), if length(idx)~=length(CONN_h.menus.m_results.ncovariates) || any(idx~=CONN_h.menus.m_results.ncovariates), xf=CONN_h.menus.m_results.X(:,idx); yf=CONN_h.menus.m_results.y.data; % se=CONN_h.menus.m_results.se; nsubjects=find(any(xf~=0,2)); xf=xf(nsubjects,:); if ~isempty(yf) yf=yf(nsubjects,:); % se.data=se.data(nsubjects,:); % se.dof=se.dof(nsubjects); if modeltype==1, [CONN_h.menus.m_results.B,CONN_h.menus.m_results.opt]=conn_glmunivariate('estimate',xf,yf); else [CONN_h.menus.m_results.B,CONN_h.menus.m_results.opt]=conn_glmunivariate('estimatefixed',xf,yf,se); end %[CONN_h.menus.m_results.B,CONN_h.menus.m_results.opt]=conn_glmunivariate('estimate',xf,yf); %set(CONN_h.menus.m_results_00{22},'string',sprintf('%-32s%10s%10s%12s%12s','Targets','beta',['T(',num2str(CONN_h.menus.m_results.opt.dof(1)),')'],'p-unc','p-FDR')); end CONN_h.menus.m_results.ncovariates=idx; CONN_x.Results.xX.X=xf; end if ~isempty(CONN_h.menus.m_results.y.data)&&size(CONN_x.Results.xX.csubjecteffects,1)==1 if modeltype==1, [h,F,p,dof,R]=conn_glmunivariate('evaluate',CONN_h.menus.m_results.opt,[],CONN_x.Results.xX.csubjecteffects); else [h,F,p,dof,R]=conn_glmunivariate('evaluatefixed',CONN_h.menus.m_results.opt,[],CONN_x.Results.xX.csubjecteffects); end if state==2 % t1=zeros(CONN_h.menus.m_results.Y.matdim.dim(1:2)); % t2=nan+zeros(CONN_h.menus.m_results.Y.matdim.dim(1:2)); switch(CONN_x.Analyses(ianalysis).measure), case {1,2}, % correlation S1=tanh(h); S2=2*min(p,1-p); case {3,4}, % regression S1=h; S2=2*min(p,1-p); end t1=reshape(S1,CONN_h.menus.m_results.Y(1).dim(1:2)); t2=reshape(S2,CONN_h.menus.m_results.Y(1).dim(1:2)); % t1(CONN_h.menus.m_results.y.idx)=S1; % t2(CONN_h.menus.m_results.y.idx)=S2; else t1=reshape(h,CONN_h.menus.m_results.Y(1).dim(1:2)); t2=reshape(2*min(p,1-p),CONN_h.menus.m_results.Y(1).dim(1:2)); end t1=permute(t1,[2,1,3]); t2=permute(t2,[2,1,3]); set(CONN_h.menus.m_results_00{14}.h9,'string',num2str(max(t1(:)))); conn_menu('update',CONN_h.menus.m_results_00{14},{CONN_h.menus.m_results.Xs,t1,-t2},{CONN_h.menus.m_results.Y(1),CONN_h.menus.m_results.y.slice}) % conn_menu('update',CONN_h.menus.m_results_00{14},{CONN_h.menus.m_results.Xs,t1,-t2},{CONN_h.menus.m_results.Y.matdim,CONN_h.menus.m_results.y.slice}) conn_menu('updatecscale',[],[],CONN_h.menus.m_results_00{14}.h9); strstr3={'Analysis results preview (voxel-level)','Do not show analysis results preview'}; set(CONN_h.menus.m_results_00{32},'string',strstr3,'value',CONN_x.Results.xX.displayvoxels,'enable','on'); set([CONN_h.menus.m_results_00{24},CONN_h.menus.m_results_00{15}],'visible','on'); else if CONN_x.Results.xX.displayvoxels==1 set(CONN_h.menus.m_results_00{32},'string',{'preview not available - select results explorer'},'value',1,'enable','off'); end conn_menu('update',CONN_h.menus.m_results_00{14},[]); set([CONN_h.menus.m_results_00{24},CONN_h.menus.m_results_00{15}],'visible','off'); end end end end if modelroi&&state==1, CONN_h.menus.m_results.roiresults=conn_process('results_ROI',CONN_x.Results.xX.nsources,CONN_x.Results.xX.csources); if isequal(CONN_h.menus.m_results.roiresults.statsname,'T') set(CONN_h.menus.m_results_00{28},'visible','on'); switch CONN_x.Results.xX.inferencetype case 1, CONN_h.menus.m_results.roiresults.p=2*min(CONN_h.menus.m_results.roiresults.p,1-CONN_h.menus.m_results.roiresults.p); case 2, case 3, CONN_h.menus.m_results.roiresults.p=1-CONN_h.menus.m_results.roiresults.p; end else set(CONN_h.menus.m_results_00{28},'visible','off'); end switch CONN_x.Results.xX.displayrois case 1, CONN_x.Results.xX.roiselected2=1:numel(CONN_h.menus.m_results.roiresults.names2); case 2, CONN_x.Results.xX.roiselected2=1:numel(CONN_h.menus.m_results.roiresults.names); end if ~isfield(CONN_x.Results.xX,'roiselected2')||isempty(CONN_x.Results.xX.roiselected2)||any(CONN_x.Results.xX.roiselected2>numel(CONN_h.menus.m_results.roiresults.names2)), CONN_x.Results.xX.roiselected2=1:numel(CONN_h.menus.m_results.roiresults.names2); end CONN_h.menus.m_results.roiresults.P=nan(size(CONN_h.menus.m_results.roiresults.p)); CONN_h.menus.m_results.roiresults.P(CONN_x.Results.xX.roiselected2)=conn_fdr(CONN_h.menus.m_results.roiresults.p(CONN_x.Results.xX.roiselected2),2); switch CONN_x.Results.xX.inferenceleveltype case 1, CONN_h.menus.m_results.roiresults.Pthr=CONN_h.menus.m_results.roiresults.P; case 2, CONN_h.menus.m_results.roiresults.Pthr=CONN_h.menus.m_results.roiresults.p; end if size(CONN_h.menus.m_results.roiresults.dof,2)>1 set(CONN_h.menus.m_results_00{22},'string',sprintf('%-32s%10s%10s%12s%12s','Targets','beta',[CONN_h.menus.m_results.roiresults.statsname,'(',num2str(CONN_h.menus.m_results.roiresults.dof(1)),',',num2str(CONN_h.menus.m_results.roiresults.dof(2)),')'],'p-unc','p-FDR')); else set(CONN_h.menus.m_results_00{22},'string',sprintf('%-32s%10s%10s%12s%12s','Targets','beta',[CONN_h.menus.m_results.roiresults.statsname,'(',num2str(CONN_h.menus.m_results.roiresults.dof(1)),')'],'p-unc','p-FDR')); end [nill,CONN_h.menus.m_results.roiresults.idx]=sort(CONN_h.menus.m_results.roiresults.P(CONN_x.Results.xX.roiselected2)-1e-10*abs(CONN_h.menus.m_results.roiresults.F(CONN_x.Results.xX.roiselected2))); CONN_h.menus.m_results.roiresults.idx=CONN_x.Results.xX.roiselected2(CONN_h.menus.m_results.roiresults.idx); txt=[]; for n1=1:numel(CONN_h.menus.m_results.roiresults.idx), n2=CONN_h.menus.m_results.roiresults.idx(n1); tmp=CONN_h.menus.m_results.roiresults.names2{n2};if length(tmp)>32,tmp=[tmp(1:27),'*',tmp(end-3:end)]; end; txt=strvcat(txt,... [[sprintf('%-32s',tmp)],... [sprintf('%10.2f',CONN_h.menus.m_results.roiresults.h(n2))],... [sprintf('%10.2f',CONN_h.menus.m_results.roiresults.F(n2))],... [sprintf('%12f',CONN_h.menus.m_results.roiresults.p(n2))],... [sprintf('%12f',CONN_h.menus.m_results.roiresults.P(n2))]]); end; set(CONN_h.menus.m_results_00{18},'string',txt,'fontname','monospaced','fontsize',8,'value',min(get(CONN_h.menus.m_results_00{18},'value'),size(txt,1))); end if state==1 xtemp=cos((0:64)'/32*pi);ytemp=sin((0:64)'/32*pi); idxplotroi=ishandle(CONN_h.menus.m_results_00{26});delete(CONN_h.menus.m_results_00{26}(idxplotroi)); CONN_h.menus.m_results_00{26}=[]; axes(CONN_h.menus.m_results_00{25}); hold on; ntarget=get(CONN_h.menus.m_results_00{18},'value'); ntarget=CONN_h.menus.m_results.roiresults.idx(ntarget); ntemp=find(CONN_h.menus.m_results.roiresults.Pthr(CONN_x.Results.xX.roiselected2)0); if ~isempty(ntemp2) xyz=pinv(CONN_refs.canonical.V.mat)*[cat(1,CONN_h.menus.m_results.roiresults.xyz2{ntemp(ntemp2)}),ones(numel(ntemp2),1)]'; [nill,idxsort]=sort(xyz(3,:)); CONN_h.menus.m_results_00{26}=cat(2,CONN_h.menus.m_results_00{26},patch(bsxfun(@plus,xyz(1,idxsort),bsxfun(@times,0+3*wtemp(ntemp2(idxsort)),xtemp)),bsxfun(@plus,xyz(2,idxsort),bsxfun(@times,0+3*wtemp(ntemp2(idxsort)),ytemp)),'r','edgecolor','k')); CONN_h.menus.m_results.roiresults.displayrois=cat(1,CONN_h.menus.m_results.roiresults.displayrois,[cat(1,CONN_h.menus.m_results.roiresults.xyz2{ntemp(ntemp2)}),2*3*wtemp(ntemp2)',ones(numel(ntemp2),1)]); CONN_h.menus.m_results.roiresults.displayroisnames=cat(2,CONN_h.menus.m_results.roiresults.displayroisnames,CONN_h.menus.m_results.roiresults.names2(ntemp(ntemp2))); %CONN_h.menus.m_results_00{26}=cat(2,CONN_h.menus.m_results_00{26},patch(bsxfun(@plus,xyz(1,:),bsxfun(@times,0+3*wtemp(ntemp2),xtemp)),bsxfun(@plus,xyz(2,:),bsxfun(@times,0+3*wtemp(ntemp2),ytemp)),bsxfun(@times,ctemp(ntemp2),shiftdim([1,0,0],-1)),'edgecolor',0*[.5,0,0])); end if ~isempty(ntarget) xyz=pinv(CONN_refs.canonical.V.mat)*[cat(1,CONN_h.menus.m_results.roiresults.xyz2{ntarget}),ones(numel(ntarget),1)]'; [nill,idxsort]=sort(xyz(3,:)); CONN_h.menus.m_results_00{26}=cat(2,CONN_h.menus.m_results_00{26},patch(bsxfun(@plus,xyz(1,idxsort),3.5*xtemp),bsxfun(@plus,xyz(2,idxsort),3.5*ytemp),'k','facecolor','none','edgecolor','w','linestyle',':')); end if ~isempty(nsources) xyz=pinv(CONN_refs.canonical.V.mat)*[cat(1,CONN_h.menus.m_results.roiresults.xyz{nsources}),ones(numel(nsources),1)]'; [nill,idxsort]=sort(xyz(3,:)); CONN_h.menus.m_results_00{26}=cat(2,CONN_h.menus.m_results_00{26},patch(bsxfun(@plus,xyz(1,idxsort),4*xtemp),bsxfun(@plus,xyz(2,idxsort),4*ytemp),'w','facecolor','k','edgecolor',.25*[1,1,1])); CONN_h.menus.m_results.roiresults.displayrois=cat(1,CONN_h.menus.m_results.roiresults.displayrois,[cat(1,CONN_h.menus.m_results.roiresults.xyz2{nsources}),2*4*ones(numel(nsources),1),0*ones(numel(nsources),1)]); CONN_h.menus.m_results.roiresults.displayroisnames=cat(2,CONN_h.menus.m_results.roiresults.displayroisnames,CONN_h.menus.m_results.roiresults.names2(nsources)); end hold off; end case 'gui_results_roiview', conn_displayroi('init',CONN_x.Results.xX.nsources); return; case 'gui_results_roi3d' c={[0,0,1],[.25,.25,.25],[1,0,0]}; conn_mesh_display('',[],struct('sph_names',{CONN_h.menus.m_results.roiresults.displayroisnames},'sph_xyz',CONN_h.menus.m_results.roiresults.displayrois(:,1:3),'sph_r',CONN_h.menus.m_results.roiresults.displayrois(:,4),'sph_c',{c(2+sign(CONN_h.menus.m_results.roiresults.displayrois(:,5)))}), [], .25, [0,-.01,1]); return case 'gui_results_wholebrain', if ~CONN_x.Setup.normalized, warndlg('Second-level voxel-level analyses not available for un-normalized data'); return; end if CONN_x.Results.xX.modeltype==2, warndlg('Second-level fixed-effects voxel-level analyses not implemented'); return; end CONN_x.Results.foldername=''; conn_process('results_voxel','readsingle','seed-to-voxel'); set(CONN_h.screen.hfig,'pointer','arrow') return; case 'gui_results_graphtheory', conn_displaynetwork('init',CONN_x.Results.xX.nsources); return; case 'gui_results_done', if isempty(CONN_x.filename), conn gui_setup_save; end %conn_menumanager clf; %axes('units','norm','position',[0,.935,1,.005]); image(shiftdim(1-get(CONN_h.screen.hfig,'color'),-1)); axis off; %conn_menumanager([CONN_h.menus.m0],'on',1); %conn gui_setup_save; CONN_x.gui=0; CONN_x.Results.foldername=''; if CONN_x.Setup.steps(1)&&~CONN_x.Setup.steps(2) || ~CONN_x.Setup.normalized, conn_process('results_roi'); else conn_process('results'); end CONN_x.gui=1; conn gui_setup_save; set(CONN_h.screen.hfig,'pointer','arrow') return; case 'gui_results_wholebrain_vv', CONN_x.Results.foldername=''; conn_process('results_voxel','readsingle','voxel-to-voxel'); set(CONN_h.screen.hfig,'pointer','arrow') return; case 'gui_results_done_vv', if isempty(CONN_x.filename), conn gui_setup_save; end %conn_menumanager clf; %axes('units','norm','position',[0,.935,1,.005]); image(shiftdim(1-get(CONN_h.screen.hfig,'color'),-1)); axis off; %conn_menumanager([CONN_h.menus.m0],'on',1); %conn gui_setup_save; CONN_x.gui=0; CONN_x.Results.foldername=''; conn_process('results_voxel','doall','voxel-to-voxel'); CONN_x.gui=1; conn gui_setup_save; set(CONN_h.screen.hfig,'pointer','arrow') return; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% end end drawnow; function [h,h2]=conn_menu(type,position,title,string,tooltipstring,callback) nmax=500; if nargin<2 || isempty(position), position=[0,0,0,0]; end if nargin<3, title='';end if nargin<4, string='';end if nargin<5, tooltipstring='';end if nargin<6, callback='';end if ~ischar(type), [type,position,title]=deal(title,get(type,'userdata'),get(type,'value')); end switch(lower(type)), case 'edit', if ~isempty(title), h2=uicontrol('style','text','units','norm','position',position+[0,.04,0,0],'string',title,'foregroundcolor',1-get(gcf,'color'),'backgroundcolor',get(gcf,'color')/2,'fontweight','bold','fontname','default','fontsize',8,'fontunits','norm','horizontalalignment','left'); end h=uicontrol('style','edit','units','norm','position',position,'foregroundcolor','w','backgroundcolor','k','string',string,'tooltipstring',tooltipstring,'callback',callback,'fontweight','bold','fontsize',8); case 'listbox', if ~isempty(title), h2=uicontrol('style','text','units','norm','position',(position+[0,position(4),0,0]).*[1,1,1,0]+[0,0,0,.04],'string',title,'foregroundcolor',1-get(gcf,'color'),'backgroundcolor',get(gcf,'color')/2,'fontweight','bold','fontname','default','fontsize',8,'fontunits','norm','horizontalalignment','center'); end h=uicontrol('style','listbox','units','norm','position',position,'foregroundcolor','w','backgroundcolor','k','string',string,'max',1,'value',1,'tooltipstring',tooltipstring,'callback',callback,'fontsize',8); case 'listbox2', if ~isempty(title), h2=uicontrol('style','text','units','norm','position',(position+[0,position(4),0,0]).*[1,1,1,0]+[0,0,0,.04],'string',title,'foregroundcolor',1-get(gcf,'color'),'backgroundcolor',get(gcf,'color')/2,'fontname','monospaced','fontsize',8,'horizontalalignment','left'); end h=uicontrol('style','listbox','units','norm','position',position,'foregroundcolor','w','backgroundcolor','k','string',string,'max',1,'value',1,'tooltipstring',tooltipstring,'callback',callback,'fontsize',8); case 'text', if ~isempty(title), h2=uicontrol('style','text','units','norm','position',(position+[0,position(4),0,0]).*[1,1,1,0]+[0,0,0,.04],'string',title,'foregroundcolor',1-get(gcf,'color'),'backgroundcolor',get(gcf,'color')/2,'fontweight','bold','fontname','default','fontsize',8,'fontunits','norm','horizontalalignment','center'); end h=uicontrol('style','text','units','norm','position',position,'foregroundcolor','w','backgroundcolor',get(gcf,'color')/2,'string',string,'tooltipstring',tooltipstring,'max',2,'horizontalalignment','center','fontsize',8); case 'popup', if ~isempty(title), h2=uicontrol('style','text','units','norm','position',(position+[0,position(4),0,0]).*[1,1,1,0]+[0,0,0,.04],'string',title,'foregroundcolor',1-get(gcf,'color'),'backgroundcolor',get(gcf,'color')/2,'fontweight','bold','fontname','default','fontsize',8,'fontunits','norm','horizontalalignment','left'); end h=uicontrol('style','popupmenu','units','norm','position',position,'foregroundcolor','w','backgroundcolor','k','string',string,'value',1,'tooltipstring',tooltipstring,'callback',callback,'fontsize',8); case 'checkbox', if ~isempty(title), h2=uicontrol('style','text','units','norm','position',(position+[position(3),0,0,0]).*[1,1,0,1]+[0,0,.15,0],'string',title,'foregroundcolor',1-get(gcf,'color'),'backgroundcolor',get(gcf,'color')/2,'fontweight','bold','fontname','default','fontsize',8,'fontunits','norm','horizontalalignment','left'); end if ischar(string),string={string}; end for n1=1:numel(string), h(n1)=uicontrol('style','checkbox','units','norm','position',position-[0,position(4)*(n1-1),0,0],'foregroundcolor','w','backgroundcolor',get(gcf,'color')/2,'string',string{n1},'value',1,'tooltipstring',tooltipstring,'callback',callback,'fontsize',8); end case 'checkbox2', if ~isempty(title), h2=uicontrol('style','text','units','norm','position',(position+[0,position(4),0,0]).*[1,1,1,0]+[0,0,0,.04],'string',title,'foregroundcolor',1-get(gcf,'color'),'backgroundcolor',get(gcf,'color')/2,'fontweight','bold','fontname','default','fontsize',8,'fontunits','norm','horizontalalignment','left'); end if ischar(string),string={string}; end for n1=1:numel(string), h(n1)=uicontrol('style','checkbox','units','norm','position',position-[0,position(4)*(n1-1),0,0],'foregroundcolor','w','backgroundcolor',get(gcf,'color')/2,'string',string{n1},'value',1,'tooltipstring',tooltipstring,'callback',callback,'fontsize',8); end case 'axes', if ~isempty(title), h2=uicontrol('style','text','units','norm','position',(position+[0,position(4),0,0]).*[1,1,1,0]+[0,0,0,.04],'string',title,'foregroundcolor',1-get(gcf,'color'),'backgroundcolor',get(gcf,'color')/2,'fontweight','bold','fontname','default','fontsize',8,'fontunits','norm','horizontalalignment','center'); end h=axes('units','norm','position',position,'visible','off'); case 'image', if ~isempty(title), h2=uicontrol('style','text','units','norm','position',(position+[0,position(4),0,0]).*[1,1,1,0]+[0,0,0,.04],'string',title,'foregroundcolor',1-get(gcf,'color'),'backgroundcolor',get(gcf,'color')/2,'fontweight','bold','fontname','default','fontsize',8,'fontunits','norm','horizontalalignment','center'); end data=struct('n',[],'thr',.5,'cscale',1,'x0',[],'x1',[],'p',0); h.h1=axes('units','norm','position',position); h.h2=image(shiftdim(get(gcf,'color')/2,-1)); h.h3=axes('units','norm','position',position+[.1*position(3),0,-.1*position(3),0]); h.h4=plot(0,zeros(1,nmax))'; h.h5=uicontrol('style','slider','units','norm','position',[position(1)+position(3)-0*.015,position(2),.015,position(4)],'callback',{@conn_menu,'updateslider1'},'backgroundcolor',get(gcf,'color')/2); h.h6=uicontrol('style','slider','units','norm','position',[position(1),position(2)-.03,position(3),.03],'min',0,'max',1,'callback',{@conn_menu,'updateslider2'},'backgroundcolor',get(gcf,'color')/2,'value',data.thr); %h.h7=axes('position',[position(1)+0*.015,position(2)-.06,position(3)-0*.03,.02],'color',get(gcf,'color')/2); h.h7=axes('position',[position(1)-.01,position(2),.01,position(4)],'color',get(gcf,'color')/2); h.h8=image((1:128)'); h.h9=uicontrol('style','edit','units','norm','position',[position(1)-.015,position(2)+position(4),.02,.04],'callback',{@conn_menu,'updatecscale'},'backgroundcolor',get(gcf,'color')/2,'string',num2str(data.cscale)); h.h10=uicontrol('style','edit','units','norm','position',[position(1)+position(3)-.1,position(2)-2*.04,.1,.04],'callback',{@conn_menu,'updatethr'},'backgroundcolor',get(gcf,'color')/2,'foregroundcolor',1-get(gcf,'color'),'string',num2str(data.thr)); set(h.h1,'color',get(gcf,'color')/2,'xtick',[],'ytick',[],'xcolor',get(gcf,'color')/2,'ycolor',get(gcf,'color')/2); set(h.h3,'color',get(gcf,'color')/2,'xtick',[],'xcolor',1-get(gcf,'color'),'ycolor',1-get(gcf,'color'),'visible','off'); set(h.h7,'color',get(gcf,'color')/2,'xtick',[],'ytick',[64.5],'yticklabel',{'0'},'xcolor',1-get(gcf,'color'),'ycolor',1-get(gcf,'color'),'visible','off','ydir','normal'); set(h.h9,'backgroundcolor',get(gcf,'color')/2,'foregroundcolor',1-get(gcf,'color'),'visible','off'); set([h.h4,h.h5,h.h6,h.h7,h.h8,h.h9,h.h10],'visible','off'); set([h.h5,h.h6,h.h9,h.h10],'userdata',h); set([h.h2],'userdata',data); case 'image2', if ~isempty(title), h2=uicontrol('style','text','units','norm','position',(position+[0,position(4),0,0]).*[1,1,1,0]+[0,0,0,.04],'string',title,'foregroundcolor',1-get(gcf,'color'),'backgroundcolor',get(gcf,'color')/2,'fontweight','bold','fontname','default','fontsize',8,'fontunits','norm','horizontalalignment','center'); end data=struct('n',[],'thr',.001,'cscale',1,'x0',[],'x1',[],'p',0); h.h1=axes('units','norm','position',position); h.h2=image(shiftdim(get(gcf,'color')/2,-1)); h.h3=axes('units','norm','position',position+[.1*position(3),0,-.1*position(3),0]); h.h4=plot(0,zeros(1,nmax))'; h.h5=uicontrol('style','slider','units','norm','position',[position(1)+position(3)-0*.015,position(2),.015,position(4)],'callback',{@conn_menu,'updateslider1'},'backgroundcolor',get(gcf,'color')/2); h.h6=uicontrol('style','slider','units','norm','position',[position(1),position(2)-.03,position(3),.03],'min',0,'max',1,'callback',{@conn_menu,'updateslider2'},'backgroundcolor',get(gcf,'color')/2,'value',data.thr); %h.h7=axes('position',[position(1)+0*.015,position(2)-.06,position(3)-0*.03,.02],'color',get(gcf,'color')/2); h.h7=axes('position',[position(1)-.01,position(2),.01,position(4)],'color',get(gcf,'color')/2); h.h8=image((1:128)'); h.h9=uicontrol('style','edit','units','norm','position',[position(1)-.015,position(2)+position(4),.02,.04],'callback',{@conn_menu,'updatecscale'},'backgroundcolor',get(gcf,'color')/2,'string',num2str(data.cscale)); h.h10=uicontrol('style','edit','units','norm','position',[position(1)+position(3)-.1,position(2)-2*.04,.1,.04],'callback',{@conn_menu,'updatethr'},'backgroundcolor',get(gcf,'color')/2,'foregroundcolor',1-get(gcf,'color'),'string',num2str(data.thr)); set(h.h1,'color',get(gcf,'color')/2,'xtick',[],'ytick',[],'xcolor',get(gcf,'color')/2,'ycolor',get(gcf,'color')/2); set(h.h3,'color',get(gcf,'color')/2,'xtick',[],'xcolor',1-get(gcf,'color'),'ycolor',1-get(gcf,'color'),'visible','off'); set(h.h7,'color',get(gcf,'color')/2,'xtick',[],'ytick',[64.5],'yticklabel',{'0'},'xcolor',1-get(gcf,'color'),'ycolor',1-get(gcf,'color'),'visible','off','ydir','normal'); set(h.h9,'backgroundcolor',get(gcf,'color')/2,'foregroundcolor',1-get(gcf,'color'),'visible','off'); set([h.h4,h.h5,h.h6,h.h7,h.h8,h.h9,h.h10],'visible','off'); set([h.h5,h.h6,h.h9,h.h10],'userdata',h); set([h.h2],'userdata',data); case 'hist', if ~isempty(title), h2=uicontrol('style','text','units','norm','position',(position+[0,position(4),0,0]).*[1,1,1,0]+[0,0,0,.04],'string',title,'foregroundcolor',1-get(gcf,'color'),'backgroundcolor',get(gcf,'color')/2,'fontweight','bold','fontname','default','fontsize',8,'fontunits','norm','horizontalalignment','center'); end h.h1=axes('units','norm','position',position,'fontsize',8); h.h3=patch(0,0,'k'); h.h4=patch(0,0,'k'); h.h5=patch(0,0,'k'); h.h6=text(0,0,'original'); h.h7=text(0,0,'without confounds'); hold on; h.h2=plot([0,0],[0,0],'k-'); hold off; set(h.h1,'color',get(gcf,'color')/2,'ytick',[],'xcolor',1-get(gcf,'color'),'ycolor',get(gcf,'color')/2,'visible','off'); set([h.h1,h.h2,h.h3,h.h4,h.h5,h.h6,h.h7],'visible','off'); case 'updatehist', if isempty(title), set([position.h1,position.h2,position.h3,position.h4,position.h5,position.h6,position.h7],'visible','off'); else set(position.h3,'xdata',title{1},'ydata',title{2},'facecolor',.25*[1,1,0],'facealpha',1,'edgecolor','k'); set(position.h4,'xdata',title{1},'ydata',title{3},'facecolor',.75*[1,1,1],'facealpha',1,'edgecolor','none'); set(position.h5,'xdata',title{1},'ydata',min(title{2},title{3}),'facecolor',[.2,.2,.4],'facealpha',1,'edgecolor','none'); set(position.h2,'xdata',[0,0],'ydata',[0,max(max(title{2}),max(title{3}))*1.1],'color','w'); axis(position.h1,'tight'); [nill,idxtemp]=max(title{3});set(position.h6,'position',[title{1}(idxtemp),title{3}(idxtemp),0],'color',.75*[1,1,1],'horizontalalignment','left'); [nill,idxtemp]=max(title{2});set(position.h7,'position',[title{1}(idxtemp),title{2}(idxtemp),0],'color',.25*[1,1,0],'horizontalalignment','right'); set([position.h1,position.h2,position.h3,position.h4,position.h5,position.h6,position.h7],'visible','on'); end case {'update','updateplot','updateimage'}, if isempty(title), set(position.h2,'cdata',shiftdim(get(gcf,'color')/2,-1)); set(position.h1,'xlim',[.5,1.5],'ylim',[.5,1.5],'xtick',[],'ytick',[]); axis(position.h1,'equal','tight'); set([position.h1,position.h2],'visible','on'); set([position.h3,position.h4,position.h5,position.h6,position.h7,position.h9,position.h10],'visible','off'); else if strcmp(lower(type),'updateimage')||isstruct(title)||iscell(title)||size(title,2)>nmax||size(title,3)>1, data=get(position.h2,'userdata'); if iscell(title), title0=title{2}; titleTHR=title{end}; title=title{1}; if any(titleTHR(:)<0), data.p=1; titleTHR=-titleTHR; else data.p=0; end else title0=[]; data.p=0; end; % title: structural; title0: activation; titleTHR: p-value (nan for missing data) if isstruct(title), if length(title)>1, title=cat(2,permute(conn_spm_read_vols(title(end)),[2,1,3]),permute(conn_spm_read_vols(title(1)),[2,1,3])); else title=permute(conn_spm_read_vols(title),[2,1,3]); end %title=permute(spm_read_vols(title),[2,1,3,4]); end if size(title,4)>1, title=cat(2,title(:,:,:,end),title(:,:,:,1)); end if isempty(data.n), data.n=ceil(size(title,3)/2); end data.n=max(1,min(size(title,3),data.n)); data.x1=round(1+127*(title-min(title(:)))/max(max(title(:))-min(title(:)),eps)); %data.x1=round(1+127*max(0,min(1,title))); if ~isempty(title0), data.x0=title0; %max(-1,min(1,title0)); % x1: structural; x0: activation; xTHR: p-value data.xTHR=titleTHR;%max(0,min(1,titleTHR)); t0=(129:256)'; idxt0=find(~isnan(titleTHR)); if isempty(idxt0), idxt0=[1,1]; %ceil(128*max(eps,max(title0(:))))]; else idxt0=ceil(128*max(eps,min(1,.5+.5*max(-1,min(1, [min(title0(idxt0)),max(title0(:))]/data.cscale ))))); end t0(1:min(idxt0)-1)=1;t0(max(idxt0)+1:end)=1;%t0(idxt0)=128;%t0(max(1,idxt0-1))=1;t0(min(128,idxt0+1))=1; set(position.h8,'cdata',t0); set([position.h6,position.h7,position.h8,position.h9,position.h10],'visible','on'); else data.x0=[]; set([position.h6,position.h7,position.h8,position.h9,position.h10],'visible','off'); end if size(data.x1,3)>1, set(position.h5,'min',1,'max',size(data.x1,3),'sliderstep',min(.5,[1,10]/(size(data.x1,3)-1)),'value',data.n,'visible','on'); else set(position.h5,'visible','off'); end title=fliplr(flipud(data.x1(:,:,data.n))); if ~isempty(data.x0), title0=fliplr(flipud(data.x0(:,:,data.n))); %if all(size(title)==2*size(title0)-1), title0=interp2(title0,'nearest'); end titleTHR=fliplr(flipud(data.xTHR(:,:,data.n))); %if all(size(title)==2*size(titleTHR)-1), titleTHR=interp2(titleTHR,'nearest'); end if data.p, idx=find(titleTHR<=data.thr); else idx=find(titleTHR>=data.thr); end title(idx)=round(192.5+63.5*max(-1,min(1, title0(idx)/data.cscale ))); end set(position.h2,'cdata',title);set(position.h1,'xlim',[.5,size(title,2)+.5],'ylim',[.5,size(title,1)+.5+eps],'xtick',[],'ytick',[]); axis(position.h1,'equal','tight'); set([position.h1,position.h2],'visible','on'); set([position.h3,position.h4],'visible','off'); if ~isempty(string), data.buttondown=struct('matdim',string{1},'z',string{2},'h1',position.h1); set(position.h2,'buttondownfcn',@conn_menubuttondownfcn,'userdata',data); else set(position.h2,'userdata',data); end else if isstruct(title), title=permute(conn_spm_read_vols(title),[2,1,3,4]); end for n1=1:size(title,2),set(position.h4(n1),'xdata',(1:size(title,1))','ydata',title(:,n1));end for n1=size(title,2)+1:nmax,set(position.h4(n1),'xdata',(1:size(title,1))','ydata',zeros(size(title,1),1));end minmaxt=[min(title(:)),max(title(:))]; set(position.h3,'xlim',[0,size(title,1)+1],'ylim',minmaxt*[1.1,-.1;-.1,1.1]+[-1e-10,1e-10]); set([position.h3,position.h4],'visible','on'); set([position.h1,position.h2,position.h5,position.h6,position.h7,position.h9,position.h10],'visible','off'); end end case 'updateslider1', data=get(position.h2,'userdata'); data.n=max(1,min(size(data.x1,3), round(title))); title=fliplr(flipud(data.x1(:,:,data.n))); if ~isempty(data.x0), title0=fliplr(flipud(data.x0(:,:,data.n))); %if all(size(title)==2*size(title0)-1), title0=interp2(title0,'nearest'); end titleTHR=fliplr(flipud(data.xTHR(:,:,data.n))); %if all(size(title)==2*size(titleTHR)-1), titleTHR=interp2(titleTHR,'nearest'); end if data.p, idx=find(titleTHR<=data.thr); else idx=find(titleTHR>=data.thr); end title(idx)=round(192.5+63.5*max(-1,min(1, title0(idx)/data.cscale ))); end set(position.h2,'cdata',title);set(position.h1,'xlim',[.5,size(title,2)+.5],'ylim',[.5,size(title,1)+.5+eps],'xtick',[],'ytick',[]); axis(position.h1,'equal','tight'); set([position.h1,position.h2],'visible','on'); set([position.h3,position.h4],'visible','off'); set(position.h2,'userdata',data); case 'updateslider2', data=get(position.h2,'userdata'); data.thr=max(0,min(1, title)); title=fliplr(flipud(data.x1(:,:,data.n))); if ~isempty(data.x0), title0=fliplr(flipud(data.x0(:,:,data.n))); %if all(size(title)==2*size(title0)-1), title0=interp2(title0,'nearest'); end titleTHR=fliplr(flipud(data.xTHR(:,:,data.n))); %if all(size(title)==2*size(titleTHR)-1), titleTHR=interp2(titleTHR,'nearest'); end if data.p, idx=find(titleTHR<=data.thr); else idx=find(titleTHR>=data.thr); end title(idx)=round(192.5+63.5*max(-1,min(1, title0(idx)/data.cscale ))); end set(position.h10,'string',num2str(data.thr)); set(position.h2,'cdata',title);set(position.h1,'xlim',[.5,size(title,2)+.5],'ylim',[.5,size(title,1)+.5+eps],'xtick',[],'ytick',[]); axis(position.h1,'equal','tight'); set([position.h1,position.h2],'visible','on'); set([position.h3,position.h4],'visible','off'); set(position.h2,'userdata',data); case 'updatethr', if nargin<=3, tgcbo=gcbo; else tgcbo=string; end position=get(tgcbo,'userdata'); title=str2num(get(tgcbo,'string')); data=get(position.h2,'userdata'); data.thr=max(0,min(inf,title)); set(position.h6,'value',data.thr); title=fliplr(flipud(data.x1(:,:,data.n))); if ~isempty(data.x0), title0=fliplr(flipud(data.x0(:,:,data.n))); %if all(size(title)==2*size(title0)-1), title0=interp2(title0,'nearest'); end titleTHR=fliplr(flipud(data.xTHR(:,:,data.n))); %if all(size(title)==2*size(titleTHR)-1), titleTHR=interp2(titleTHR,'nearest'); end if data.p, idx=find(titleTHR<=data.thr); else idx=find(titleTHR>=data.thr); end title(idx)=round(192.5+63.5*max(-1,min(1, title0(idx)/data.cscale ))); end set(position.h2,'cdata',title);set(position.h1,'xlim',[.5,size(title,2)+.5],'ylim',[.5,size(title,1)+.5+eps],'xtick',[],'ytick',[]); axis(position.h1,'equal','tight'); set([position.h1,position.h2],'visible','on'); set([position.h3,position.h4],'visible','off'); set(position.h2,'userdata',data); case 'updatecscale', if nargin<=3, tgcbo=gcbo; else tgcbo=string; end position=get(tgcbo,'userdata'); title=str2num(get(tgcbo,'string')); data=get(position.h2,'userdata'); data.cscale=max(eps,title); title=fliplr(flipud(data.x1(:,:,data.n))); if ~isempty(data.x0), title0=fliplr(flipud(data.x0(:,:,data.n))); %if all(size(title)==2*size(title0)-1), title0=interp2(title0,'nearest'); end titleTHR=fliplr(flipud(data.xTHR(:,:,data.n))); %if all(size(title)==2*size(titleTHR)-1), titleTHR=interp2(titleTHR,'nearest'); end t0=(129:256)'; idxt0=find(~isnan(titleTHR)); if isempty(idxt0), idxt0=[1,1]; %ceil(128*max(eps,max(title0(:))))]; else idxt0=ceil(128*max(eps,min(1,.5+.5*max(-1,min(1, [min(title0(idxt0)),max(title0(:))]/data.cscale ))))); end t0(1:min(idxt0)-1)=1;t0(max(idxt0)+1:end)=1;%t0(idxt0)=128;%t0(max(1,idxt0-1))=1;t0(min(128,idxt0+1))=1; set(position.h8,'cdata',t0); if data.p, idx=find(titleTHR<=data.thr); else idx=find(titleTHR>=data.thr); end title(idx)=round(192.5+63.5*max(-1,min(1, title0(idx)/data.cscale ))); end set(position.h2,'cdata',title);set(position.h1,'xlim',[.5,size(title,2)+.5],'ylim',[.5,size(title,1)+.5+eps],'xtick',[],'ytick',[]); axis(position.h1,'equal','tight'); set([position.h1,position.h2],'visible','on'); set([position.h3,position.h4],'visible','off'); set(position.h2,'userdata',data); case 'filesearch', h=conn_filesearchtool('position',[.65,.06,.25,.84],'backgroundcolor',get(gcf,'color')/2,'foregroundcolor',1-get(gcf,'color'),... 'title',title,'filter',string,'callback',callback,'max',1); set([h.folder,h.filter,h.find,h.files],'backgroundcolor','k','foregroundcolor','w'); case 'frame', if ~isempty(title), uicontrol('style','text','units','norm','position',(position+[0,position(4),0,0]).*[1,1,1,0]+[0,0,0,.04],'string',title,'foregroundcolor',1-get(gcf,'color'),'backgroundcolor',get(gcf,'color'),'fontweight','bold','fontname','default','fontsize',8,'fontunits','norm','horizontalalignment','center'); end h=axes('units','norm','position',position,'color',get(gcf,'color')/2,'xtick',[],'ytick',[],'xcolor',1-get(gcf,'color'),'ycolor',1-get(gcf,'color'),'box','on'); %h=axes('units','norm','position',[position(1),position(2)+.99*position(4),position(3),.01*position(4)],'color',get(gcf,'color')/2,'xtick',[],'ytick',[],'xcolor',1-get(gcf,'color'),'ycolor',1-get(gcf,'color'),'box','on'); end function x=conn_spm_read_vols(v) global CONN_refs; x=spm_get_data(v,pinv(v(1).mat)*CONN_refs.canonical.xyz); x=permute(reshape(x,[numel(v),CONN_refs.canonical.V.dim]),[2,3,4,1]); function conn_menubuttondownfcn(varargin) global CONN_refs data=get(gcbo,'userdata');data=data.buttondown; xyz=get(data.h1,'currentpoint'); xyz=round(data.matdim.mat(1:3,:)*[data.matdim.dim(1)+1-xyz(1),data.matdim.dim(2)+1-xyz(1,2),data.z,1]'); v=spm_get_data(CONN_refs.rois.V,pinv(CONN_refs.rois.V.mat)*[xyz;1]); if v>0, txt=[CONN_refs.rois.filename,'.',CONN_refs.rois.labels{v}]; else txt=''; end h=findobj('tag','conn_menubuttondownfcn');if isempty(h), h=figure('units','pixels','position',[get(0,'pointerlocation')-[400,30],250,40]);else figure(h); end; set(h,'units','pixels','position',[get(0,'pointerlocation')-[150,30],0,0]+get(h,'position')*[0,0,0,0;0,0,0,0;-1,0,1,0;0,0,0,1],'menubar','none','numbertitle','off','color','k','tag','conn_menubuttondownfcn'); clf(h);text(0,1,['x,y,z = (',num2str(xyz(1)),',',num2str(xyz(2)),',',num2str(xyz(3)),') mm'],'color','y','fontweight','bold','horizontalalignment','center','fontsize',8);text(0,0,txt,'color','y','fontweight','bold','horizontalalignment','center','fontsize',8,'interpreter','none');set(gca,'units','norm','position',[0,0,1,1],'xlim',[-1,1],'ylim',[-.5,1.5],'visible','off'); %hc=get(0,'children');if length(hc)>0&&hc(1)~=h,hc=[h;hc(hc~=h)];set(0,'children',h); end