nrrd_getSpaceDimensions.m 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. % Get number of space dimensions ("space dimension" field) according to the
  2. % space descriptor, following the format definition at
  3. % http://teem.sourceforge.net/nrrd/format.html#spacedirections.
  4. %
  5. % Returns 3 if "space" field is one of
  6. % "right-anterior-superior" or "RAS"
  7. % "left-anterior-superior" or "LAS"
  8. % "left-posterior-superior" or "LPS"
  9. % "scanner-xyz"
  10. % "3D-right-handed"
  11. % "3D-left-handed"
  12. %
  13. % Returns 4 if "space" field is one of
  14. % "right-anterior-superior-time" or "RAST"
  15. % "left-anterior-superior-time" or "LAST"
  16. % "left-posterior-superior-time" or "LPST"
  17. % "scanner-xyz-time"
  18. % "3D-right-handed-time"
  19. % "3D-left-handed-time"
  20. %
  21. % Date: October 25, 2017
  22. % Author: Gaetan Rensonnet
  23. function sd = nrrd_getSpaceDimensions(spacedescriptor)
  24. if any(strcmpi(spacedescriptor,...
  25. {'right-anterior-superior', 'RAS',...
  26. 'left-anterior-superior', 'LAS',...
  27. 'left-posterior-superior', 'LPS',...
  28. 'scanner-xyz',...
  29. '3D-right-handed',...
  30. '3D-left-handed'}...
  31. ))
  32. sd = 3;
  33. elseif any(strcmpi(spacedescriptor,...
  34. {'right-anterior-superior-time', 'RAST',...
  35. 'left-anterior-superior-time', 'LAST',...
  36. 'left-posterior-superior-time', 'LPST', ...
  37. 'scanner-xyz-time', ...
  38. '3D-right-handed-time', ...
  39. '3D-left-handed-time'}...
  40. ))
  41. sd = 4;
  42. else
  43. sd = -1;
  44. % Unrecognized nrrd space descriptor (grace under fire)
  45. end
  46. end