
function [estimatedBR, estimatedHR] = CalculateCS_VitalSigns(brPeakAmps,brPeakLocs,hrPeakAmps,hrPeaksLocs)

    peakFreq_br = peakFreqency(brPeakAmps, brPeakLocs);
    estimatedBR = peakFreq_br * 60;
 
    i = 1;
    while(i<length(hrPeakAmps))
        
        modulus = mod(hrPeaksLocs(i),peakFreq_br);
        if(modulus < 0.04)

            hrPeakAmps(i) = 0;

        end

        i = i + 1;

    end

    peakFreq_hr = peakFreqency(hrPeakAmps, hrPeaksLocs);
    estimatedHR = peakFreq_hr * 60;

end


function [peakFreq] = peakFreqency(peakAmplitudes, peakFrequencies)
  
    peakAmp = max(peakAmplitudes);
    index = peakAmplitudes==peakAmp;
    peakFreq = peakFrequencies(index);

end