Home > functions > device > filter_func > vb_channel_bias_remove.m

vb_channel_bias_remove

PURPOSE ^

Remove bias and a linear trend from multi channel data

SYNOPSIS ^

function y = vb_channel_bias_remove(x,mode)

DESCRIPTION ^

 Remove bias and a linear trend from multi channel data
  y = vb_channel_bias_remove(x,mode)
 x : channel x time
 mode = 1: bias removal
      = 2: bias and a linear trend removal

 Masa-aki Sato 2009-1-27

 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 y = vb_channel_bias_remove(x,mode)
0002 % Remove bias and a linear trend from multi channel data
0003 %  y = vb_channel_bias_remove(x,mode)
0004 % x : channel x time
0005 % mode = 1: bias removal
0006 %      = 2: bias and a linear trend removal
0007 %
0008 % Masa-aki Sato 2009-1-27
0009 %
0010 % Copyright (C) 2011, ATR All Rights Reserved.
0011 % License : New BSD License(see VBMEG_LICENSE.txt)
0012 
0013 if nargin == 1 | isempty(mode),    mode = 1; end
0014 
0015 [Nch,T] = size(x);
0016 
0017 % bias remove
0018 x = vb_repadd( x, - mean(x,2));% sum(x,2) = 0 is not hold when T >> 1
0019 x = vb_repadd( x, - mean(x,2));% repeat for numerical accuracy
0020 
0021 switch    mode
0022 case    1
0023     y = x;
0024 case    2
0025     % x = a * t
0026     t = (1:T) - (T+1)/2; % sum(t)=0
0027     t = t/T;
0028     a = (x * t')./sum(t.^2);
0029     y = x - a * t;
0030 end
0031

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005