GetUnits - Get list of units. USAGE units = GetUnits(groups) group one or more optional electrode groups (default = all groups) EXAMPLES all = GetUnits; % list all units units = GetUnits(2); % list all units on electrode group 2
0001 function units = GetUnits(groups) 0002 0003 %GetUnits - Get list of units. 0004 % 0005 % USAGE 0006 % 0007 % units = GetUnits(groups) 0008 % 0009 % group one or more optional electrode groups (default = all groups) 0010 % 0011 % EXAMPLES 0012 % 0013 % all = GetUnits; % list all units 0014 % units = GetUnits(2); % list all units on electrode group 2 0015 0016 0017 % Copyright (C) 2004-2012 by Michaƫl Zugaro 0018 % 0019 % This program is free software; you can redistribute it and/or modify 0020 % it under the terms of the GNU General Public License as published by 0021 % the Free Software Foundation; either version 3 of the License, or 0022 % (at your option) any later version. 0023 0024 global DATA; 0025 if isempty(DATA), 0026 error('No session defined (did you forget to call SetCurrentSession? Type ''help <a href="matlab:help Data">Data</a>'' for details).'); 0027 end 0028 0029 % Exclude clusters 0 and 1 (artefacts and noise) 0030 units = DATA.spikes(:,[2 3]); 0031 units = unique(units,'rows'); 0032 units = units(units(:,2)~=0&units(:,2)~=1,:); 0033 0034 if nargin > 0, 0035 if ~isivector(groups), 0036 error('Incorrect group list (type ''help <a href="matlab:help GetUnits">GetUnits</a>'' for details).'); 0037 end 0038 all = unique(units(:,1)); 0039 discard = all(~ismember(all,groups)); 0040 for i = 1:length(discard), 0041 units(units(:,1)==discard(i),:) = []; 0042 end 0043 end