Пример #1
0
        public PeakAndValleyFinder(IList <float> intensities)
        {
            int    maxIntensityIndex = -1;
            double baselineIntensity = 0;

            if (intensities.Count > 0)
            {
                float maxIntensityFloat = intensities.Max();
                if (maxIntensityFloat > 0)
                {
                    maxIntensityIndex = intensities.IndexOf(maxIntensityFloat);
                    baselineIntensity = intensities.Min();
                }
            }
            int fwhm = 6;

            if (maxIntensityIndex != -1)
            {
                double halfHeight = (intensities[maxIntensityIndex] - baselineIntensity) / 2 + baselineIntensity;
                int    iStart     = 0;
                for (int i = maxIntensityIndex - 1; i >= 0; i--)
                {
                    if (intensities[i] < halfHeight)
                    {
                        iStart = i;
                        break;
                    }
                }
                int len  = intensities.Count;
                int iEnd = len - 1;
                for (int i = maxIntensityIndex + 1; i < len; i++)
                {
                    if (intensities[i] < halfHeight)
                    {
                        iEnd = i;
                        break;
                    }
                }
                fwhm = Math.Max(fwhm, iEnd - iStart);
            }
            _fullWidthHalfMax     = fwhm * 3;
            _min_len              = (int)(fwhm / 4.0 + 0.5);
            _widthDataWings       = _fullWidthHalfMax * 2;
            _intensitiesWithWings =
                Enumerable.Repeat((float)baselineIntensity, _widthDataWings)
                .Concat(intensities)
                .Concat(Enumerable.Repeat((float)baselineIntensity, _widthDataWings))
                .ToArray();
            var gs2D = new GaussSmother();

            gs2D.SetGaussWeights(GetSd(), 2);
            gs2D.InvertWeights();
            gs2D.TrimWeightsByFracMax(0.005f);
            _chrom2D = gs2D.SmoothVect(_intensitiesWithWings);
            FindCrossPoints(0f);
            FindsPeaksAndValleys();
        }
Пример #2
0
        public IList <float> GetIntensities1d()
        {
            var gs1d = new GaussSmother();

            gs1d.SetGaussWeights(GetSd(), 1);
            gs1d.TrimWeightsByFracMax(0.005f);
            gs1d.SmoothVect(_intensitiesWithWings);
            return(_intensitiesWithWings);
        }