frequencies.m 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. function res = frequencies(this, ind, f)
  2. % Method for getting/setting frequencies of TF data
  3. % FORMAT res = frequencies(this, ind, values)
  4. % _________________________________________________________________________
  5. % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging
  6. % Stefan Kiebel
  7. % $Id: frequencies.m 5079 2012-11-25 18:38:18Z vladimir $
  8. if nargin >1
  9. if ~isnumeric(ind)
  10. ind = 1:nfrequencies(this);
  11. end
  12. end
  13. if nargin < 3
  14. if strncmpi(transformtype(this), 'TF',2)
  15. res = this.transform.frequencies;
  16. else
  17. res = [];
  18. return
  19. end
  20. if exist('ind', 'var') == 1
  21. res = res(ind);
  22. end
  23. else
  24. if ~strncmpi(transformtype(this), 'TF',2)
  25. error('Frequencies can only be assigned to a TF dataset');
  26. end
  27. if any(f) <= 0 || any(~isnumeric(f))
  28. error('Frequencies must be positive numbers');
  29. end
  30. if length(ind)~=length(f) || max(ind)>size(this, 2)
  31. error('Wrong frequency axis or indices');
  32. end
  33. if length(ind) == size(this.data, 2)
  34. this.transform.frequencies = f;
  35. else
  36. this.transform.frequencies(ind) = f;
  37. end
  38. res = this;
  39. end