Home > FMAToolbox > Analyses > CCGParameters.m

CCGParameters

PURPOSE ^

CCGParameters - Reformat time series for CCG computation

SYNOPSIS ^

function [times,id,group] = CCGParameters(varargin)

DESCRIPTION ^

CCGParameters - Reformat time series for CCG computation

  USAGE

    [times,id,group] = CCGParameters(series1,group1,series2,group2,...)

    series1...     time series (one column) with optional IDs (in the second
                   column, such as obtained from <a href="matlab:help GetSpikes">GetSpikes</a>, see <a href="matlab:help CCG">CCG</a>)
    group1...      optional group number for each series

  SEE

    See also CCG.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [times,id,group] = CCGParameters(varargin)
0002 
0003 %CCGParameters - Reformat time series for CCG computation
0004 %
0005 %  USAGE
0006 %
0007 %    [times,id,group] = CCGParameters(series1,group1,series2,group2,...)
0008 %
0009 %    series1...     time series (one column) with optional IDs (in the second
0010 %                   column, such as obtained from <a href="matlab:help GetSpikes">GetSpikes</a>, see <a href="matlab:help CCG">CCG</a>)
0011 %    group1...      optional group number for each series
0012 %
0013 %  SEE
0014 %
0015 %    See also CCG.
0016 
0017 % Copyright (C) 2013 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 % Check parameters
0025 if nargin < 2,
0026   error('Incorrect number of parameters (type ''help <a href="matlab:help CCGParameters">CCGParameters</a>'' for details).');
0027 end
0028 
0029 data = [];
0030 
0031 % Parse parameter list
0032 i = 1;
0033 while i <= length(varargin),
0034 
0035     % Time series i (and optional IDs)
0036     times = varargin{i};
0037     i = i + 1;
0038     if ~isdvector(times) && ~(isdmatrix(times) && size(times,2) == 2),
0039         error(['Incorrect time series at parameter #' int2str(i) ' (type ''help <a href="matlab:help CCGParameters">CCGParameters</a>'' for details).']);
0040     end
0041     if size(times,2) > 1,
0042         id = times(:,2);
0043         if ~isivector(id,'>0'),
0044             error(['Incorrect time series at parameter #' int2str(i) ' (type ''help <a href="matlab:help CCGParameters">CCGParameters</a>'' for details).']);
0045         end
0046     else
0047         id = ones(size(times(:,1)));
0048     end
0049     if length(unique(id)) ~= max(id),
0050         error('Incorrect IDs (type ''help <a href="matlab:help CCGParameters">CCGParameters</a>'' for details).');
0051     end
0052     times = times(:,1);
0053     
0054     % Groups i
0055     if i > length(varargin),
0056         group = ones(size(id));
0057     else
0058         group = varargin{i};
0059         % Is this a group, or the next time series?
0060         if ~isivector(group) || (any(group>1) && any(group>2)),
0061             group = ones(size(id));
0062         else
0063             if length(group) == 1,
0064                 group = repmat(group,size(id),1);
0065             elseif length(group) ~= length(id),
0066                 error(['Incorrect groups at parameter #' int2str(i) ' (type ''help <a href="matlab:help CCGParameters">CCGParameters</a>'' for details).']);
0067             end
0068             i = i + 1;
0069         end
0070     end
0071     group = group(:);
0072     
0073     % Concatenate with previous times series, IDs and groups
0074     if ~isempty(data), id = id+max(data(:,2)); end
0075     data = [data ; times id group];
0076 
0077 end
0078 
0079 times = data(:,1);
0080 id = data(:,2);
0081 group = data(:,3);

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