Get A and b quantities - average prediction errors from AR model FORMAT [voxel] = spm_vb_get_Ab (Y,slice) Y data slice data structure voxel(n).A voxel(n).b The above quantities are estimated using pre-computed cross-covariance matrices %W% Will Penny and Nelson Trujillo-Barreto %E%
0001 function [voxel] = spm_vb_get_Ab (Y,slice) 0002 % Get A and b quantities - average prediction errors from AR model 0003 % FORMAT [voxel] = spm_vb_get_Ab (Y,slice) 0004 % 0005 % Y data 0006 % slice data structure 0007 % 0008 % voxel(n).A 0009 % voxel(n).b 0010 % 0011 % The above quantities are estimated using pre-computed 0012 % cross-covariance matrices 0013 % 0014 % %W% Will Penny and Nelson Trujillo-Barreto %E% 0015 0016 k=slice.k; 0017 N=slice.N; 0018 0019 for n=1:N, 0020 % Equation 63 of paper VB1 but implemented 0021 % efficiently using cross-covariance method described in paper VB3 0022 if isfield(slice.I,'A2_tilde') 0023 A2_tilde=slice.I.A2_tilde(:,:,n); 0024 else 0025 A2_tilde=reshape(slice.I.S*slice.a2{n}(:),k,k); 0026 end 0027 if isfield(slice.I,'A3a_tilde') 0028 A3a_tilde=slice.I.A3a_tilde(:,:,n); 0029 else 0030 A3a_tilde=-reshape(slice.I.R1*slice.ap_mean(:,n),k,k); 0031 end 0032 voxel(n).A=slice.I.xtx+A2_tilde+A3a_tilde+A3a_tilde'; 0033 0034 % Equation 64 of paper VB1 but implemented 0035 % efficiently using cross-covariance method described in paper VB3 0036 b2_tilde=-slice.I.rxy(:,:,n)'*slice.ap_mean(:,n); 0037 b3_tilde=-slice.I.Gxy(:,:,n)'*slice.ap_mean(:,n); 0038 b4_tilde= slice.I.D(:,:,n)*slice.a2{n}(:); 0039 voxel(n).b=slice.I.gxy(:,n)+b2_tilde+b3_tilde+b4_tilde; 0040 end 0041 0042