0001 function [nG_global, bsnorm, ix_global, ix_global_ex, W_global, L_global]...
0002 = vb_global_leadfield_preparation(bayes_parm, bsnorm, remove_area)
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 if ~isfield(bayes_parm, 'patch_norm')
0023 bayes_parm.patch_norm = ON;
0024 end
0025
0026
0027 vb_struct2vars(bayes_parm,{'basisfile_global','area_key_global', ...
0028 'reduce_global', 'Rfilt_global','brainfile','areafile', ...
0029 'expand_spatial_filter', 'area_key','patch_norm', 'basis_smoother'});
0030
0031
0032 fprintf('--- Lead field matrix of global window \n');
0033 if exist('remove_area','var') & remove_area == ON,
0034
0035 [G_global, L_global, W_global, ix_global, ix_global_ex] = ...
0036 vb_prepare_leadfield(basisfile_global, brainfile, areafile,...
0037 area_key_global, reduce_global, Rfilt_global, expand_spatial_filter,...
0038 patch_norm, area_key, basis_smoother);
0039 else
0040 [G_global, L_global, W_global, ix_global, ix_global_ex] = ...
0041 vb_prepare_leadfield(basisfile_global, brainfile, areafile,...
0042 area_key_global, reduce_global, Rfilt_global, expand_spatial_filter,...
0043 patch_norm, [], basis_smoother);
0044 end
0045
0046 Nsession = length(G_global);
0047
0048
0049 if ~exist('bsnorm','var') | isempty(bsnorm)
0050 Bnorm = zeros(Nsession,1);
0051
0052 for n = 1: Nsession
0053 GG_global = sum(G_global{n}.^2, 2);
0054 Bnorm(n) = sum(GG_global)/length(GG_global);
0055 end
0056
0057
0058 bsnorm = sqrt(mean(Bnorm));
0059 end
0060
0061 for n=1:Nsession
0062 nG_global{n} = G_global{n}/bsnorm;
0063 end;
0064