Home > FMAToolbox > Analyses > SurveyCCG.m

SurveyCCG

PURPOSE ^

SurveyCCG - Compute and plot cross-correlograms (CCGs) for all subsessions.

SYNOPSIS ^

function [data,t] = SurveyCCG(units,varargin)

DESCRIPTION ^

SurveyCCG - Compute and plot cross-correlograms (CCGs) for all subsessions.

  USAGE

    [data,t] = SurveyCCG(units,<options>)

    units          optional list of units, i.e. [electrode group, cluster]
                   pairs; set cluster to -1 to process all clusters
    <options>      optional list of property-value pairs (see table below)

    =========================================================================
     Properties    Values
    -------------------------------------------------------------------------
     'minv'        minimum instantaneous velocity (default = 0)
     'pixel'       size of the video pixel in cm (no default value)
     'show'        set to 'off' to compute but not plot data (default = 'on')
     'duration'    duration in s of each xcorrelogram (default = 1)
    =========================================================================

  OUTPUT

    The outputs are the same as for <a href="matlab:help CCG">CCG</a>.

  SEE

    See also CCG, SurveyFiringMaps, SurveyPhasePrecession.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [data,t] = SurveyCCG(units,varargin)
0002 
0003 %SurveyCCG - Compute and plot cross-correlograms (CCGs) for all subsessions.
0004 %
0005 %  USAGE
0006 %
0007 %    [data,t] = SurveyCCG(units,<options>)
0008 %
0009 %    units          optional list of units, i.e. [electrode group, cluster]
0010 %                   pairs; set cluster to -1 to process all clusters
0011 %    <options>      optional list of property-value pairs (see table below)
0012 %
0013 %    =========================================================================
0014 %     Properties    Values
0015 %    -------------------------------------------------------------------------
0016 %     'minv'        minimum instantaneous velocity (default = 0)
0017 %     'pixel'       size of the video pixel in cm (no default value)
0018 %     'show'        set to 'off' to compute but not plot data (default = 'on')
0019 %     'duration'    duration in s of each xcorrelogram (default = 1)
0020 %    =========================================================================
0021 %
0022 %  OUTPUT
0023 %
0024 %    The outputs are the same as for <a href="matlab:help CCG">CCG</a>.
0025 %
0026 %  SEE
0027 %
0028 %    See also CCG, SurveyFiringMaps, SurveyPhasePrecession.
0029 
0030 % Copyright (C) 2009-2013 by Anne Cei, Michaƫl Zugaro
0031 %
0032 % This program is free software; you can redistribute it and/or modify
0033 % it under the terms of the GNU General Public License as published by
0034 % the Free Software Foundation; either version 3 of the License, or
0035 % (at your option) any later version.
0036 
0037 % Default values
0038 minv = [];
0039 pixel = [];
0040 show = 'on';
0041 duration = 1;
0042 
0043 % No unit list provided?
0044 if ~(nargin >= 1 && isimatrix(units)),
0045     units = GetUnits;
0046     varargin = {units,varargin{:}};
0047 else
0048     all = units(:,2) == -1;
0049     groups = unique(units(all,1));
0050     units(all,:) = [];
0051     units = unique([units;GetUnits(groups)],'rows');
0052 end
0053 nUnits = size(units,1);
0054 
0055 if mod(length(varargin),2) ~= 0,
0056     error('Incorrect number of parameters (type ''help <a href="matlab:help SurveyCCG">SurveyCCG</a>'' for details).');
0057 end
0058 
0059 % Parse options
0060 for i = 1:2:length(varargin),
0061     if ~ischar(varargin{i}),
0062         error(['Parameter ' num2str(i+1) ' is not a property (type ''help <a href="matlab:help SurveyCCG">SurveyCCG</a>'' for details).']);
0063     end
0064     switch(lower(varargin{i})),
0065         case 'minv',
0066             minv = varargin{i+1};
0067             if ~isdscalar(minv,'>=0'),
0068                 error('Incorrect value for property ''minv'' (type ''help <a href="matlab:help SurveyCCG">SurveyCCG</a>'' for details).');
0069             end
0070         case 'pixel',
0071             pixel = varargin{i+1};
0072             if ~isdscalar(pixel,'>0'),
0073                 error('Incorrect value for property ''pixel'' (type ''help <a href="matlab:help SurveyCCG">SurveyCCG</a>'' for details).');
0074             end
0075         case 'show',
0076             show = varargin{i+1};
0077             if ~isastring(show,'on','off'),
0078                 error('Incorrect value for property ''show'' (type ''help <a href="matlab:help SurveyCCG">SurveyCCG</a>'' for details).');
0079             end
0080         case 'duration',
0081             duration = varargin{i+1};
0082             if ~isdscalar(duration,'>0'),
0083                 error('Incorrect value for property ''duration'' (type ''help <a href="matlab:help SurveyCCG">SurveyCCG</a>'' for details).');
0084             end
0085         otherwise,
0086             error(['Unknown property ''' num2str(varargin{i}) ''' (type ''help <a href="matlab:help SurveyCCG">SurveyCCG</a>'' for details).']);
0087     end
0088 end
0089 
0090 % Get spikes (with unit IDs)
0091 spikes = GetSpikes(units,'output','full');
0092 
0093 % Get positions, compute velocity and discard spikes during slow periods
0094 positions = GetPositions;
0095 if isempty(positions), warning('No positions found for current session'); return; end
0096 if ~isempty(minv),
0097     if isempty(pixel),
0098         error(['Missing pixel size for minimum velocity (type ''help <a href="matlab:help SurveyCCG">SurveyCCG</a>'' for details).']);
0099     end
0100     x = GetPositions('coordinates','real','pixel',pixel);
0101     x = Interpolate(x,spikes(:,1));
0102     v = LinearVelocity(x,30);
0103     [~,in] = Threshold(v,'>',minv,'min',10,'max',10);
0104     spikes = spikes(in,:);
0105 end
0106 
0107 % Get start/stop events for each subsession
0108 start = GetEvents('beginning of .*');
0109 stop = GetEvents('end of .*');
0110 nSubsessions = length(start);
0111 
0112 % Number units from 1 to n
0113 n = size(units,1);
0114 groups = ones(size(spikes(:,1)));
0115 for i = 1:n,
0116     this = spikes(:,2)==units(i,1)&spikes(:,3)==units(i,2);
0117     groups(this) = i;
0118 end
0119 spikes = spikes(:,1);
0120 
0121 if strcmp(show,'on'),
0122     titles = GetEventTypes('beginning of .*');
0123     status = Hide('status');
0124     Hide('on');
0125     figureList = [];
0126 end
0127 
0128 try
0129     % Loop through subsessions
0130     for i = 1:nSubsessions,
0131         if strcmp(show,'on'), figureList = [figureList figure]; end
0132         in = InIntervals(spikes,[start(i) stop(i)]);
0133         s = spikes(in);
0134         g = groups(in);
0135         [ccg,t] = CCG(s,g,'binSize',duration/30,'duration',duration);
0136         d.ccg = ccg;
0137         d.subsession = i;
0138         data(i) = d;
0139         if strcmp(show,'on'),
0140             PlotCCG(t,ccg);
0141             subplot(n,n,n*n);
0142             axis off;
0143             title(titles{i}(14:end));
0144         end
0145     end
0146 catch err
0147     if strcmp(show,'on'),
0148         Hide(status);
0149         Hide(figureList,status);
0150     end
0151     err.rethrow;
0152 end
0153 
0154 if strcmp(show,'on'),
0155     Hide(status);
0156     Hide(figureList,status);
0157 end

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