indtrial.m 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. function res = indtrial(this, label, flag)
  2. % Method for getting trial indices based on condition labels
  3. % FORMAT res = indtrial(this, label)
  4. % this - MEEG object
  5. % label - string or cell array of labels, 'GOOD' and 'BAD'
  6. % can be added to list of labels to select only
  7. % good or bad trials respectively
  8. % flag - 'GOOD' or 'BAD' to include only good or bad trials
  9. % respectively (all are selected by default)
  10. %
  11. % res - vector of trial indices matching condition labels
  12. %__________________________________________________________________________
  13. % Copyright (C) 2008-2012 Wellcome Trust Centre for Neuroimaging
  14. % Vladimir Litvak
  15. % $Id: indtrial.m 6998 2017-01-31 16:48:27Z vladimir $
  16. if ischar(label)
  17. label = {label};
  18. end
  19. [dum, res] = match_str(label, conditions(this));
  20. if nargin > 2
  21. if strcmpi(flag, 'GOOD')
  22. [dum, ind] = setdiff(res, badtrials(this));
  23. elseif strcmpi(flag, 'BAD')
  24. [dum, ind] = intersect(res, badtrials(this));
  25. end
  26. res = res(sort(ind));
  27. end
  28. res = res(:)';