Home > vbmeg > functions > leadfield > eeg > vb_berg_error.m

vb_berg_error

PURPOSE ^

Error function to optimize Berg parameters for multilayer sphere model

SYNOPSIS ^

function delta = vb_berg_error(berg, R, f)

DESCRIPTION ^

 Error function to optimize Berg parameters for multilayer sphere model

 INPUTS:
    berg : Berg parameters                                  (2*NJ-1) x 1
    R    : Sphere Radii from innermost to outermost               NL x 1
    f    : Legendre Expansion Weights to fit Berg Parameters  ( Nmax x 1 )
 
        NL = # of sphere layers; 
      Nmax = # of Legendre Expansion
        NJ = # of Berg Dipoles

 OUTPUTS:
   delta: Error function value to be minimized

 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)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function delta = vb_berg_error(berg, R, f)
0002 % Error function to optimize Berg parameters for multilayer sphere model
0003 %
0004 % INPUTS:
0005 %    berg : Berg parameters                                  (2*NJ-1) x 1
0006 %    R    : Sphere Radii from innermost to outermost               NL x 1
0007 %    f    : Legendre Expansion Weights to fit Berg Parameters  ( Nmax x 1 )
0008 %
0009 %        NL = # of sphere layers;
0010 %      Nmax = # of Legendre Expansion
0011 %        NJ = # of Berg Dipoles
0012 %
0013 % OUTPUTS:
0014 %   delta: Error function value to be minimized
0015 %
0016 % Z. Zhang,  Phys. Med. Biol., vol.40, pp. 335-349, 1995.
0017 %
0018 %
0019 % Copyright (C) 2011, ATR All Rights Reserved.
0020 % License : New BSD License(see VBMEG_LICENSE.txt)
0021 
0022 NL     = length(R);               % Number of Sphere Layers
0023 Nmax = length(f);               % Number of Legendre Series Terms
0024 NJ     = (length(berg)+1)/2;      % Number of Berg Dipoles
0025 mu     = berg(1:NJ);              % Berg Eccentricity Factors
0026 lam  = [0.0 berg(NJ+1:2*NJ-1)];    % Berg Magnitude Factors
0027 
0028 % Error function defined by Zhang Eq. (5i")
0029 delta = 0.0;
0030 r     = R(1)/R(NL);
0031 
0032 for n = 2:Nmax
0033    err0 = 0;
0034    for j=2:NJ
0035       err0 = err0 + lam(j)*( mu(j)^(n-1) - mu(1)^(n-1) );
0036    end
0037    
0038    err   = ( r^(n-1) )*( f(n) - f(1)*mu(1)^(n-1) - err0 );
0039    delta = delta + err*err;
0040 end
0041

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005