spm_mesh_max.m 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. function [N,Z,M,A,XYZ] = spm_mesh_max(X,L,G)
  2. % Sizes, local maxima and locations of excursion sets on a surface mesh
  3. % FORMAT [N,Z,M,A,XYZ] = spm_mesh_max(X,L,G)
  4. % X - a [nx1] array of stat values
  5. % L - a [nx1] array of locations {in vertices}
  6. % G - a patch structure
  7. %
  8. % N - a [px1] size of connected components {in vertices}
  9. % Z - stat values of maxima
  10. % M - location of maxima {in vertices}
  11. % A - region number
  12. % XYZ - cell array of vertices locations
  13. %__________________________________________________________________________
  14. %
  15. % See also: spm_max.m, spm_mesh_clusters.m and spm_mesh_get_lm.m
  16. %__________________________________________________________________________
  17. % Copyright (C) 2012-2016 Wellcome Trust Centre for Neuroimaging
  18. % Guillaume Flandin
  19. % $Id: spm_mesh_max.m 6860 2016-08-25 12:00:10Z guillaume $
  20. %-Get connected components
  21. %--------------------------------------------------------------------------
  22. LL = NaN(size(G.vertices,1),1);
  23. LL(L(1,:)) = X;
  24. [C, N] = spm_mesh_clusters(G,LL);
  25. %-Get local maxima
  26. %--------------------------------------------------------------------------
  27. M = spm_mesh_get_lm(G,LL);
  28. Z = LL(M);
  29. A = C(M);
  30. M = [M;ones(2,size(M,2))];
  31. N = N(A);
  32. if nargout > 4
  33. XYZ = cell(1,max(A));
  34. for i=1:numel(XYZ)
  35. XYZ{i} = find(C==i)';
  36. XYZ{i} = [XYZ{i};ones(2,size(XYZ{i},2))];
  37. end
  38. end