function entre

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

global stepping
global nb_state_ex nb_state_arp
global dim_x dim_y
global threshold mat_vois
global dim_protoc protocole liste_stim liste_disc
global  id_step id_protoc etat
global mat_vois etat
global h_main

[fn,pn]=uigetfile('*.mat','choose the file');
if(fn ~=0)
str=['load ' pn fn]
eval(['load ' pn fn]);
end

if(~all(size(etat) == [dim_x dim_y]))return;end

figure=h_main
ha=findobj(h_main,'type','axes');

   if(~isempty(ha))
      cla;
      
   else
     ha=axes('units', 'norm', 'pos', [0, 0, 1 1],'vis','off');
   end

cmap=hot(nb_state_ex+nb_state_arp+1);
colormap(cmap);

set(ha, 'xlim', [0 dim_x], 'ylim', [ 0 dim_y]);


%matrix to trace the patch
clear cx cy
for j=1:dim_y
for i=1:dim_x
%cx(j+(i-1)*dim_y,:)=[i-1 i i i-1];
%cy(j+(i-1)*dim_y,:)=[j-1 j-1 j j];
cx(i+(j-1)*dim_x,:)=[i-1 i i i-1];
cy(i+(j-1)*dim_x,:)=[j-1 j-1 j j];
end;
end

for i=1:dim_x*dim_y
patch(cx(i,:),cy(i,:),etat(i)+1, 'eras', 'none');
end;
drawnow
