function drawcmap

%   Copyright 2003
%   Centre for Nonlinear Dynamics in Physiology and Medicine

global cmap figcmap
global nb_state_ex nb_state_arp

if(exist('figcmap') ~=1)figcmap=[];
elseif( isempty(find(get(0,'children') == figcmap)) )
figcmap=[];
end

if(~isempty(figcmap))delete(figcmap);end

if(isempty(cmap))
cmap=hot(nb_state_ex+nb_state_arp+1);
elseif(length(cmap(:,1)) ~= nb_state_ex+nb_state_arp+1)
cmap=hot(nb_state_ex+nb_state_arp+1);
end

figcmap=figure('numbertitle', 'off', 'name', 'current color map',...
         'unit','normalized','position',[.05 .90 .9 .05]);

uimenu(figcmap,'label','delete','callback','delete(figcmap);figcmap=[];');
ha=axes('units', 'norm', 'pos', [0, 0, 1 1],'vis','off');
set(ha, 'xlim', [0 nb_state_ex+nb_state_arp+1 ], 'ylim', [ 0 1]);

colormap(cmap);
vect_colmap=colormap;
caxis([1 nb_state_ex+nb_state_arp+1]);

for i=1:nb_state_ex+nb_state_arp+1
patch(.5+(i-1)+[-.5 .5 .5 -.5],[0 0 1 1],i,...
        'facecolor',vect_colmap(i,:),'edgecolor',[0 0 0]);

end

text(.25,.5,'rest','fontweight','bold','fontsize',10);

for i=1:nb_state_ex
text(i+.25,.5,['EX ' int2str(i)],'fontweight','bold','fontsize',10);
end

for i=1:nb_state_arp
text(nb_state_ex+i+.25,.5,['ARP ' int2str(i)],'fontweight','bold','fontsize',10);
end
