badchannels.m 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. function res = badchannels(this, varargin)
  2. % Method for getting/setting bad channels
  3. % FORMAT res = badchannels(this)
  4. % _______________________________________________________________________
  5. % Copyright (C) 2008-2012 Wellcome Trust Centre for Neuroimaging
  6. % Stefan Kiebel
  7. % $Id: badchannels.m 5933 2014-03-28 13:22:28Z vladimir $
  8. if length(varargin) == 2 && isnumeric(varargin{1})
  9. % make sure that the two inputs for set are the same length
  10. if ~(length(varargin{2}) == 1 || (length(varargin{1}) == length(varargin{2})))
  11. error('Use either same vector length or scalar for value');
  12. end
  13. end
  14. if numel(varargin) >= 1 && (isnumeric(varargin{1}) && ~isempty(varargin{1}))
  15. if ~(all(varargin{1} >= 1) && all(varargin{1} <= nchannels(this)))
  16. error('Channel number out of range.');
  17. end
  18. end
  19. if numel(varargin) >= 2 && (isnumeric(varargin{1}) && ~isempty(varargin{1}))
  20. ubad = unique(varargin{2});
  21. if isempty(ubad) || ~all(ismember(ubad, [0 1]))
  22. error('Illegal bad flags (should be 0 or 1)');
  23. end
  24. end
  25. if this.montage.Mind == 0
  26. res = getset(this, 'channels', 'bad', varargin{:});
  27. elseif numel(varargin) >= 2
  28. this.montage.M(this.montage.Mind) = getset(this.montage.M(this.montage.Mind), 'channels', 'bad', varargin{:});
  29. res = this;
  30. else
  31. res = getset(this.montage.M(this.montage.Mind), 'channels', 'bad', varargin{:});
  32. end
  33. % Return channel indices if called without arguments and [0, 1] if called
  34. if numel(varargin) <= 1 % get
  35. if iscell(res)
  36. res = [res{:}];
  37. end
  38. res = logical(res);
  39. if isempty(varargin)
  40. res = find(res);
  41. end
  42. end