function visualize_chordMatrix(chords_retrieved,chords_relevant,parameter);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Name: visualize_chordsRetrievedRelevant
% Date: 15.09.2009
% Programmer: Meinard Mueller, Verena Konz
%
% Input: 
%        chords_retrieved
%        chords_relevant       
%        parameter
%
%
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if nargin<2
   chords_relevant=[]; 
end

if nargin<3
   parameter=[]; 
end

if size(chords_relevant,1) == 0
    chords_relevant = zeros(size(chords_retrieved));
end

if isfield(parameter,'featureRate')==0
   parameter.featureRate = 1;
end

if isfield(parameter,'numChords')==0
   parameter.numChords = 24;
end

if isfield(parameter,'visualizedChords')==0
   parameter.visualizedChords = [1:24];
end

if isfield(parameter,'YTickLabel')==0
   parameter.YTickLabel = [];
end

if isfield(parameter,'groundTruth')==0
   parameter.groundTruth = [];
end


if isfield(parameter,'colorbar')==0
   parameter.colorbar = 1;
end

if isfield(parameter,'colormap')==0
    %parameter.colormap = 'hot';
    parameter.colormap = [0 0 0; 0.4 0.4 0.4; 0.8 0 0; 1 1 1];
end


if isfield(parameter,'print')==0
   parameter.print = 0;
end

if isfield(parameter,'printFile')==0
   parameter.printFile = 'figure.eps';
end

if isfield(parameter,'printDir')==0
   parameter.printDir = '';
end

if isfield(parameter,'title')==0
   parameter.title = '';
end

if isfield(parameter,'xlabel')==0
   parameter.xlabel = '';
end

if isfield(parameter,'imagerange')==0
   parameter.imagerange = 0;
end


if isfield(parameter,'printPaperPosition')==0
   parameter.printPaperPosition = [1   10   26  15]; %[left, bottom, width, height]
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Visualization
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

numSamples = size(chords_retrieved,2);
numChords = parameter.numChords;
featureRate = parameter.featureRate;


figure;
set(gcf,'renderer','painters');
t = [0:numSamples-1]/parameter.featureRate;

f_image = chords_retrieved+2*chords_relevant;
f_image = f_image(parameter.visualizedChords,:);
numVisualizedChords = size(parameter.visualizedChords,2);
if parameter.imagerange == 0
    h = imagesc(t,[1:numVisualizedChords],f_image,[0 3]);
else
    h = imagesc(t,[1:numVisualizedChords],f_image,[0 3]);
end
set(gca,'YTick',[1:numVisualizedChords]);
set(gca,'YDir','normal');

if size(parameter.YTickLabel,1) > 0
    set(gca,'YTickLabel',parameter.YTickLabel(parameter.visualizedChords,:));
end
if t(end)>t(1)
    set(gca,'XLim',[t(1),t(end)]);
end

title(parameter.title);
xlabel(parameter.xlabel);
colormap(parameter.colormap);
if parameter.colorbar == 1
    h = colorbar;
end
 
drawnow;

if parameter.print == 1
    %pos = get(h,'Position');
    %pos(3)=pos(3)/3;
    %set(h,'Position',pos)        
    set(gcf,'PaperPosition',parameter.printPaperPosition);
    print('-depsc2',strcat(parameter.printDir,parameter.printFile));
end




