samer@0: % additive_split - Arrow to process data with adaptive zero mean samer@0: % samer@0: % additive_split :: samer@0: % arrow( {[N,M]}, {[N,M]}, S1) ~'arrow to process N channel zero mean data', samer@0: % arrow( {[N]}, {[N]}, S2) ~'arrow to process estimated mean', samer@0: % options {} ~'options passed to azeromean' samer@0: % -> arrow( {[N,M]}, {[N,M]}, pair( pair([N],pair(S1,S2)), empty)). samer@0: % samer@0: % This arrow uses the azeromean arrow to adaptively estimate the mean of samer@0: % the N channels of input data, using a gaussian data model. The mean is samer@0: % subtracted out. The two components are then processed independently by samer@0: % the two supplied arrows and added together to create the output. samer@0: samer@0: function o=additive_split(a1,a2,varargin) samer@37: opts=options(varargin{:}); samer@0: samer@0: o = states(azeromean(gaussian,opts))*(a1+a2)*aplus; samer@0: end samer@0: samer@0: function o=aplus, o=arrf(@plusfn,2,1); end samer@0: function f=plusfn(sz) samer@0: if all(sz{1}==sz{2}), f=@plus; samer@0: elseif sz{1}(1)==sz{2}(1) && sz{1}(2)>sz{2}(2) samer@0: f=@(a,b)a+repmat(b,1,size(a,2)); samer@0: elseif sz{1}(1)==sz{2}(1) && sz{1}(2)