selectchannels.m 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. function chanind = selectchannels(this, channels)
  2. % Method for getting channel indices based on labels and/or types
  3. % FORMAT res = selectchannels(this, label)
  4. % this - MEEG object
  5. % channels - string or cell array of labels that may also include
  6. % 'all', or types ('EEG', 'MEG' etc.)
  7. %
  8. % res - vector of channel indices matching labels
  9. %__________________________________________________________________________
  10. % Copyright (C) 2010-2012 Wellcome Trust Centre for Neuroimaging
  11. % Vladimir Litvak
  12. % $Id: selectchannels.m 7253 2018-02-04 17:20:57Z vladimir $
  13. if ischar(channels)
  14. channels = {channels};
  15. end
  16. chanind = [];
  17. for i = 1:numel(channels)
  18. if strncmpi('regexp_', channels{i}, 7)
  19. re = channels{i}(8:end);
  20. match = regexp(chanlabels(this), re);
  21. chanind = [chanind find(~cellfun('isempty', match))];
  22. else
  23. cind = indchannel(this, channels{i});
  24. if ~isempty(cind)
  25. chanind = [chanind cind];
  26. elseif ismember(upper(channels{i}), ...
  27. {'ALL','MEG', 'MEGPLANAR', 'MEGMAG', 'MEGGRAD', 'MEGCOMB','EEG',...
  28. 'EOG', 'ECG', 'EMG', 'LFP', 'SRC', 'PHYS', 'ILAM', 'OTHER', 'REF', 'REFMAG', 'REFGRAD'})
  29. chanind = [chanind indchantype(this, upper(channels{i}))];
  30. end
  31. end
  32. if any(size(chanind) == 0)
  33. chanind = [];
  34. end
  35. end
  36. chanind = unique(chanind);