示例#1
0
        public bool DiscoverPeak(List <double> mzList, List <double> intensityList, double startMz, double stopMz,
                                 out clsPeak peak, bool findFwhm = false, bool findSignalToNoise = false, bool fitPeak = false)
        {
            peak = new clsPeak();
            var startIndex = PeakIndex.GetNearest(mzList, startMz, 0);
            var stopIndex  = PeakIndex.GetNearest(mzList, stopMz, startIndex);

            peak.Mz            = 0;
            peak.Intensity     = 0;
            peak.DataIndex     = -1;
            peak.FWHM          = 0;
            peak.SignalToNoise = 0;

            double maxIntensity = 0;
            var    found        = false;

            for (var i = startIndex; i < stopIndex; i++)
            {
                var intensity = intensityList[i];
                if (intensity > maxIntensity)
                {
                    maxIntensity   = intensity;
                    peak.Mz        = mzList[i];
                    peak.Intensity = intensity;
                    peak.DataIndex = i;
                    found          = true;
                }
            }
            if (found)
            {
                if (findFwhm)
                {
                    peak.FWHM = PeakStatistician.FindFwhm(mzList, intensityList, peak.DataIndex);
                }
                if (findSignalToNoise)
                {
                    peak.SignalToNoise = PeakStatistician.FindSignalToNoise(peak.Intensity, intensityList,
                                                                            peak.DataIndex);
                }
                if (fitPeak)
                {
                    peak.Mz = _peakFit.Fit(peak.DataIndex, mzList, intensityList);
                }
            }
            return(found);
        }
示例#2
0
        /// <summary>
        ///     Gets the peak that fits the point at a given index with a Lorentzian fit.
        /// </summary>
        /// <param name="index">index of the point in the m/z vectors which is the apex of the peak.</param>
        /// <param name="mzs">List of raw data of m\zs.</param>
        /// <param name="intensities">List of raw data of intensities.</param>
        /// <param name="fwhm"></param>
        /// <returns>returns the m/z of the peak.</returns>
        private double LorentzianFit(List <double> mzs, List <double> intensities, int index, double fwhm)
        {
            var a  = intensities[index];
            var vo = mzs[index];
            var e  = Math.Abs((vo - mzs[index + 1]) / 100);

            if (index < 1)
            {
                return(mzs[index]);
            }
            if (index == mzs.Count)
            {
                return(mzs[index]);
            }

            var lstart = PeakIndex.GetNearest(mzs, vo + fwhm, index) + 1;
            var lstop  = PeakIndex.GetNearest(mzs, vo - fwhm, index) - 1;

            var currentE = LorentzianLS(mzs, intensities, a, fwhm, vo, lstart, lstop);

            for (var i = 0; i < 50; i++)
            {
                var lastE = currentE;
                vo       = vo + e;
                currentE = LorentzianLS(mzs, intensities, a, fwhm, vo, lstart, lstop);
                if (currentE > lastE)
                {
                    break;
                }
            }

            vo       = vo - e;
            currentE = LorentzianLS(mzs, intensities, a, fwhm, vo, lstart, lstop);
            for (var i = 0; i < 50; i++)
            {
                var lastE = currentE;
                vo       = vo - e;
                currentE = LorentzianLS(mzs, intensities, a, fwhm, vo, lstart, lstop);
                if (currentE > lastE)
                {
                    break;
                }
            }
            vo = vo + e;
            return(vo);
        }
示例#3
0
        public double GetSignalToNoise(List <double> mzList, List <double> intensityList, double peak)
        {
            var index = PeakIndex.GetNearest(mzList, peak, 0);

            return(PeakStatistician.FindSignalToNoise(intensityList[index], intensityList, index));
        }
示例#4
0
        public double GetFWHM(List <double> mzList, List <double> intensityList, double peak)
        {
            var index = PeakIndex.GetNearest(mzList, peak, 0);

            return(PeakStatistician.FindFwhm(mzList, intensityList, index));
        }