function [differ,thrm]=ca_thrm(wave,BPIndex,differ)
 if differ<120
    if BPIndex(1)>=differ-1 %ECGR波波峰先出现的情况
            PeakIndex=BPIndex-differ;
    else                    %BP波峰先出现的情况
            PeakIndex=BPIndex(2:end)-differ;
    end
    lenP=length(PeakIndex);
    thrm0=40;
    sub=[];
    for i=2:lenP-1
        k=PeakIndex(i)-thrm0:PeakIndex(i)+thrm0;
        [~,d]=max(wave(k));
        PeakIndex(i)=PeakIndex(i)-thrm0-1+d;
        sub(i-1)=d-thrm0-1;
    end
    thrm=max(abs(sub));
    thrm=thrm+18;
%     thrm=thrm+8;%%加8还是加12要考虑一下
 else
     differ=80;
     thrm=40;
end