function p = defclus(b,image,irx,irr,irh,icl)
% p = defclus(b,image,irx,irr,irh,icl)
[mb nb] = size(b);
p = b;
for i1 = 1:mb   %  for every cluster
  rowxct = 0;  clear c1locs; ival = b(i1,1);
  c1locs(5) = 0; maxgloc = b(i1,2); maxgval = image(ival,maxgloc);
  for j1 = b(i1,2):b(i1,3)     % look at every column in cluster
    if image(ival,j1) > maxgval
      maxgval = image(ival,j1);
      maxgloc = j1;
    end % if
    if irx(b(i1,1),j1) > 0     % for a row parabola peak
       rowxct = rowxct+1;       % count how many responses
       c1locs(rowxct) = j1;     % keep column numbers
       radii(rowxct) = irr(b(i1,1),j1);     % keep row radius there
       heights(rowxct) = irh(b(i1,1),j1);   % heep height of peak
    elseif (icl(b(i1,1),j1)==16) | (icl(b(i1,1),j1)==4 & icl(b(i1,1),j1+1)==8)
      c1locs(1) = j1;
      radii(1) = b(i1,3)-b(i1,2);
      heights(1) = image(b(i1,1),j1);
    end % elseif
  end % for
  if rowxct > 0      % if there's only on response, use it
    center1 = c1locs(1);
    left1 = center1 - radii(1) + 5;
    right1 = center1 + radii(1) - 5;
    height1 = heights(1);
    if rowxct > 1    % if more than one and they're close, average them
      maxdif = 0;  jsum = c1locs(1); rsum = radii(1); hsum = heights(1);
      for index = 1:rowxct-1
        dif = c1locs(index+1) - c1locs(index);
        jsum = jsum + c1locs(index+1);
        rsum = rsum + radii(index+1);
        hsum = hsum + heights(index+1);
        if dif > maxdif
          maxdif = dif;
        end
      end
      if maxdif<3
        center1 = jsum/rowxct;
        r1 = rsum/rowxct;
        left1 = center1 - r1 + 5;
        right1 = center1 + r1 - 5;
        height1 = hsum/rowxct;
      end
    end
  else
    center1 = maxgloc;
    left1 = b(i1,2);
    right1 = b(i1,3);
    height1 = maxgval;
  end
  p(i1,4) = center1;
  p(i1,5) = left1;
  p(i1,6) = right1;
  p(i1,7) = height1;
end
