Home > FMAToolbox > Analyses > SurveyTuningCurves.m

SurveyTuningCurves

PURPOSE ^

SurveyTuningCurves - Compute and plot tuning curves for all subsessions.

SYNOPSIS ^

function [curves,stats] = SurveyTuningCurves(units,varargin)

DESCRIPTION ^

SurveyTuningCurves - Compute and plot tuning curves for all subsessions.

  USAGE

    [curves,stats] = SurveyTuningCurves(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)
     'type'        'cartesian' (default) or 'polar' plot
     'show'        set to 'off' to compute but not plot data (default = 'on')
    =========================================================================

  OUTPUT

    The outputs are the same as for <a href="matlab:help MapStats">MapStats</a>, except for map.z which is
    replaced by map.rate.

  SEE

    See also FiringMap, PlotColorMap.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [curves,stats] = SurveyTuningCurves(units,varargin)
0002 
0003 %SurveyTuningCurves - Compute and plot tuning curves for all subsessions.
0004 %
0005 %  USAGE
0006 %
0007 %    [curves,stats] = SurveyTuningCurves(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 %     'type'        'cartesian' (default) or 'polar' plot
0019 %     'show'        set to 'off' to compute but not plot data (default = 'on')
0020 %    =========================================================================
0021 %
0022 %  OUTPUT
0023 %
0024 %    The outputs are the same as for <a href="matlab:help MapStats">MapStats</a>, except for map.z which is
0025 %    replaced by map.rate.
0026 %
0027 %  SEE
0028 %
0029 %    See also FiringMap, PlotColorMap.
0030 
0031 % Copyright (C) 2009-2013 by Anne Cei, Michaƫl Zugaro
0032 %
0033 % This program is free software; you can redistribute it and/or modify
0034 % it under the terms of the GNU General Public License as published by
0035 % the Free Software Foundation; either version 3 of the License, or
0036 % (at your option) any later version.
0037 
0038 % Default values
0039 minv = [];
0040 pixel = [];
0041 show = 'on';
0042 type = 'cartesian';
0043 
0044 % No unit list provided?
0045 if ~(nargin >= 1 && isimatrix(units)),
0046     units = GetUnits;
0047     varargin = {units,varargin{:}};
0048 else
0049     all = units(:,2) == -1;
0050     groups = unique(units(all,1));
0051     units(all,:) = [];
0052     units = unique([units;GetUnits(groups)],'rows');
0053 end
0054 nUnits = size(units,1);
0055 
0056 if mod(length(varargin),2) ~= 0,
0057     error('Incorrect number of parameters (type ''help <a href="matlab:help SurveyFiringMaps">SurveyFiringMaps</a>'' for details).');
0058 end
0059 
0060 % Parse options
0061 for i = 1:2:length(varargin),
0062     if ~ischar(varargin{i}),
0063         error(['Parameter ' num2str(i+1) ' is not a property (type ''help <a href="matlab:help SurveyFiringMaps">SurveyFiringMaps</a>'' for details).']);
0064     end
0065     switch(lower(varargin{i})),
0066         case 'minv',
0067             minv = varargin{i+1};
0068             if ~isdscalar(minv,'>=0'),
0069                 error('Incorrect value for property ''minv'' (type ''help <a href="matlab:help SurveyFiringMaps">SurveyFiringMaps</a>'' for details).');
0070             end
0071         case 'pixel',
0072             pixel = varargin{i+1};
0073             if ~isdscalar(pixel,'>0'),
0074                 error('Incorrect value for property ''pixel'' (type ''help <a href="matlab:help SurveyFiringMaps">SurveyFiringMaps</a>'' for details).');
0075             end
0076         case 'show',
0077             show = varargin{i+1};
0078             if ~isastring(show,'on','off'),
0079                 error('Incorrect value for property ''show'' (type ''help <a href="matlab:help SurveyFiringMaps">SurveyFiringMaps</a>'' for details).');
0080             end
0081         case 'type',
0082             type = varargin{i+1};
0083             if ~isastring(type,'polar','cartesian'),
0084                 error('Incorrect value for property ''type'' (type ''help <a href="matlab:help SurveyFiringMaps">SurveyFiringMaps</a>'' for details).');
0085             end
0086         otherwise,
0087             error(['Unknown property ''' num2str(varargin{i}) ''' (type ''help <a href="matlab:help SurveyFiringMaps">SurveyFiringMaps</a>'' for details).']);
0088     end
0089 end
0090 
0091 % Get positions
0092 positions = GetPositions;
0093 if isempty(positions), warning('No positions found for current subsession'); return; end
0094 if ~isempty(minv),
0095     if isempty(pixel),
0096         error('Missing pixel size for minimum velocity (type ''help <a href="matlab:help SurveyFiringMaps">SurveyFiringMaps</a>'' for details).');
0097     end
0098     x = GetPositions('coordinates','real','pixel',pixel);
0099     v = LinearVelocity(x,30);
0100     [~,in] = Threshold(v,'>',minv,'min',10,'max',2);
0101     positions = positions(in,:);
0102 
0103 end
0104 
0105 % Get angles and normalize in [0,1]
0106 angles = GetAngles;
0107 angles(:,2) = (angles(:,2)+pi)/(2*pi);
0108 
0109 % Get start/stop events for each subsession
0110 start = GetEvents('beginning of .*');
0111 stop = GetEvents('end of .*');
0112 nSubsessions = length(start);
0113 
0114 if strcmp(show,'on'),
0115     titles = GetEventTypes('beginning of .*');
0116     status = Hide('status');
0117     Hide('on');
0118     figureList = [];
0119 end
0120 
0121 try
0122     n = 0;
0123     % Loop through units
0124     for j = 1:nUnits,
0125         if strcmp(show,'on'), figureList = [figureList figure]; end
0126         spikes = GetSpikes(units(j,:));
0127         % Loop through subsessions
0128         for i = 1:nSubsessions,
0129             a = Restrict(angles,[start(i) stop(i)]);
0130             s = Restrict(spikes,[start(i) stop(i)]);
0131             if nargout == 0,
0132                 curve = FiringCurve(a,s,'nbins',120,'mintime',0,'type','cl');
0133             else
0134                 [curve,st] = FiringCurve(a,s,'nbins',120,'mintime',0,'type','cl');
0135                 st.unit = units(j,:);
0136                 st.subsession = i;
0137                 n = n + 1;
0138                 stats(n) = st;
0139                 curves(n) = curve;
0140             end
0141             if strcmp(show,'on'),
0142                 SquareSubplot(nSubsessions,i);
0143                 if strcmp(type,'cartesian'),
0144                     plot(curve.x,curve.rate);
0145                 else
0146                     polar(curve.x*2*pi,curve.rate);
0147                 end
0148                 title = titles{i}(14:end);
0149                 SplitTitle([title ' (' int2str(units(j,1)) '-' int2str(units(j,2)) ')'],round(150/sqrt(nSubsessions)));
0150             end
0151         end
0152     end
0153 catch err
0154     if strcmp(show,'on'),
0155         Hide(status);
0156         Hide(figureList,status);
0157     end
0158     err.rethrow;
0159 end
0160 
0161 if strcmp(show,'on'),
0162     Hide(status);
0163     Hide(figureList,status);
0164 end

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