Home > FMAToolbox > Data > GetChannels.m

GetChannels

PURPOSE ^

GetChannels - Get list of channels for one or more spike groups.

SYNOPSIS ^

function [channels,groups] = GetChannels(groups)

DESCRIPTION ^

GetChannels - Get list of channels for one or more spike groups.

  USAGE

    channels = GetChannels(groups)

    groups         one or more optional electrode groups (default = all groups)

  EXAMPLES

    all = GetChannels;           % list all channels
    channels = GetChannels(2);   % list all channels for electrode group 2

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [channels,groups] = GetChannels(groups)
0002 
0003 %GetChannels - Get list of channels for one or more spike groups.
0004 %
0005 %  USAGE
0006 %
0007 %    channels = GetChannels(groups)
0008 %
0009 %    groups         one or more optional electrode groups (default = all groups)
0010 %
0011 %  EXAMPLES
0012 %
0013 %    all = GetChannels;           % list all channels
0014 %    channels = GetChannels(2);   % list all channels for electrode group 2
0015 
0016 
0017 % Copyright (C) 2004-2018 by Michaƫl Zugaro, 2018 by Ralitsa Todorova
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 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 % Provide information about the group of each channel
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

Generated on Fri 16-Mar-2018 13:00:20 by m2html © 2005