Home > FMAToolbox > Analyses > SurveyFiringMaps.m

SurveyFiringMaps

PURPOSE ^

SurveyFiringMaps - Compute and plot firing maps for all subsessions.

SYNOPSIS ^

function [maps,stats] = SurveyFiringMaps(units,varargin)

DESCRIPTION ^

SurveyFiringMaps - Compute and plot firing maps for all subsessions.

  USAGE

    [maps,stats] = SurveyFiringMaps(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')
    =========================================================================

  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 [maps,stats] = SurveyFiringMaps(units,varargin)
0002 
0003 %SurveyFiringMaps - Compute and plot firing maps for all subsessions.
0004 %
0005 %  USAGE
0006 %
0007 %    [maps,stats] = SurveyFiringMaps(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 %    =========================================================================
0020 %
0021 %  OUTPUT
0022 %
0023 %    The outputs are the same as for <a href="matlab:help MapStats">MapStats</a>, except for map.z which is
0024 %    replaced by map.rate.
0025 %
0026 %  SEE
0027 %
0028 %    See also FiringMap, PlotColorMap.
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 
0042 % No unit list provided?
0043 if ~(nargin >= 1 && isimatrix(units)),
0044     units = GetUnits;
0045     varargin = {units,varargin{:}};
0046 else
0047     all = units(:,2) == -1;
0048     groups = unique(units(all,1));
0049     units(all,:) = [];
0050     units = unique([units;GetUnits(groups)],'rows');
0051 end
0052 nUnits = size(units,1);
0053 
0054 if mod(length(varargin),2) ~= 0,
0055     error('Incorrect number of parameters (type ''help <a href="matlab:help SurveyFiringMaps">SurveyFiringMaps</a>'' for details).');
0056 end
0057 
0058 % Parse options
0059 for i = 1:2:length(varargin),
0060     if ~ischar(varargin{i}),
0061         error(['Parameter ' num2str(i+1) ' is not a property (type ''help <a href="matlab:help SurveyFiringMaps">SurveyFiringMaps</a>'' for details).']);
0062     end
0063     switch(lower(varargin{i})),
0064         case 'minv',
0065             minv = varargin{i+1};
0066             if ~isdscalar(minv,'>=0'),
0067                 error('Incorrect value for property ''minv'' (type ''help <a href="matlab:help SurveyFiringMaps">SurveyFiringMaps</a>'' for details).');
0068             end
0069         case 'pixel',
0070             pixel = varargin{i+1};
0071             if ~isdscalar(pixel,'>0'),
0072                 error('Incorrect value for property ''pixel'' (type ''help <a href="matlab:help SurveyFiringMaps">SurveyFiringMaps</a>'' for details).');
0073             end
0074         case 'show',
0075             show = varargin{i+1};
0076             if ~isastring(show,'on','off'),
0077                 error('Incorrect value for property ''show'' (type ''help <a href="matlab:help SurveyFiringMaps">SurveyFiringMaps</a>'' for details).');
0078             end
0079         otherwise,
0080             error(['Unknown property ''' num2str(varargin{i}) ''' (type ''help <a href="matlab:help SurveyFiringMaps">SurveyFiringMaps</a>'' for details).']);
0081     end
0082 end
0083 
0084 % Get positions
0085 positions = GetPositions;
0086 if isempty(positions), warning('No positions found for current subsession'); return; end
0087 if ~isempty(minv),
0088     if isempty(pixel),
0089         error(['Missing pixel size for minimum velocity (type ''help <a href="matlab:help SurveyFiringMaps">SurveyFiringMaps</a>'' for details).']);
0090     end
0091     x = GetPositions('coordinates','real','pixel',pixel);
0092     v = LinearVelocity(x,30);
0093     [~,in] = Threshold(v,'>',minv,'min',10,'max',2);
0094     positions = positions(in,:);
0095 end
0096 
0097 % Get start/stop events for each subsession
0098 start = GetEvents('beginning of .*');
0099 stop = GetEvents('end of .*');
0100 nSubsessions = length(start);
0101 
0102 if strcmp(show,'on'),
0103     titles = GetEventTypes('beginning of .*');
0104     status = Hide('status');
0105     Hide('on');
0106     figureList = [];
0107 end
0108 
0109 try
0110     n = 0;
0111     % Loop through units
0112     for j = 1:nUnits,
0113         if strcmp(show,'on'), figureList = [figureList figure]; end
0114         spikes = GetSpikes(units(j,:));
0115         % Loop through subsessions
0116         for i = 1:nSubsessions,
0117             p = Restrict(positions,[start(i) stop(i)]);
0118             s = Restrict(spikes,[start(i) stop(i)]);
0119             if nargin == 0,
0120                 map = FiringMap(p(:,1:3),s,'nbins',[250 250],'smooth',5,'mintime',0);
0121             else
0122                 [map,st] = FiringMap(p(:,1:3),s,'nbins',[250 250],'smooth',5,'mintime',0);
0123                 st.unit = units(j,:);
0124                 st.subsession = i;
0125                 n = n + 1;
0126                 stats(n) = st;
0127                 maps(n) = map;
0128             end
0129             if strcmp(show,'on'),
0130                 SquareSubplot(nSubsessions,i);
0131                 PlotColorMap(map.rate,map.time,'ydir','reverse','bar','off','cutoffs',[0 10],'gamma',2);
0132                 title = titles{i}(14:end);
0133                 SplitTitle([title ' (' int2str(units(j,1)) '-' int2str(units(j,2)) ')'],round(150/sqrt(nSubsessions)));
0134             end
0135         end
0136     end
0137 catch err
0138     if strcmp(show,'on'),
0139         Hide(status);
0140         Hide(figureList,status);
0141     end
0142     err.rethrow;
0143 end
0144 
0145 if strcmp(show,'on'),
0146     Hide(status);
0147     Hide(figureList,status);
0148 end

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