function [clistv] = docolor(eventliston,eventlistoff,clim,ebank,fs,framehz)
%  make color selection
% [clistv] = docolor(eventliston,eventlistoff,clim,ebank,fs,framehz);
% compute color arrays in db from the audio bank
% clim sets the color range of chosen events
% you could change clim here and you could change the color used
% to pick events

% this routine needs as inputs
%   clim: sets color trigger for chosen events
%   eventliston, eventlistoff: tagged event lists
%   ebank: the filterbank
%   fs sampling freq of data
%   framehz sampling freq of filterbank
% this routine returns
%   clistv:  list of indexes in eventsliston that are the color chosen ones

%color14 = e(:,1)-e(:,4);  % ratio of two filter banks
%color23 = e(:,2)-e(:,3);
color13 = ebank(:,1)-ebank(:,3);
color12 = ebank(:,1)-ebank(:,2);
color34 = ebank(:,3)-ebank(:,4);
%color35 = e(:,3)-e(:,5);


%clim = 10.0;  % in db
% color limit for picking interesting events
elist = [];  
% list of indexes in color,filterbank arrays
%    that are labelled as during events
clist = [];
% list of indexes in color,filterbank arrays
%    that are events that have some color
%    above a clim level
clistv = [];
% list of indexes in events list that 
%    are events with some color above some clim somewhere during event
%    these are event numbers not indexes of start of event
%    index of start of event would be eventliston(clistv(i))
dj = fs/framehz;
for i = 1:length(eventliston);
    xx = 0;
    shortlist =[];
    for j= fix(eventliston(i)/dj):fix(eventlistoff(i)/dj);
       elist= [elist j];   % indexs of events in colors arrays
       shortlist = [shortlist j];
       if ((xx==0) & (color13(j) > clim))
           xx = 1;
           clist = [clist j]; % index in filterbank
           clistv = [clistv i];  % index in event list
       end
    end
end
plot(color12(elist),color34(elist),'d');
xlabel('color [0.25:2Hz]-[5:10Hz] (db)');
ylabel('color [5:10Hz] - [10:18Hz](db)');
length(clistv)
%number of colored events!

