GetEventTypes - Get event types (= unique descriptions). USAGE descriptions = GetEventTypes(selection) selection optional patterns of event descriptions; see examples below EXAMPLES % Get all event descriptions descriptions = GetEventTypes(); % Get events with description starting with any letter % but 'R' and ending with ' beginning' m = GetEventTypes({'[^R].* beginning'}); NOTE Type 'help regexp' for details on pattern matching using regular expressions. SEE See also GetEvents.
0001 function descriptions = GetEventTypes(selection) 0002 0003 %GetEventTypes - Get event types (= unique descriptions). 0004 % 0005 % USAGE 0006 % 0007 % descriptions = GetEventTypes(selection) 0008 % 0009 % selection optional patterns of event descriptions; see examples below 0010 % 0011 % EXAMPLES 0012 % 0013 % % Get all event descriptions 0014 % descriptions = GetEventTypes(); 0015 % 0016 % % Get events with description starting with any letter 0017 % % but 'R' and ending with ' beginning' 0018 % m = GetEventTypes({'[^R].* beginning'}); 0019 % 0020 % NOTE 0021 % 0022 % Type 'help regexp' for details on pattern matching using regular expressions. 0023 % 0024 % SEE 0025 % 0026 % See also GetEvents. 0027 0028 0029 % Copyright (C) 2004-2012 by Michaƫl Zugaro 0030 % 0031 % This program is free software; you can redistribute it and/or modify 0032 % it under the terms of the GNU General Public License as published by 0033 % the Free Software Foundation; either version 3 of the License, or 0034 % (at your option) any later version. 0035 0036 global DATA; 0037 if isempty(DATA), 0038 error('No session defined (did you forget to call SetCurrentSession? Type ''help <a href="matlab:help Data">Data</a>'' for details).'); 0039 end 0040 0041 if nargin == 0, 0042 selection = '.*'; 0043 end 0044 if isa(selection,'char'), selection = {selection}; end 0045 0046 events = DATA.events; 0047 if isempty(events.time), return; end 0048 0049 % Selected events only 0050 nPatterns = length(selection); 0051 if nPatterns == 0, 0052 selected = logical(ones(size(events.time))); 0053 else 0054 selected = logical(zeros(size(events.time))); 0055 for i = 1:nPatterns, 0056 pattern = ['^' selection{i} '$']; 0057 matches = GetMatches(regexp(events.description,pattern)); 0058 selected = selected | matches; 0059 end 0060 end 0061 descriptions = unique({events.description{selected}})'; 0062 0063 function m = GetMatches(c) 0064 0065 m = zeros(length(c),1); 0066 for i = 1:length(c), 0067 m(i) = ~isempty(c{i}); 0068 end