spm_mesh_detect.m 876 B

123456789101112131415161718192021222324252627282930
  1. function s = spm_mesh_detect(F)
  2. % True for valid representation of a mesh
  3. % FORMAT s = spm_mesh_detect(F)
  4. % F - variable to query: filename, vol structure, patch structure
  5. % s - true if F corresponds to a mesh, and false otherwise
  6. %__________________________________________________________________________
  7. % Copyright (C) 2012 Wellcome Trust Centre for Neuroimaging
  8. % Guillaume Flandin
  9. % $Id: spm_mesh_detect.m 5065 2012-11-16 20:00:21Z guillaume $
  10. s = false;
  11. if iscellstr(F) || ischar(F)
  12. F = cellstr(F);
  13. [p,n,e] = spm_fileparts(F{1});
  14. if strcmpi(e,'.gii')
  15. s = true;
  16. end
  17. elseif isstruct(F)
  18. if isfield(F,'vertices') && isfield(F,'faces')
  19. s = true;
  20. elseif isfield(F,'cdata')
  21. s = true;
  22. elseif isfield(F,'private') && isa(F(1).private,'gifti')
  23. s = true;
  24. end
  25. elseif isa(F,'gifti')
  26. s = true;
  27. end