function show_interactions(hObject, eventdata)
global var h


xpos=var.xpos;
ypos=var.ypos;
Hstep=var.Hstep;
nBR = var.nBR;
nBL = var.nBL;
nTL = var.nTL;
Vpoints = var.Vpoints;
Hpoints = var.Hpoints;


if var.correction==1

    var.ExtPSThres2 = var.IntePSThres2;
    var.ExtConvThres1 = var.InteConvThres1;

end

subplot(1,14,1:12)


h.plot = imagesc(var.newimage);
set(gca,'YDir','normal');
colormap gray

hold on
plot([nBL(1) nTL(1) nBR(1)], [nBL(2) nTL(2) nBR(2)],'oy')

% plotting boxes for individual colonies
% for i=1:(Vpoints/2)
%     for j=1:(Hpoints/2)
%         
%         for i2=1:2
%             for j2=1:2
%                 plot(var.pointbox{i,j,(i2-1)*2+j2}([1:4 1],1),var.pointbox{i,j,(i2-1)*2+j2}([1:4 1],2),'b')
%             end
%         end
%     end
% end
% hold off

hold on
colors = 'krg';


var.confirmed = {'Interactions'};
var.nc=0;
var.conf_pos={''};
var.combined = zeros(Vpoints/2,Hpoints/2);
for i2=1:length(var.inte)
    i = var.inte(i2,1);
    j = var.inte(i2,2);
    

    
    if (var.intensity(i,j) >= var.InteConvThres1 && var.PointSum(i,j)>var.IntePSThres2)
    
        var.confirmed{end+1} = var.abb{i,j};
        if var.species ~= 3
            var.conf_pos{end+1} = var.pos{i,j};
        end
        var.nc=var.nc+1;
        var.confposx(var.nc)= var.xpos(i,j);
        var.confposy(var.nc) = var.ypos(i,j);
        var.combined(i,j) = 1;
        
    end
end

if var.correction==2
    for i2=1:length(var.ext)
        i = var.ext(i2,1);
        j = var.ext(i2,2);
         
        
        if (var.intensity(i,j) >= var.ExtConvThres1 && var.PointSum(i,j)>var.ExtPSThres2) 
            
            var.confirmed{end+1} = var.abb{i,j};
            if var.species ~= 3
                var.conf_pos{end+1} = var.pos{i,j};
            end
            var.nc=var.nc+1;
            var.confposx(var.nc) = var.xpos(i,j);
            var.confposy(var.nc) = var.ypos(i,j);
            var.combined(i,j) = 1;
            
        end
    end
end



plot(xpos(var.combined==1),ypos(var.combined==1),'og','markersize',Hstep*.90);

for c=1:var.nc
    text(var.confposx(c),var.confposy(c),[ var.confirmed{c+1}],...
        'HorizontalAlignment','center','color','g','FontSize',Hstep*.26)
end

hold off




maxPS = max(max(var.PointSum));
minPS = min([min(min(var.PointSum)) var.IntePSThres2  var.ExtPSThres2]);
maxPS = maxPS + .05*(maxPS-minPS);
maxint = max(max(var.intensity));
minint = min([min(min(var.intensity)) var.InteConvThres1  var.ExtConvThres1 ]);
maxint = maxint + .05*(maxint-minint);


subplot(2,16,15:16)

 
intinte = zeros(length(var.inte),2);
PSinte = zeros(length(var.inte),2);
for i=1:length(var.inte)
    intinte(i) = var.intensity(var.inte(i,1),var.inte(i,2));
    PSinte(i) = var.PointSum(var.inte(i,1),var.inte(i,2));
end
plot(intinte,PSinte,'.')
hold on
plot([var.InteConvThres1 var.InteConvThres1 maxint maxint var.InteConvThres1], ...
    [maxPS var.IntePSThres2 var.IntePSThres2 maxPS maxPS], ...
    'g-', 'linewidth',2);


hold off
xlim([minint maxint])
ylim([minPS maxPS])

if var.correction == 2
     subplot(2,16,31:32)
    
    intext = zeros(length(var.ext),2);
    PSext = zeros(length(var.ext),2);
    for i=1:length(var.ext)
        intext(i) = var.intensity(var.ext(i,1),var.ext(i,2));
        PSext(i) = var.PointSum(var.ext(i,1),var.ext(i,2));
    end
    plot(intext,PSext,'.')
    hold on
    plot([var.ExtConvThres1 var.ExtConvThres1 maxint maxint var.ExtConvThres1], ...
        [maxPS var.ExtPSThres2 var.ExtPSThres2 maxPS maxPS], ...
        'g-', 'linewidth',2);
    
    
    hold off
    xlim([minint maxint])
    ylim([minPS maxPS])
end




set(h.buttons.show_interactions,'backgroundcolor','w','visible','off')

% Display of interactions

for j=2:length(var.confirmed(:))
    string(j,1)=[var.confirmed(j)];
     S(j)=string(j,1);
 
    if var.species ~= 3
        string(j,2)=[var.conf_pos(j)];
         S(j) = strcat(string(j,1),' - ', string(j,2));
        
    end
    
    
end


S(1)=var.confirmed(1);
var.S=S;
[outstring,newpos] = textwrap(h.text.results,S);
if exist('string','var')
interactions=string
else
    disp('No interactions found')
end
set(h.text.results,'string',outstring,'visible','on','Position',[.915 0.9-newpos(4) .06 newpos(4)])
% [.005 .2 .08 newpos(4)]


