Exemple #1
0
        /// <summary>
        /// Filter noise peaks out using peak slope
        /// </summary>
        /// <param name="slopeThreshold"></param>
        public void FilterNoiseBySlope(double slopeThreshold = 10000)
        {
            if (Peaks.Length < 2)
            {
                return;
            }

            var mzData        = new float[Peaks.Length];
            var intensityData = new float[Peaks.Length];
            var i             = 0;

            for (i = 0; i < Peaks.Length; i++)
            {
                mzData[i]        = (float)Peaks[i].Mz;
                intensityData[i] = (float)Peaks[i].Intensity;
            }

            var spline = new CubicSpline();

            spline.Fit(mzData, intensityData);

            var intensitySlope = spline.EvalSlope(mzData);

            var filteredPeaks = new List <Peak>();

            for (i = 0; i < Peaks.Length; i++)
            {
                if (Math.Abs(intensitySlope[i]) > slopeThreshold)
                {
                    filteredPeaks.Add(Peaks[i]);
                }
            }
            Peaks = filteredPeaks.ToArray();
        }