0001 function [channels,groups] = GetChannels(groups)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
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 nGroups = DATA.spikeGroups.nGroups;
0030 if nargin < 1,
0031 groups = 1:nGroups;
0032 else
0033 if ~isivector(groups,'>0',['<=' int2str(nGroups)]),
0034 error('Incorrect group list (type ''help <a href="matlab:help GetChannels">GetChannels</a>'' for details).');
0035 end
0036 end
0037
0038 channels = [DATA.spikeGroups.groups{groups}]';
0039
0040
0041 if nargout > 1,
0042 nChannelsPerGroup = cellfun(@length,DATA.spikeGroups.groups)';
0043 nChannelsPerGroup = nChannelsPerGroup(groups);
0044 if ~isempty(which('repelem')),
0045 groups = repelem(groups',nChannelsPerGroup);
0046 else
0047 g = [];
0048 for i = 1:length(groups), g = [g; ones(nChannelsPerGroup(i),1)*groups(i)]; end
0049 groups = g;
0050 end
0051 end