Home > vbmeg > functions > estimation > bayes > vb_calc_GoF.m

vb_calc_GoF

PURPOSE ^

Calculate GoF (goodness of fit); a measure how magnetic field can be reconstructed by estimated current.

SYNOPSIS ^

function GoF = vb_calc_GoF(basis,w,B, mode)

DESCRIPTION ^

 Calculate GoF (goodness of fit); a measure how magnetic field can be reconstructed by estimated current.
 
-- Syntax
 GoF = vb_calc_GoF(basis,w,B)
 GoF = vb_calc_GoF(basis,w,B, mode)

-- Input 
 basis : Lead field (Nch*Nvertex)   
 w     : Estimated current    (Nvertex*Nt)
 B     : MEG observation (Nch*Nt)  

-- Optional
 mode [0] : if mode = 0, Yoshioka-san version
            if mode = 1, Coefficient of determination, CoD (search 'Coefficient of Determation' in google)
            CoD is originally defined in ordinal regression problem (over-detremined problem), therefore it may not be appropriate 
            for sourse localization problem (under-determined problem).

 mode = 0,    GoF = 100 * (1 - ((B-B_estimation)^2/B^2))
 mode = 1,    GoF = 100 * (1 - (B-B_estimation)^2/(B-B_bar)^2), where B_bar is mean of B   

-- Output
 GoF : Goodness of Fit for each time point (1*Nt)

 2004-03-12 Taku Yoshioka
 2005-10-15 O Yamashita
 2006-05-30 O Yamashita

 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 GoF = vb_calc_GoF(basis,w,B, mode)
0002 % Calculate GoF (goodness of fit); a measure how magnetic field can be reconstructed by estimated current.
0003 %
0004 %-- Syntax
0005 % GoF = vb_calc_GoF(basis,w,B)
0006 % GoF = vb_calc_GoF(basis,w,B, mode)
0007 %
0008 %-- Input
0009 % basis : Lead field (Nch*Nvertex)
0010 % w     : Estimated current    (Nvertex*Nt)
0011 % B     : MEG observation (Nch*Nt)
0012 %
0013 %-- Optional
0014 % mode [0] : if mode = 0, Yoshioka-san version
0015 %            if mode = 1, Coefficient of determination, CoD (search 'Coefficient of Determation' in google)
0016 %            CoD is originally defined in ordinal regression problem (over-detremined problem), therefore it may not be appropriate
0017 %            for sourse localization problem (under-determined problem).
0018 %
0019 % mode = 0,    GoF = 100 * (1 - ((B-B_estimation)^2/B^2))
0020 % mode = 1,    GoF = 100 * (1 - (B-B_estimation)^2/(B-B_bar)^2), where B_bar is mean of B
0021 %
0022 %-- Output
0023 % GoF : Goodness of Fit for each time point (1*Nt)
0024 %
0025 % 2004-03-12 Taku Yoshioka
0026 % 2005-10-15 O Yamashita
0027 % 2006-05-30 O Yamashita
0028 %
0029 % Copyright (C) 2011, ATR All Rights Reserved.
0030 % License : New BSD License(see VBMEG_LICENSE.txt)
0031 
0032 if nargin < 4
0033     mode = 0;
0034 end
0035 
0036 if mode == 0  % default
0037     tmp1 = sum((basis * w - B).^2,1);
0038     tmp2 = sum(B.^2,1);
0039     GoF = 1-tmp1./tmp2;
0040 else
0041     [Nch, Nt] = size(B);
0042     Bmean = mean(B,1); %% average over sensor for each time pointr
0043     ST= sum((B-repmat(Bmean, [Nch, 1])).^2,1); % total variation
0044     SE= sum((basis * w - B).^2, 1); % error variation
0045 
0046     GoF = 1 - SE./ST;
0047 end
0048 
0049 GoF = 100*GoF;

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