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

DetectQRS() public method

public DetectQRS ( ) : void
return void
        public void DetectQRS()
        {
            _currentQRSonsetsPart.Clear();
            List<Vector<double>> dwt = new List<Vector<double>>();
            int startInd = 0;
            if (_rPeaksProcessed > 1)
            {
                startInd = (int)InputDataRpeaks.RPeaks[_currentChannelIndex].Item2[_rPeaksProcessed - 1];
                //Console.WriteLine("startujemy");
                //Console.WriteLine(startInd);
            }
            int endInd = (int)InputDataRpeaks.RPeaks[_currentChannelIndex].Item2.Count - 1;

            if (_rPeaksProcessed + _params.RpeaksStep + 1 < endInd)
            {
                endInd = (int)InputDataRpeaks.RPeaks[_currentChannelIndex].Item2[_rPeaksProcessed + _params.RpeaksStep + 1];
                //Console.WriteLine(endInd);
            }
            else
            {
                endInd = (int)InputDataRpeaks.RPeaks[_currentChannelIndex].Item2[endInd];
            }

            int dwtLen = 1;
            if (endInd != startInd)
                dwtLen = endInd - startInd;
            //Console.WriteLine(endInd);
            //Console.WriteLine(dwtLen);

            dwt = ListDWT(InputData.Signals[_currentChannelIndex].Item2.SubVector(startInd, dwtLen), _params.DecompositionLevel , _params.WaveType);

            int d2size = dwt[_params.DecompositionLevel - 1].Count();
            int rSize = _params.RpeaksStep;
            int decLev = _params.DecompositionLevel;

            if (startInd == 0)
                 _currentQRSonsetsPart.Add(FindQRSOnset(0, InputDataRpeaks.RPeaks[_currentChannelIndex].Item2[0], dwt[decLev-1], _params.DecompositionLevel));

            int maxRInd = _rPeaksProcessed + rSize;
            if (maxRInd >= _currentRpeaksLength)
                maxRInd = _currentRpeaksLength - 1;

            for (int middleR = _rPeaksProcessed+1; middleR < maxRInd ; middleR++ )
            {
                _currentQRSonsetsPart.Add(FindQRSOnset(InputDataRpeaks.RPeaks[_currentChannelIndex].Item2[middleR-1] - startInd, InputDataRpeaks.RPeaks[_currentChannelIndex].Item2[middleR] - startInd, dwt[decLev - 1], _params.DecompositionLevel)+ startInd);
                _currentQRSendsPart.Add(FindQRSEnd(InputDataRpeaks.RPeaks[_currentChannelIndex].Item2[middleR] - startInd, InputDataRpeaks.RPeaks[_currentChannelIndex].Item2[middleR + 1] - startInd, dwt[decLev - 1], _params.DecompositionLevel)+ startInd);
            }

            if (endInd == (int)InputDataRpeaks.RPeaks[_currentChannelIndex].Item2.Count - 1)
                _currentQRSendsPart.Add(FindQRSEnd(InputDataRpeaks.RPeaks[_currentChannelIndex].Item2[rSize] -startInd, InputData.Signals[_currentChannelIndex].Item2.Count - 1, dwt[decLev - 1], _params.DecompositionLevel));
        }