Ejemplo n.º 1
0
        private void ExamineNarrowPeaks(PeakDataContainer peakData, udtSICPeakFinderOptionsType peakFinderOptions)
        {
            if (peakData.Peaks.Count <= 0)
            {
                // No peaks were found; create a new peak list using the original peak location index as the peak center
                peakData.Peaks = new List <clsPeak>
                {
                    new clsPeak(peakData.OriginalPeakLocationIndex)
                };

                return;
            }

            if (!peakFinderOptions.ReturnClosestPeak)
            {
                return;
            }

            // Make sure one of the peaks is within 1 of the original peak location
            var blnSuccess = false;

            foreach (var peak in peakData.Peaks)
            {
                if (peak.LocationIndex - peakData.OriginalPeakLocationIndex <= 1)
                {
                    blnSuccess = true;
                    break;
                }
            }

            if (blnSuccess)
            {
                // One of the peaks includes data point peakData.OriginalPeakLocationIndex
                return;
            }

            // None of the peaks includes peakData.OriginalPeakLocationIndex
            var newPeak = new clsPeak(peakData.OriginalPeakLocationIndex)
            {
                Area = peakData.YData[peakData.OriginalPeakLocationIndex]
            };

            peakData.Peaks.Add(newPeak);
        }
Ejemplo n.º 2
0
        private void ExpandPeakRightEdge(
            PeakDataContainer peakData,
            udtSICPeakFinderOptionsType peakFinderOptions,
            clsPeak peak,
            float sngPeakMaximum,
            bool dataIsSmoothed)
        {
            var intStepOverIncreaseCount = 0;

            while (peak.RightEdge < peakData.DataCount - 1)
            {
                if (peakData.SmoothedYData[peak.RightEdge + 1] < peakData.SmoothedYData[peak.RightEdge])
                {
                    // The adjacent point is lower than the current point
                    peak.RightEdge += 1;
                }
                else if (Math.Abs(peakData.SmoothedYData[peak.RightEdge + 1] -
                                  peakData.SmoothedYData[peak.RightEdge]) < double.Epsilon)
                {
                    // The adjacent point is equal to the current point
                    peak.RightEdge += 1;
                }
                else
                {
                    // The next point to the right is not lower; what about the point after it?
                    if (peak.RightEdge < peakData.DataCount - 2)
                    {
                        if (peakData.SmoothedYData[peak.RightEdge + 2] <=
                            peakData.SmoothedYData[peak.RightEdge])
                        {
                            // Only allow ignoring an upward spike if the delta from this point to the next is <= .MaxAllowedUpwardSpikeFractionMax of sngPeakMaximum
                            if (peakData.SmoothedYData[peak.RightEdge + 1] -
                                peakData.SmoothedYData[peak.RightEdge] >
                                peakFinderOptions.MaxAllowedUpwardSpikeFractionMax * sngPeakMaximum)
                            {
                                break;
                            }

                            if (dataIsSmoothed)
                            {
                                // Only ignore an upward spike twice if the data is smoothed
                                if (intStepOverIncreaseCount >= 2)
                                {
                                    break;
                                }
                            }

                            peak.RightEdge += 1;

                            intStepOverIncreaseCount += 1;
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
        }