function []=hidensityall(parent,varargin)
%show the highest density regions of a 2D scores plot
if size(varargin,1)>0 && strcmp('data',varargin(1))==1
    score=parent.data;
    type='Data';
else
    score=parent.score;
    type='Score';
end

nrows=parent.cropmatrix(4)-parent.cropmatrix(2)+1;
scrsz = get(groot,'ScreenSize');
figure('Position',[1 scrsz(4)*0.75 scrsz(3)*0.75 scrsz(4)*0.75]);
a=1;
b=2;

subplot(2,3,1)
scatter(score(1:5:end,a),score(1:5:end,b),1,[0 0.2 1]);
hold on
scatter(score(2:50:end,a),score(2:50:end,b),1,[0 0.8 1]);
scatter(score(3:200:end,a),score(3:200:end,b),2,[0.8 1 0],'filled');
scatter(score(4:1000:end,a),score(4:1000:end,b),1,[1 0.2 0],'filled');
str = sprintf('%s %d',type,a);
xlabel(str)
str = sprintf('%s %d',type,b);
ylabel(str)
str = sprintf('Cluster Plot');
title(str)
xlim([-inf inf])
ylim([-inf inf])

subplot(2,3,3)
[xy,h]=plotgram(score(:,b));
rotate(h,[0 0 1],270,[0 0 0]);
h.YData=-h.YData;
h=gca;
h.XTickLabelRotation=-45;
xlabel('Density')
str = sprintf('%s %d',type,b);
ylabel(str)
ylim([-inf inf])
xlim([-inf inf])

a=3;
b=2;

subplot(2,3,2)
scatter(score(1:5:end,a),score(1:5:end,b),1,[0 0.2 1]);
hold on
scatter(score(2:50:end,a),score(2:50:end,b),1,[0 0.8 1]);
scatter(score(3:200:end,a),score(3:200:end,b),2,[0.8 1 0],'filled');
scatter(score(4:1000:end,a),score(4:1000:end,b),1,[1 0.2 0],'filled');
str = sprintf('%s %d',type,a);
xlabel(str)
str = sprintf('%s %d',type,b);
ylabel(str)
str = sprintf('Cluster Plot');
title(str)
xlim([-inf inf])
ylim([-inf inf])

a=1;
b=2;
subplot(2,3,4)
plotgram(score(:,a));
set(gca,'YDir','reverse');
ylabel('Density')
str = sprintf('%s %d',type,a);
xlabel(str)
ylim([-inf inf])
xlim([-inf inf])

a=3;
b=2;

subplot(2,3,5)
plotgram(score(:,a));
set(gca,'YDir','reverse');
ylabel('Density')
str = sprintf('%s %d',type,a);
xlabel(str)
ylim([-inf inf])
xlim([-inf inf])

a=1;
b=2;
c=3;
figure;
fused1=imfuse(reshape(score(:,a),nrows,[]),reshape(score(:,b),nrows,[]));
fused2=imfuse(reshape(score(:,c),nrows,[]),reshape(score(:,b),nrows,[]));
fused3=imfuse(reshape(score(:,a),nrows,[]),reshape(score(:,c),nrows,[]));
subplot(1,3,1), imshow(fused1); title(sprintf('Contrast Images: %s (%0.0f, %0.0f)',type,a,b)); 
subplot(1,3,2), imshow(fused2); title(sprintf('Contrast Images: %s (%0.0f, %0.0f)',type,c,b)); 
subplot(1,3,3), imshow(fused3); title(sprintf('Contrast Images: %s (%0.0f, %0.0f)',type,a,c));
end