


Berg Parameter calculation for EEG multilayer spherical forward model
[mu,lam] = vb_berg_param(R, sigma)
[mu,lam,f] = vb_berg_param(R, sigma, NJ, Nmax, Nopt)
Computes the Berg parameters:
INPUTS (Required):
R : Radii of sphere from innermost to outermost ( NL x 1 )
sigma: Conductivity from innermost to outermost ( NL x 1 )
INPUTS (Optional):
Nmax : # of Legendre Expansion
to fit Berg Parameters (Default: 200)
NJ : # of Berg Dipoles (Default: 3)
Nopt : # of optimization search
mu_ini: Initial value for radial factors ( NJ x 1 )
lam_ini: Initial value for magnitude factors ( NJ x 1 )
NL = # of sphere layers;
NJ = # of Berg Dipoles
OUTPUTS:
mu: Berg radial factors ( NJ x 1 )
lam: Berg magnitude factors ( NJ x 1 )
f: Legendre Expansion Weights used to fit Berg Parameters ( Nmax x 1 )
Single Dipole in a multilayer sphere can be approximated
by multiple dipoles in a single shell.
Z. Zhang, Phys. Med. Biol., vol.40, pp. 335-349, 1995.
Copyright (C) 2011, ATR All Rights Reserved.
License : New BSD License(see VBMEG_LICENSE.txt)

0001 function [mu, lam, f, fval, flag, nsteps] = ... 0002 vb_berg_param(R, sigma, NJ, Nmax, Nopt, mu_ini, lam_ini) 0003 % Berg Parameter calculation for EEG multilayer spherical forward model 0004 % [mu,lam] = vb_berg_param(R, sigma) 0005 % [mu,lam,f] = vb_berg_param(R, sigma, NJ, Nmax, Nopt) 0006 % 0007 % Computes the Berg parameters: 0008 % 0009 % INPUTS (Required): 0010 % R : Radii of sphere from innermost to outermost ( NL x 1 ) 0011 % sigma: Conductivity from innermost to outermost ( NL x 1 ) 0012 % 0013 % INPUTS (Optional): 0014 % Nmax : # of Legendre Expansion 0015 % to fit Berg Parameters (Default: 200) 0016 % NJ : # of Berg Dipoles (Default: 3) 0017 % Nopt : # of optimization search 0018 % mu_ini: Initial value for radial factors ( NJ x 1 ) 0019 % lam_ini: Initial value for magnitude factors ( NJ x 1 ) 0020 % 0021 % NL = # of sphere layers; 0022 % NJ = # of Berg Dipoles 0023 % 0024 % OUTPUTS: 0025 % mu: Berg radial factors ( NJ x 1 ) 0026 % lam: Berg magnitude factors ( NJ x 1 ) 0027 % f: Legendre Expansion Weights used to fit Berg Parameters ( Nmax x 1 ) 0028 % 0029 % 0030 % Single Dipole in a multilayer sphere can be approximated 0031 % by multiple dipoles in a single shell. 0032 % Z. Zhang, Phys. Med. Biol., vol.40, pp. 335-349, 1995. 0033 % 0034 % 0035 % Copyright (C) 2011, ATR All Rights Reserved. 0036 % License : New BSD License(see VBMEG_LICENSE.txt) 0037 0038 % # of sphere 0039 NL = length(R); 0040 0041 if nargin < 3 0042 % Default # of Berg Parameters 0043 NJ=3; 0044 end 0045 0046 if nargin < 4 0047 % Default # of Legendre expansion 0048 Nmax = 200; 0049 end 0050 0051 if nargin < 5 0052 % Default # of iteration in optimum search 0053 Nopt = 1000; 0054 end 0055 0056 if nargin < 6 0057 % Default Value for Initial Eccentricity Parameters 0058 mu_ini = (1/(NJ+2))*[1:NJ]; 0059 % Default Value for Initial Magnitude Parameters 0060 lam_ini = 0.2*ones(1,NJ); 0061 end 0062 0063 % 0064 % Set minimization option 0065 % 0066 %OPTIONS = optimset('MaxFunEvals', NJ*Nopt, ... 0067 % 'MaxIter', NJ*Nopt, ... 0068 % 'TolFun', [0 1.e-9 1.e-9]); 0069 0070 OPTIONS = optimset('MaxFunEvals', NJ*Nopt, ... 0071 'MaxIter', NJ*Nopt, ... 0072 'TolFun', [0 1.e-8 1.e-8]); 0073 0074 % Computes the weights f(n) for legendre expansion 0075 0076 f = vb_multi_shell_param(R, sigma, Nmax); 0077 0078 % 0079 % Minimize the error function defined by Zhang 0080 % 0081 0082 [berg, fval, flag, outputs]= ... 0083 fminsearch('vb_berg_error',[mu_ini lam_ini(2:NJ)], OPTIONS, R, f); 0084 0085 nsteps = outputs.iterations; 0086 0087 mu = berg(1:NJ); 0088 lam(2:NJ) = berg(NJ+1:2*NJ-1); 0089 lam(1) = f(1) - sum(lam(2:NJ));