function vesDNmaxB = brighter(vesDNmaxB, m, pT, data, flak, newmean)
%set conditions for vesicles BRIGHTER THAN MATRIX: The mean of the data
%between borders must be higher than the average of the borders. However, 
%ignore data that is too broad (> 200 px).

%now find vesicles darker than matrix
if (mean(data(1:pT(1))) > (data(1)+data(pT(1)))/2) & ((pT(1)-1) < 200)
  %keep track of values and length of data string (to compute mean 
  %afterwards).
    flak=1;
    datasum(1)=sum(data(1:pT(1)));
    datalength(1)=length(1:pT(1));
    %vesDN(1)=mean(data((1+pT(1))/2));
end

if flak==1
    c=2; %vesDN counter (used below)
else
    c=1; %vesDN counter (used below)
end

for j=2:length(pT)
  if (mean(data(pT(j-1):pT(j))) > (data(pT(j-1))+data(pT(j)))/2) & ...
     ((pT(j)-pT(j-1)) < 200)
        %datalength(c)=pT(j)-pT(j-1);
        flak=2;
        datasum(c)=sum(data(pT(j-1):pT(j)));
        datalength(c)=length(pT(j-1):pT(j));
        %vesDN(c)=mean(data(pT(j-1):pT(j)));
        c=c+1;
  end
end

%set vesicle DN range
if flak==2
    if ((sum(datasum)/sum(datalength))+newmean)-newmean < 2
        vesDNmaxB(m)=0; %zero values are removed later
    else
        vesDNmaxB(m)=(sum(datasum)/sum(datalength))+newmean;
    end
else
    vesDNmaxB(m)=0; %zero values are removed later
end %check flak==2