history.m 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. function res = history(this, varargin)
  2. % Method for getting or adding to the history of function calls of some
  3. % M/EEG data
  4. % FORMAT res = history(this, varargin)
  5. % _______________________________________________________________________
  6. % Copyright (C) 2008-2016 Wellcome Trust Centre for Neuroimaging
  7. % Stefan Kiebel
  8. % $Id: history.m 6883 2016-09-19 13:42:05Z vladimir $
  9. if isempty(varargin)
  10. res = this.history;
  11. else
  12. % add another history item
  13. if length(varargin) > 2 % To enable reset
  14. nh = 0;
  15. this.history = [];
  16. else
  17. nh = length(this.history);
  18. end
  19. if ischar(varargin{1})
  20. this.history(nh+1).fun = varargin{1};
  21. if isstruct(varargin{2}) && isfield(varargin{2}, 'D')
  22. if isa(varargin{2}.D, 'meeg')
  23. varargin{2}.D = fullfile(varargin{2}.D);
  24. elseif isa(varargin{2}.D, 'cell')
  25. for i = 1:numel(varargin{2}.D)
  26. if isa(varargin{2}.D{i}, 'meeg')
  27. varargin{2}.D{i} = fullfile(varargin{2}.D{i});
  28. end
  29. end
  30. end
  31. end
  32. this.history(nh+1).args = varargin{2};
  33. [dum, this.history(nh+1).ver] = spm('ver');
  34. elseif isstruct(varargin{1})
  35. this.history = varargin{1};
  36. end
  37. res = this;
  38. end