EKG_Project.Modules.Waves.Waves.FindQRSOnset C# (CSharp) Method

FindQRSOnset() public method

public FindQRSOnset ( double drightEnd, double dmiddleR, Vector dwt, int decompLevel ) : int
drightEnd double
dmiddleR double
dwt Vector
decompLevel int
return int
        public int FindQRSOnset( double drightEnd, double dmiddleR, Vector<double> dwt, int decompLevel)
        {
            int rightEnd = (int)drightEnd;
            int middleR = (int)dmiddleR;
            int sectionStart = (rightEnd >> decompLevel);

            int len = (middleR >> decompLevel) - (rightEnd >> decompLevel);

            if (len < 1)
                len = 1;

            //Console.WriteLine("nadupcamy!");
            //Console.WriteLine(sectionStart);
            //Console.WriteLine((middleR >> decompLevel) - (rightEnd >> decompLevel) + 1);
            //Console.WriteLine(dwt.Count);

            if (sectionStart + len >= dwt.Count)
                return -1;

            int qrsOnsetInd = dwt.SubVector(sectionStart, len).MinimumIndex() + sectionStart;
            double treshold = Math.Abs(dwt[qrsOnsetInd])*0.05;

            while (Math.Abs(dwt[qrsOnsetInd]) > treshold && qrsOnsetInd > sectionStart)
                qrsOnsetInd--;

            if (qrsOnsetInd == sectionStart)
                return -1;
            else
                return (qrsOnsetInd << decompLevel);
        }