Attachment 'extractSPMData.m'
Download 1 % This function extracts beta, st error and 90% CI
2 % for the voxel at the current location in the SPM
3 % results viewer (or at a location specified in
4 % the third argument).
5 % [beta,sterr,ci90] = extractSPMData(xSPM,SPM,[coords]);
6 % 11/6/2010 J Carlin
7 function [cbeta,SE,CI] = extractSPMData(xSPM,SPM,coords);
8
9 hReg = findobj('Tag','hReg'); % get results figure handle
10
11 % Use current coordinates, if none were provided
12 if ~exist('coords','var')
13 coords = spm_XYZreg('GetCoords',hReg);
14 end
15
16 % This is mostly pulled out of spm_graph
17 [xyz,i] = spm_XYZreg('NearestXYZ',coords,xSPM.XYZmm);
18 spm_XYZreg('SetCoords',xyz,hReg);
19 XYZ = xSPM.XYZ(:,i); % coordinates
20
21 %-Parameter estimates: beta = xX.pKX*xX.K*y;
22 %-Residual mean square: ResMS = sum(R.^2)/xX.trRV
23 %----------------------------------------------------------------------
24 beta = spm_get_data(SPM.Vbeta, XYZ);
25 ResMS = spm_get_data(SPM.VResMS,XYZ);
26 Bcov = ResMS*SPM.xX.Bcov;
27
28 CI = 1.6449;
29 % compute contrast of parameter estimates and 90% C.I.
30 %------------------------------------------------------------------
31 Ic = xSPM.Ic; % Use current contrast
32 cbeta = SPM.xCon(Ic).c'*beta;
33 SE = sqrt(diag(SPM.xCon(Ic).c'*Bcov*SPM.xCon(Ic).c));
34 CI = CI*SE;
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.You are not allowed to attach a file to this page.