private Peak[] SplitIntoPair(double valleyFactor, bool maxIntensity) { float[] intensities = smoothIntensity; int[] minPos = ArrayUtil.CalcLocalMinPositions(intensities); foreach (int pos in minPos) { double leftMax = GetLeftMax(pos, intensities); double rightMax = GetRightMax(pos, intensities); double smallMax = Math.Min(leftMax, rightMax); if (smallMax / intensities[pos] > valleyFactor) { return(SplitAt(pos, maxIntensity)); } } return(null); }