attachment:cls_getRes.m of BatchRenderRfx - MRC CBU Imaging Wiki
location: attachment:cls_getRes.m of BatchRenderRfx

Attachment 'cls_getRes.m'

Download

   1 function varargout = csl_getRes(sCon)
   2 	
   3 
   4 % xSPM      - structure containing SPM, distribution & filtering details
   5 % .swd      - SPM working directory - directory containing current SPM.mat
   6 % .title    - title for comparison (string)
   7 % .Z        - minimum of n Statistics {filtered on u and k}
   8 % .n        - number of conjoint tests        
   9 % .STAT     - distribution {Z, T, X, F or P}     
  10 % .df       - degrees of freedom [df{interest}, df{residual}]
  11 % .STATstr  - description string     
  12 % .Ic       - indices of contrasts (in SPM.xCon)
  13 % .Im       - indices of masking contrasts (in xCon)
  14 % .pm       - p-value for masking (uncorrected)
  15 % .Ex       - flag for exclusive or inclusive masking
  16 % .u        - height threshold
  17 % .k        - extent threshold {voxels}
  18 % .XYZ      - location of voxels {voxel coords}
  19 % .XYZmm    - location of voxels {mm}
  20 % .S        - search Volume {voxels}
  21 % .R        - search Volume {resels}
  22 % .FWHM     - smoothness {voxels}     
  23 % .M        - voxels -> mm matrix
  24 % .iM       - mm -> voxels matrix
  25 % .VOX      - voxel dimensions {mm} - column vector
  26 % .DIM      - image dimensions {voxels} - column vector
  27 % .Vspm     - Mapped statistic image(s)
  28 % .Ps       - list of P values for voxels at SPM.xVol.XYZ (used by FDR)
  29 %- sCon = struct( ...
  30 %-     'spmmat', '', ...    % full path to SPM.mat file
  31 %-     'Ic', [], ...        % no of contrast (or contrasts for conjunction)
  32 %-     'mask', 0,...        % whether to mask with another contrast
  33 %-     'masking_Ic', [],... % no of contrast to mask with
  34 %-     'mask_ucp', [],...   % masking contrast uncorrected p
  35 %-     'exclusive', [],...  % whether masking is inclusive or exclusive
  36 %-     'title', '',...      % if empty results in default contrast title
  37 %-     'thresh', 0.01,...  % threshold (corrected or uncorrected, as above)
  38 %-     'Mcp', 'none',...  % Mutiple comp : FWE|FDR|none
  39 %-     'extent_thresh', 0); % extent threshold
  40 %- 
  41 %- 
  42 %- This function is just a fragment  of spm_results_ui.m, with a liitle change a line 
  43 %- to call csl_getSPM2 with sCon as input.
  44 %====================================================================
  45 %- From spm_results_ui 
  46 %- KHERIF Ferath csl, Cambridge, UK.
  47 
  48 %-Initialise 
  49 %-----------------------------------------------------------------------
  50 %SPMid      = spm('FnBanner',mfilename,SCCSid);
  51 [Finter,Fgraph,CmdLine] = spm('FnUIsetup','Stats: Results');
  52 FS         = spm('FontSizes');
  53 
  54 % clear satfig if it exists
  55 %-----------------------------------------------------------------------
  56 hSat       = findobj('tag','Satellite');
  57 spm_figure('clear',hSat);
  58 
  59 %-Get thresholded xSPM data and parameters of design
  60 %=======================================================================
  61 [SPM,xSPM] = csl_getSPM2(sCon);
  62 M          = SPM.xVol.M;
  63 DIM        = SPM.xVol.DIM;
  64 
  65 % ensure pwd = swd so that relative filenames are valid
  66 %-----------------------------------------------------------------------
  67 cd(SPM.swd)
  68 
  69 %-Setup Results User Interface; Display MIP, design matrix & parameters
  70 %=======================================================================
  71 spm('FigName',['SPM{',xSPM.STAT,'}: Results'],Finter,CmdLine);
  72 
  73 
  74 %-Setup results GUI
  75 %-----------------------------------------------------------------------
  76 spm_figure('Clear',Finter)
  77 hReg      = spm_results_ui('SetupGUI',M,DIM,xSPM,Finter);
  78 
  79 %-Setup design interrogation menu
  80 %-----------------------------------------------------------------------
  81 hDesRepUI = spm_DesRep('DesRepUI',SPM);
  82 figure(Finter)
  83 
  84 %-Setup Maximium intensity projection (MIP) & register
  85 %-----------------------------------------------------------------------
  86 hMIPax = axes('Parent',Fgraph,'Position',[0.05 0.60 0.55 0.36],'Visible','off');
  87 hMIPax = spm_mip_ui(xSPM.Z,xSPM.XYZmm,M,DIM,hMIPax);
  88 spm_XYZreg('XReg',hReg,hMIPax,'spm_mip_ui');
  89 if xSPM.STAT == 'P'
  90 	str = xSPM.STATstr;
  91 else
  92 	str = ['SPM\{',xSPM.STATstr,'\}'];
  93 end
  94 text(240,260,str,...
  95 	'Interpreter','TeX',...
  96 	'FontSize',FS(14),'Fontweight','Bold',...
  97 	'Parent',hMIPax)
  98 
  99 
 100 %-Print comparison title
 101 %-----------------------------------------------------------------------
 102 hTitAx = axes('Parent',Fgraph,...
 103 		'Position',[0.02 0.95 0.96 0.02],...
 104 		'Visible','off');
 105 
 106 text(0.5,0,xSPM.title,'Parent',hTitAx,...
 107 	'HorizontalAlignment','center',...
 108 	'VerticalAlignment','baseline',...
 109 	'FontWeight','Bold','FontSize',FS(14))
 110 
 111 
 112 %-Print SPMresults: Results directory & thresholding info
 113 %-----------------------------------------------------------------------
 114 hResAx = axes('Parent',Fgraph,...
 115 		'Position',[0.05 0.55 0.45 0.05],...
 116 		'DefaultTextVerticalAlignment','baseline',...
 117 		'DefaultTextFontSize',FS(9),...
 118 		'DefaultTextColor',[1,1,1]*.7,...
 119 		'Units','points',...
 120 		'Visible','off');
 121 AxPos = get(hResAx,'Position'); set(hResAx,'YLim',[0,AxPos(4)])
 122 h     = text(0,24,'SPMresults:','Parent',hResAx,...
 123 	'FontWeight','Bold','FontSize',FS(14));
 124 text(get(h,'Extent')*[0;0;1;0],24,spm_str_manip(SPM.swd,'a30'),'Parent',hResAx)
 125 text(0,12,sprintf('Height threshold %c = %0.2f',xSPM.STAT,xSPM.u),'Parent',hResAx)
 126 text(0,00,sprintf('Extent threshold k = %0.0f voxels',xSPM.k), 'Parent',hResAx)
 127 
 128 
 129 %-Plot design matrix
 130 %-----------------------------------------------------------------------
 131 hDesMtx   = axes('Parent',Fgraph,'Position',[0.65 0.55 0.25 0.25]);
 132 hDesMtxIm = image((SPM.xX.nKX + 1)*32);
 133 xlabel('Design matrix')
 134 set(hDesMtxIm,'ButtonDownFcn','spm_DesRep(''SurfDesMtx_CB'')',...
 135 	'UserData',struct(...
 136 		'X',		SPM.xX.xKXs.X,...
 137 		'fnames',	{reshape({SPM.xY.VY.fname},size(SPM.xY.VY))},...
 138 		'Xnames',	{SPM.xX.name}))
 139 
 140 %-Plot contrasts
 141 %-----------------------------------------------------------------------
 142 nPar   = size(SPM.xX.X,2);
 143 xx     = [repmat([0:nPar-1],2,1);repmat([1:nPar],2,1)];
 144 nCon   = length(xSPM.Ic);
 145 xCon   = SPM.xCon;
 146 if nCon
 147 	dy     = 0.15/max(nCon,2);
 148 	hConAx = axes('Position',[0.65 (0.80 + dy*.1) 0.25 dy*(nCon-.1)],...
 149 		'Tag','ConGrphAx','Visible','off');
 150 	title('contrast(s)')
 151 	htxt   = get(hConAx,'title'); 
 152 	set(htxt,'Visible','on','HandleVisibility','on')
 153 end
 154 
 155 for ii = nCon:-1:1
 156     axes('Position',[0.65 (0.80 + dy*(nCon - ii +.1)) 0.25 dy*.9])
 157     if xCon(xSPM.Ic(ii)).STAT == 'T' & size(xCon(xSPM.Ic(ii)).c,2) == 1
 158 
 159 	%-Single vector contrast for SPM{t} - bar
 160 	%---------------------------------------------------------------
 161 	yy = [zeros(1,nPar);repmat(xCon(xSPM.Ic(ii)).c',2,1);zeros(1,nPar)];
 162 	h  = patch(xx,yy,[1,1,1]*.5);
 163 	set(gca,'Tag','ConGrphAx',...
 164 		'Box','off','TickDir','out',...
 165 		'XTick',spm_DesRep('ScanTick',nPar,10) - 0.5,'XTickLabel','',...
 166 		'XLim',	[0,nPar],...
 167 		'YTick',[-1,0,+1],'YTickLabel','',...
 168 		'YLim',[min(xCon(xSPM.Ic(ii)).c),max(xCon(xSPM.Ic(ii)).c)] +...
 169 		       [-1 +1] * max(abs(xCon(xSPM.Ic(ii)).c))/10	)
 170 
 171     else
 172 
 173 	%-F-contrast - image
 174 	%---------------------------------------------------------------
 175 	h = image((xCon(xSPM.Ic(ii)).c'/max(abs(xCon(xSPM.Ic(ii)).c(:)))+1)*32);
 176 	set(gca,'Tag','ConGrphAx',...
 177 		'Box','on','TickDir','out',...
 178 		'XTick',spm_DesRep('ScanTick',nPar,10),'XTickLabel','',...
 179 		'XLim',	[0,nPar]+0.5,...
 180 		'YTick',[0:size(SPM.xCon(xSPM.Ic(ii)).c,2)]+0.5,....
 181 		'YTickLabel','',...
 182 		'YLim',	[0,size(xCon(xSPM.Ic(ii)).c,2)]+0.5	)
 183 
 184     end
 185     ylabel(num2str(xSPM.Ic(ii)))
 186     set(h,'ButtonDownFcn','spm_DesRep(''SurfCon_CB'')',...
 187     	'UserData',	struct(	'i',		xSPM.Ic(ii),...
 188     				'h',		htxt,...
 189     				'xCon',		xCon(xSPM.Ic(ii))))
 190 end
 191 
 192 
 193 %-Store handles of results section Graphics window objects
 194 %-----------------------------------------------------------------------
 195 H  = get(Fgraph,'Children');
 196 H  = findobj(H,'flat','HandleVisibility','on');
 197 H  = findobj(H);
 198 Hv = get(H,'Visible');
 199 set(hResAx,'Tag','PermRes','UserData',struct('H',H,'Hv',{Hv}))
 200 
 201 
 202 %-Finished results setup
 203 %-----------------------------------------------------------------------
 204 varargout = {hReg,xSPM,SPM};

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2008-03-12 18:40:18, 8.6 KB) [[attachment:BatchRenderRFX.m]]
  • [get | view] (2006-11-03 10:32:58, 7.6 KB) [[attachment:cls_getRes.m]]
  • [get | view] (2006-11-03 10:33:54, 19.9 KB) [[attachment:cls_getSPM2.m]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.