Home > chronux_1_1 > spikesort > utility > datatools > histxt.m

histxt

PURPOSE ^

HISTXT Column-by-column Histograms.

SYNOPSIS ^

function [counts,t_inds,x_inds] = histxt(x, varargin)

DESCRIPTION ^

HISTXT            Column-by-column Histograms.
   COUNTS = HISTXT(X,D), where X is an M x T matrix returns a D x T
   matrix COUNTS in which each column contains the histogrammed (with D
   bins) values from the corresponding column in X.  If D is not
   specified (or is the empty matrix), it defaults to 100.

   [COUNTS,T_INDS,X_INDS] = HISTXT(X,D) returns the column indices and
   bin centers so that the density can be visualized with
   IMAGESC(T_INDS,X_INDS,COUNTS).

   [...] = HISTXT(...,'log') uses the log of the counts (0's yield -Inf).

   HISTXT(...) without output arguments produces an image of the counts.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [counts,t_inds,x_inds] = histxt(x, varargin)
0002 %HISTXT            Column-by-column Histograms.
0003 %   COUNTS = HISTXT(X,D), where X is an M x T matrix returns a D x T
0004 %   matrix COUNTS in which each column contains the histogrammed (with D
0005 %   bins) values from the corresponding column in X.  If D is not
0006 %   specified (or is the empty matrix), it defaults to 100.
0007 %
0008 %   [COUNTS,T_INDS,X_INDS] = HISTXT(X,D) returns the column indices and
0009 %   bin centers so that the density can be visualized with
0010 %   IMAGESC(T_INDS,X_INDS,COUNTS).
0011 %
0012 %   [...] = HISTXT(...,'log') uses the log of the counts (0's yield -Inf).
0013 %
0014 %   HISTXT(...) without output arguments produces an image of the counts.
0015 
0016 %%%%%%%%%%%%%%%%%%%%%%%%%%%% Parse Inputs %%%%%%%%%%%%%%%%%%%%%%%%%%%%
0017 D = 100;  logflag = 0;                        % defaults
0018 
0019 [M,T] = size(x);
0020 if (~isnumeric(x) || ndims(x)~=2)
0021     error('First input argument must be a 2-D numeric matrix.');
0022 end
0023 
0024 if (length(varargin) > 0)
0025     tail = varargin{end};
0026     if (ischar(tail) && strcmpi(tail,'log'))  % If the last arg was 'log' ...
0027         varargin = varargin(1:(end-1));       % ... chomp it and set a flag.
0028         logflag = 1;
0029     end
0030     if (length(varargin) > 0)
0031         tail = varargin{end};
0032         if (isnumeric(tail) && length(tail)==1)   % If next to last arg was a scalar, ...
0033             varargin = varargin(1:end-1);         % ... chomp it and set the bin count.
0034             D = tail;
0035         end
0036     end
0037     if (length(varargin) > 0),  error('Unknown syntax.');  end;
0038 end
0039 
0040 
0041 %%%%%%%%%%%%%%%%%%%%%%%%%%%% Rescale Data %%%%%%%%%%%%%%%%%%%%%%%%%%%%
0042 % Scale the data
0043 [x,oldmin,oldmax] = rescale(x,1,D);  x = round(x);
0044 
0045 % Make bin centers/column indices
0046 x_inds = linspace(oldmin,oldmax,D);
0047 t_inds = 1:T;
0048 
0049 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Histogram %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0050 counts = CORE_histxt(x,D);
0051 
0052 if (logflag)
0053     old = warning('off');   counts = log(counts);   warning(old);
0054 end
0055 
0056 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Graphics %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0057 if (nargout == 0)
0058      imagesc(t_inds, x_inds, counts);   axis xy;
0059      clear counts t_inds x_inds  % clear these so nothing is dumped to output
0060 end

Generated on Sun 13-Aug-2006 11:49:44 by m2html © 2003