FiringMap - Compute firing map (e.g. for a place cell). Compute firing map (e.g. for a place cell), as well as occupancy and spike count maps. Optionnally, field statistics can also be computed, including in-field peak and mean firing rates, firing field size, etc. USAGE [map,stats] = FiringMap(positions,spikes,<options>) positions position <a href="matlab:help samples">samples</a> spikes spike timestamps <options> optional list of property-value pairs (see table below) ========================================================================= Properties Values ------------------------------------------------------------------------- 'smooth' smoothing size in bins (0 = no smoothing, default = 2) 'nBins' number of horizontal and vertical bins (default = [50 50]) 'minTime' minimum time spent in each bin (in s, default = 0) 'mode' 'interpolate' to interpolate missing points (< minTime), or 'discard' to discard them (default) 'maxDistance' maximal distance for interpolation (default = 5) 'maxGap' z values recorded during time gaps between successive (x,y) samples exceeding this threshold (e.g. undetects) will not be interpolated; also, such long gaps in (x,y) sampling will be clipped to 'maxGap' to compute the occupancy map (default = 0.100 s) 'type' two letters (one for X and one for Y) indicating which coordinates are linear ('l') and which are circular ('c') (default 'll') 'threshold' values above threshold*peak belong to the field (default = 0.2) 'minSize' fields smaller than this size are considered spurious and ignored (default = 100) 'minPeak' peaks smaller than this size are considered spurious and ignored (default = 1) 'verbose' display processing information (default = 'off') ========================================================================= OUTPUT map.x x bins map.y y bins map.rate average firing rate map (in Hz) map.count spike count map map.time occupancy map (in s) stats.x abscissa of the peak rate (in bins) stats.y ordinate of the peak rate (in bins) stats.peak in-field peak rate stats.mean in-field mean value stats.size field size (in bins) stats.field field (1 = bin in field, 0 = bin not in field) stats.fieldX field x boundaries (in bins) stats.fieldY field y boundaries (in bins) stats.specificity spatial specificity (Skaggs et al., 1993) NOTE This function is provided for convenience. It simply calls <a href="matlab:help Map">Map</a> and <a href="matlab:help MapStats">MapStats</a> using the same parameters. The outputs are the same except for map.z which is replaced by map.rate. SEE See also Map, MapStats, FiringCurve, PlotColorMap.
0001 function [map,stats] = FiringMap(positions,spikes,varargin) 0002 0003 %FiringMap - Compute firing map (e.g. for a place cell). 0004 % 0005 % Compute firing map (e.g. for a place cell), as well as occupancy and spike 0006 % count maps. Optionnally, field statistics can also be computed, including 0007 % in-field peak and mean firing rates, firing field size, etc. 0008 % 0009 % USAGE 0010 % 0011 % [map,stats] = FiringMap(positions,spikes,<options>) 0012 % 0013 % positions position <a href="matlab:help samples">samples</a> 0014 % spikes spike timestamps 0015 % <options> optional list of property-value pairs (see table below) 0016 % 0017 % ========================================================================= 0018 % Properties Values 0019 % ------------------------------------------------------------------------- 0020 % 'smooth' smoothing size in bins (0 = no smoothing, default = 2) 0021 % 'nBins' number of horizontal and vertical bins (default = [50 50]) 0022 % 'minTime' minimum time spent in each bin (in s, default = 0) 0023 % 'mode' 'interpolate' to interpolate missing points (< minTime), 0024 % or 'discard' to discard them (default) 0025 % 'maxDistance' maximal distance for interpolation (default = 5) 0026 % 'maxGap' z values recorded during time gaps between successive (x,y) 0027 % samples exceeding this threshold (e.g. undetects) will not 0028 % be interpolated; also, such long gaps in (x,y) sampling 0029 % will be clipped to 'maxGap' to compute the occupancy map 0030 % (default = 0.100 s) 0031 % 'type' two letters (one for X and one for Y) indicating which 0032 % coordinates are linear ('l') and which are circular ('c') 0033 % (default 'll') 0034 % 'threshold' values above threshold*peak belong to the field 0035 % (default = 0.2) 0036 % 'minSize' fields smaller than this size are considered spurious 0037 % and ignored (default = 100) 0038 % 'minPeak' peaks smaller than this size are considered spurious 0039 % and ignored (default = 1) 0040 % 'verbose' display processing information (default = 'off') 0041 % ========================================================================= 0042 % 0043 % OUTPUT 0044 % 0045 % map.x x bins 0046 % map.y y bins 0047 % map.rate average firing rate map (in Hz) 0048 % map.count spike count map 0049 % map.time occupancy map (in s) 0050 % 0051 % stats.x abscissa of the peak rate (in bins) 0052 % stats.y ordinate of the peak rate (in bins) 0053 % stats.peak in-field peak rate 0054 % stats.mean in-field mean value 0055 % stats.size field size (in bins) 0056 % stats.field field (1 = bin in field, 0 = bin not in field) 0057 % stats.fieldX field x boundaries (in bins) 0058 % stats.fieldY field y boundaries (in bins) 0059 % stats.specificity spatial specificity (Skaggs et al., 1993) 0060 % 0061 % NOTE 0062 % 0063 % This function is provided for convenience. It simply calls <a href="matlab:help Map">Map</a> and <a href="matlab:help MapStats">MapStats</a> 0064 % using the same parameters. The outputs are the same except for map.z which 0065 % is replaced by map.rate. 0066 % 0067 % SEE 0068 % 0069 % See also Map, MapStats, FiringCurve, PlotColorMap. 0070 0071 % Copyright (C) 2004-2013 by Michaƫl Zugaro 0072 % 0073 % This program is free software; you can redistribute it and/or modify 0074 % it under the terms of the GNU General Public License as published by 0075 % the Free Software Foundation; either version 3 of the License, or 0076 % (at your option) any later version. 0077 0078 % Check number of parameters 0079 if nargin < 2, 0080 error('Incorrect number of parameters (type ''help <a href="matlab:help FiringMap">FiringMap</a>'' for details).'); 0081 end 0082 0083 if size(positions,2) ~= 3, 0084 warning('Parameter ''positions'' is not a Nx3 matrix - using the first light.'); 0085 positions = positions(:,1:3); 0086 end 0087 0088 im = 1;argsm = {}; 0089 is = 1;argss = {}; 0090 % Parse parameter list 0091 for i = 1:2:length(varargin), 0092 if ~ischar(varargin{i}), 0093 error(['Parameter ' num2str(i+2) ' is not a property (type ''help <a href="matlab:help FiringMap">FiringMap</a>'' for details).']); 0094 end 0095 switch(lower(varargin{i})), 0096 case 'type', 0097 argss{is} = 'type'; 0098 argss{is+1} = varargin{i+1}(1:2); 0099 is = is+2; 0100 argsm{im} = 'type'; 0101 argsm{im+1} = [varargin{i+1}(1:2) 'l']; 0102 im = im+2; 0103 case {'threshold','minsize','minpeak','verbose','debug'}, 0104 argss{is} = varargin{i}; 0105 argss{is+1} = varargin{i+1}; 0106 is = is+2; 0107 otherwise, 0108 argsm{im} = varargin{i}; 0109 argsm{im+1} = varargin{i+1}; 0110 im = im+2; 0111 end 0112 end 0113 0114 map = Map(positions,spikes,argsm{:}); 0115 if nargout == 2, 0116 stats = MapStats(map,argss{:}); 0117 end 0118 map.rate = map.z; 0119 map = rmfield(map,'z');