function [iCell Region] = DecidePyrIntRegion(Map)

% Map = PyrIntMap.Map
iCell{1} = (Map(:,5)>0 & Map(:,6)==0) |  (Map(:,41)>0 & Map(:,6)==0 & Map(:,42)==0);
iCell{2} = (Map(:,6)>0 & Map(:,5)==0) |  (Map(:,42)>0 & Map(:,5)==0 & Map(:,41)==0);
%iCell{3} = ~iCell{1} & ~iCell{2};
iCell{4} = Map(:,5)>0 & Map(:,6)==0;
iCell{5} = Map(:,6)>0 & Map(:,5)==0;

ToRemove = [20036 5 7;
       20041 6 9;
       20041 7 12;
       20046 8 11;
       40017 3 4;
       30103 2 3;
       40017 3 13;
       40017 3 11;
       40017 3 16;
       40028 2 5;
       40030 2 6;
       40031 2 5;
       40051 8 2;
       40058 2 4;
       81104 6 12];
   
for i = 1:size(ToRemove,1)
   ind = Map(:,18)==ToRemove(i,1) & Map(:,3)==ToRemove(i,2) & Map(:,4)==ToRemove(i,3);
   if any(ind)
       iCell{1}(ind)=0;
       iCell{4}(ind)=0;
   end
end

iCell{1} = logical(iCell{1});
iCell{4} = logical(iCell{4});


iCell{3} = ~iCell{1} & ~iCell{2};

Region = zeros(size(Map,1),1);

% CA1
ind = Map(:,43)==2;
Region(ind,:) = 1;

% CA3
ind = Map(:,43)==3 & Map(:,19)==1;
Region(ind,:) = 2;

% DG
ind = Map(:,43)==3 & Map(:,19)==2 & Map(:,18)~=20051;
Region(ind,:) = 3;

% EC2
ind = Map(:,43)==1 & Map(:,19)==1;
Region(ind,:) = 4;

% EC3
ind = Map(:,43)==1 & Map(:,19)==2;
Region(ind,:) = 5;

% EC5
ind = Map(:,43)==1 & Map(:,19)==4;
Region(ind,:) = 6;

% EC4
ind = Map(:,43)==1 & Map(:,19)==3;
Region(ind,:) = 7;

% EC?
ind = Map(:,43)==1 & Map(:,19)>4;
Region(ind,:) = 8;

return

GG = [3311 3601 3620 3925 5080 4999 5089 5087 5092 5338 5389 5436 7445 7714];

ToRemove = Map(GG',[18 3 4]);