GSRme.m 668 B

1234567891011121314151617181920212223242526272829303132
  1. function gsrY=GSRme(Y,T,varargin)
  2. % Quick Global Signal Regression
  3. %
  4. % NOTE: Y should be a TxI matrix
  5. %
  6. % SA, Ox, 2018
  7. if nargin==3; error('something is wrong mate!'); end;
  8. if ~exist('T','var')
  9. error('Second input should be length of TS for sanity check.');
  10. end;
  11. if size(Y,1)~=T
  12. Y=Y'; %TxI
  13. end
  14. if sum(strcmpi(varargin,'GS'))
  15. mY = varargin{find(strcmpi(varargin,'GS'))+1};
  16. if size(mY,1)~=T; error('GSRme :: Make sure that the global signal is as long as the other signals, maybe transpose?'); end
  17. else
  18. mY=mean(Y,2);
  19. end
  20. gsrY=Y-(mY*(pinv(mY)*Y));
  21. if size(gsrY,1)~=size(Y,1) || size(gsrY,2)~=size(Y,2)
  22. error('something is wrong!')
  23. end