Home > FMAToolbox > Plot > PlotColorMap.m

PlotColorMap

PURPOSE ^

PlotColorMap - Plot a color map.

SYNOPSIS ^

function PlotColorMap(data,dimm,varargin)

DESCRIPTION ^

PlotColorMap - Plot a color map.

  Plot a color map (e.g. the firing field of a place cell).

  USAGE

    PlotColorMap(data,dimm,<options>)

    data           data
    dimm           optional luminance map
    <options>      optional list of property-value pairs (see table below)

    =========================================================================
     Properties    Values
    -------------------------------------------------------------------------
     'x'           abscissae
     'y'           ordinates
     'threshold'   dimm values below this limit are zeroed (default = 0.01)
     'cutoffs'     lower and upper cutoff values ([] = autoscale, default)
     'hgamma'      gamma-like correction for hue (1 = no correction, default)
     'colorspace'  'HSV' or 'RGB' (default = 'RGB')
     'bar'         draw a color bar (default = 'off')
     'type'        either 'linear' or 'circular' (default 'linear')
     'ydir'        either 'normal' (default) or 'reverse' (useful when the
                   x and y coordinates correspond to spatial positions,
                   as video cameras measure y in reverse direction)
    =========================================================================

  NOTE

    The luminance map is used to dimm the color map. A single scalar value
    is interpreted as a constant luminance map. If this parameter is not
    provided, normal equiluminance is assumed (i.e. scalar value of 1).

  EXAMPLE

    fm = FiringMap(positions,spikes);      % firing map for a place cell
    figure;PlotColorMap(fm.rate,fm.time);  % plot, dimming with occupancy map

  SEE

    See also FiringMap, PhaseMap, MTSpectrogram, PlotShortTimeCCG.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function PlotColorMap(data,dimm,varargin)
0002 
0003 %PlotColorMap - Plot a color map.
0004 %
0005 %  Plot a color map (e.g. the firing field of a place cell).
0006 %
0007 %  USAGE
0008 %
0009 %    PlotColorMap(data,dimm,<options>)
0010 %
0011 %    data           data
0012 %    dimm           optional luminance map
0013 %    <options>      optional list of property-value pairs (see table below)
0014 %
0015 %    =========================================================================
0016 %     Properties    Values
0017 %    -------------------------------------------------------------------------
0018 %     'x'           abscissae
0019 %     'y'           ordinates
0020 %     'threshold'   dimm values below this limit are zeroed (default = 0.01)
0021 %     'cutoffs'     lower and upper cutoff values ([] = autoscale, default)
0022 %     'hgamma'      gamma-like correction for hue (1 = no correction, default)
0023 %     'colorspace'  'HSV' or 'RGB' (default = 'RGB')
0024 %     'bar'         draw a color bar (default = 'off')
0025 %     'type'        either 'linear' or 'circular' (default 'linear')
0026 %     'ydir'        either 'normal' (default) or 'reverse' (useful when the
0027 %                   x and y coordinates correspond to spatial positions,
0028 %                   as video cameras measure y in reverse direction)
0029 %    =========================================================================
0030 %
0031 %  NOTE
0032 %
0033 %    The luminance map is used to dimm the color map. A single scalar value
0034 %    is interpreted as a constant luminance map. If this parameter is not
0035 %    provided, normal equiluminance is assumed (i.e. scalar value of 1).
0036 %
0037 %  EXAMPLE
0038 %
0039 %    fm = FiringMap(positions,spikes);      % firing map for a place cell
0040 %    figure;PlotColorMap(fm.rate,fm.time);  % plot, dimming with occupancy map
0041 %
0042 %  SEE
0043 %
0044 %    See also FiringMap, PhaseMap, MTSpectrogram, PlotShortTimeCCG.
0045 
0046 % Copyright (C) 2004-2012 by Michaƫl Zugaro
0047 %
0048 % This program is free software; you can redistribute it and/or modify
0049 % it under the terms of the GNU General Public License as published by
0050 % the Free Software Foundation; either version 3 of the License, or
0051 % (at your option) any later version.
0052 
0053 % Default values
0054 cutoffs = [];
0055 hgamma = 1;
0056 gamma = 1;
0057 hg = 0;
0058 colorspace = 'rgb';
0059 threshold = 0.01;
0060 drawBar = 0;
0061 type = 'linear';
0062 [y,x] = size(data);
0063 x = 1:x;y = 1:y;
0064 ydir = 'normal';
0065 
0066 % Check parameters
0067 if nargin < 1,
0068     error('Incorrect number of parameters (type ''help <a href="matlab:help PlotColorMap">PlotColorMap</a>'' for details).');
0069 end
0070 if nargin == 1,
0071     dimm = 1;
0072 end
0073 if isa(dimm,'char'),
0074     varargin = {dimm varargin{:}};
0075     dimm = 1;
0076 end
0077 
0078 % Parse parameter list
0079 for i = 1:2:length(varargin),
0080     if ~ischar(varargin{i}),
0081         error(['Parameter ' num2str(i+2) ' is not a property (type ''help <a href="matlab:help PlotColorMap">PlotColorMap</a>'' for details).']);
0082     end
0083     switch(lower(varargin{i})),
0084 
0085         case 'threshold',
0086             threshold = varargin{i+1};
0087             if ~isdscalar(threshold,'>=0'),
0088                 error('Incorrect value for property ''threshold'' (type ''help <a href="matlab:help PlotColorMap">PlotColorMap</a>'' for details).');
0089             end
0090         case 'x',
0091             x = varargin{i+1};
0092             if ~isdvector(x),
0093                 error('Incorrect value for property ''x'' (type ''help <a href="matlab:help PlotColorMap">PlotColorMap</a>'' for details).');
0094             end
0095         case 'y',
0096             y = varargin{i+1};
0097             if ~isdvector(y),
0098                 error('Incorrect value for property ''y'' (type ''help <a href="matlab:help PlotColorMap">PlotColorMap</a>'' for details).');
0099             end
0100         case 'cutoffs',
0101             cutoffs = varargin{i+1};
0102             if ~isdvector(cutoffs,'#2','<') & ~isempty(cutoffs),
0103                 error('Incorrect value for property ''cutoffs'' (type ''help <a href="matlab:help PlotColorMap">PlotColorMap</a>'' for details).');
0104             end
0105         case 'hgamma',
0106             hg = 1;
0107             hgamma = varargin{i+1};
0108             if ~isdscalar(hgamma,'>=0'),
0109                 error('Incorrect value for property ''hgamma'' (type ''help <a href="matlab:help PlotColorMap">PlotColorMap</a>'' for details).');
0110             end
0111         case 'gamma',
0112             gamma = varargin{i+1};
0113             if ~isdscalar(gamma,'>=0'),
0114                 error('Incorrect value for deprecated property ''gamma'' (type ''help <a href="matlab:help PlotColorMap">PlotColorMap</a>'' for details).');
0115             end
0116         case 'colorspace',
0117             colorspace = lower(varargin{i+1});
0118             if ~isastring(colorspace,'hsv','rgb'),
0119                 error('Incorrect value for property ''colorspace'' (type ''help <a href="matlab:help PlotColorMap">PlotColorMap</a>'' for details).');
0120             end
0121         case 'bar',
0122             drawBar = lower(varargin{i+1});
0123             if ~isastring(drawBar,'on','off'),
0124                 error('Incorrect value for property ''bar'' (type ''help <a href="matlab:help PlotColorMap">PlotColorMap</a>'' for details).');
0125             end
0126         case 'type',
0127             type = lower(varargin{i+1});
0128             if ~isastring(type,'linear','circular'),
0129                 error('Incorrect value for property ''type'' (type ''help <a href="matlab:help PlotColorMap">PlotColorMap</a>'' for details).');
0130             end
0131         case 'ydir',
0132             ydir = lower(varargin{i+1});
0133             if ~isastring(ydir,'normal','reverse'),
0134                 error('Incorrect value for property ''ydir'' (type ''help <a href="matlab:help PlotColorMap">PlotColorMap</a>'' for details).');
0135             end
0136         otherwise,
0137             error(['Unknown property ''' num2str(varargin{i}) ''' (type ''help <a href="matlab:help PlotColorMap">PlotColorMap</a>'' for details).']);
0138 
0139     end
0140 end
0141 
0142 % Special defaults
0143 x = x(:);
0144 y = y(:);
0145 if hg == 0,
0146     hgamma = 1/gamma;
0147 end
0148 if ~isempty(cutoffs),
0149     m = cutoffs(1);
0150     M = cutoffs(2);
0151 else
0152     m = min(min(data));
0153     M = max(max(data));
0154 end
0155 if m == M, M = m+1; end
0156 if isnan(m), m = 0; M = 1; end
0157 if length(dimm) == 1,
0158     dimm = dimm*ones(size(data));
0159 end
0160 
0161 f = gcf;
0162 a = gca;
0163 
0164 % Plot data
0165 data = squeeze(data);
0166 dimm = squeeze(dimm);
0167 p = imagesc(x,y,data,[m M]);
0168 set(a,'color',[0 0 0]);
0169 if any(dimm(:)~=1),
0170     alpha(p,1./(1+threshold./(dimm+eps)));
0171 end
0172 
0173 % Set X and Y axes
0174 set(a,'ydir',ydir,'tickdir','out','box','off');
0175 if ~isempty(x) && length(x) ~= 1,
0176     PiecewiseLinearAxis(x);
0177 end
0178 if ~isempty(y) && length(y) ~= 1,
0179     PiecewiseLinearAxis(y,'y');
0180 end
0181 
0182 % Color map and bar
0183 colormap(Bright(100,'hgamma',hgamma,'type',type));
0184 if strcmp(drawBar,'on'),
0185     b = colorbar('vert');
0186     set(b,'xtick',[],'tickdir','out','box','off','ycolor','k');
0187     set(f,'currentaxes',a);
0188 end
0189 
0190

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