spm_get_defaults.m 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. function varargout = spm_get_defaults(defstr, varargin)
  2. % Get/set the defaults values associated with an identifier
  3. % FORMAT defaults = spm_get_defaults
  4. % Return the global "defaults" variable defined in spm_defaults.m.
  5. %
  6. % FORMAT defval = spm_get_defaults(defstr)
  7. % Return the defaults value associated with identifier "defstr".
  8. % Currently, this is a '.' subscript reference into the global
  9. % "defaults" variable defined in spm_defaults.m.
  10. %
  11. % FORMAT spm_get_defaults(defstr, defval)
  12. % Set the defaults value associated with identifier "defstr" to defval.
  13. % The new defaults value applies immediately to:
  14. % * new modules in batch jobs
  15. % * modules in batch jobs that have not been saved yet
  16. % This value will not be saved for future sessions of SPM. To make
  17. % persistent changes, see help section in spm_defaults.m.
  18. %__________________________________________________________________________
  19. % Copyright (C) 2008-2014 Wellcome Trust Centre for Neuroimaging
  20. % Volkmar Glauche
  21. % $Id: spm_get_defaults.m 6157 2014-09-05 18:17:54Z guillaume $
  22. global defaults;
  23. if isempty(defaults)
  24. spm_defaults;
  25. end
  26. if nargin == 0
  27. varargout{1} = defaults;
  28. return
  29. end
  30. % construct subscript reference struct from dot delimited tag string
  31. tags = textscan(defstr,'%s', 'delimiter','.');
  32. subs = struct('type','.','subs',tags{1}');
  33. if nargin == 1
  34. varargout{1} = subsref(defaults, subs);
  35. else
  36. defaults = subsasgn(defaults, subs, varargin{1});
  37. end