spm_mesh_smooth.m 854 B

12345678910111213141516171819202122232425262728293031
  1. function T = spm_mesh_smooth(M, T, S)
  2. % Perform Gaussian smoothing on data lying on a surface mesh
  3. % FORMAT GL = spm_mesh_smooth(M)
  4. % M - a patch structure or a handle to a patch
  5. % GL - graph Laplacian
  6. %
  7. % FORMAT T = spm_mesh_smooth(M, T, S)
  8. % FORMAT T = spm_mesh_smooth(GL, T, S)
  9. % T - [vx1] data vector
  10. % S - smoothing parameter (number of iterations)
  11. %__________________________________________________________________________
  12. % Copyright (C) 2010 Wellcome Trust Centre for Neuroimaging
  13. % Karl Friston, Guillaume Flandin
  14. % $Id: spm_mesh_smooth.m 4079 2010-10-07 11:41:54Z guillaume $
  15. if isstruct(M) || numel(M) == 1
  16. A = spm_mesh_distmtx(M,0);
  17. N = size(A,1);
  18. GL = speye(N,N) + (A - spdiags(sum(A,2),0,N,N))/16;
  19. else
  20. GL = M;
  21. end
  22. if nargin == 1, T = GL; return; end
  23. for i=1:S
  24. T = GL * T;
  25. end
  26. return;