Beispiel #1
0
 public void SetOptions(clsPeakProcessorParameters parameters)
 {
     _parameters = parameters;
     // the minimum intensity is not set till the actual data is available in DiscoverPeaks
     _peakProcessor.SetOptions(_parameters.SignalToNoiseThreshold, 0, _parameters.ThresholdedData,
                               _parameters.PeakFitType);
 }
Beispiel #2
0
 public clsPeakProcessor()
 {
     _peakProcessor = new PeakProcessor();
     _parameters    = new clsPeakProcessorParameters();
     _peakProcessor.SetOptions(_parameters.SignalToNoiseThreshold, 0, false,
                               _parameters.PeakFitType);
     ProfileType = enmProfileType.PROFILE;
 }
Beispiel #3
0
        //TODO: remove code duplication (see DeconToolsPeakDetector)
        public override List <Peak> FindPeaks(XYData xyData, double xMin = 0, double xMax = 0)
        {
            var peakList = new List <Peak>();

            if (xyData == null)
            {
                return(peakList);
            }

            if (UseNewPeakDetector)
            {
                _peakDetectorV2.FindPeaks(xyData, xMin, xMax);
            }
            else
            {
                var xVals = xyData.Xvalues.ToList();
                var yVals = xyData.Yvalues.ToList();

                if (_oldPeakProcessor == null)
                {
                    _oldPeakProcessor = new PeakProcessor();
                }

                BackgroundIntensity = _oldPeakProcessor.GetBackgroundIntensity(yVals);
                _oldPeakProcessor.SetOptions(SigNoise, BackgroundIntensity * PeakBackgroundRatio, false, PeakFitType.Quadratic);

                //Find peaks using DeconEngine
                var largestXValue = xyData.Xvalues[xyData.Xvalues.Length - 1];

                try
                {
                    _oldPeakProcessor.DiscoverPeaks(xVals, yVals, 0, largestXValue);
                }
                catch (Exception ex)
                {
                    Logger.Instance.AddEntry("ChromPeakDetector failed: " + ex.Message, true);
                    throw;
                }

                _oldDeconEnginePeaklist = _oldPeakProcessor.PeakData.PeakTops;
                foreach (var peak in _oldDeconEnginePeaklist)
                {
                    var chromPeak = new ChromPeak
                    {
                        XValue        = peak.Mz, // here,  mz is actually the scan / or NET
                        Height        = (float)peak.Intensity,
                        SignalToNoise = peak.SignalToNoise,
                        Width         = (float)peak.FWHM
                    };

                    peakList.Add(chromPeak);
                }
            }

            //resultList.Run.PeakList = new List<IPeak>();

            return(peakList);
        }
        /*[gord]  the following is currently unused. The idea was to give weighting to the algorithm so that
         * the user could favor certain fitting parameters (i.e. space between isotopomers) over others
         * public double FindIsotopicDist(PeakProcessing.PeakData peakData, int cs, PeakProcessing.Peak peak,
         *  IsotopeFitRecord isoRecord, double deleteIntensityThreshold, double spacingWeight, double spacingVar,
         *  double signalToNoiseWeight, double signalToNoiseThresh, double ratioWeight, double ratioThreshold,
         *  double fitWeight, double fitThreshold, bool debug = false)
         * {
         *  if (cs <= 0)
         *  {
         *      Environment.Exit(1);
         *  }
         *
         *  //Get theoretical distribution using Mercury algorithm
         *  double peakMass = (peak.mdbl_mz - ChargeCarrierMass) * cs;
         *  double resolution = peak.mdbl_mz / peak.mdbl_FWHM;
         *  GetIsotopeDistribution(peakMass, cs, resolution, out TheoreticalDistMzs,
         *      out TheoreticalDistIntensities,
         *      deleteIntensityThreshold, debug);
         *
         *  double theorMostAbundantPeakMz = IsotopeDistribution.mdbl_max_peak_mz;
         *  double delta = peak.mdbl_mz - theorMostAbundantPeakMz;
         *  double spacingScore = 0;
         *  double signalToNoiseScore = 0;
         *  double ratioScore = 0;
         *  double totalScore = 0;
         *  double maximumScore = spacingWeight + signalToNoiseWeight + ratioWeight + fitWeight;
         *
         *  //this will select peaks to the left until
         *  for (double dd = 1.003 / cs; dd <= 10.03 / cs; dd += 1.003 / cs)
         *  {
         *      double theorLeftPeakMz = 0;
         *      double theorLeftPeakIntensity = 0;
         *      PeakProcessing.Peak leftPeak;
         *      peakData.FindPeak(peak.mdbl_mz - dd - peak.mdbl_FWHM, peak.mdbl_mz - dd + peak.mdbl_FWHM, out leftPeak);
         *      //PeakProcessing.FindPeak
         *      IsotopeDistribution.FindPeak(theorMostAbundantPeakMz - dd - 0.2 / cs,
         *          theorMostAbundantPeakMz - dd + 0.2 / cs, out theorLeftPeakMz, out theorLeftPeakIntensity);
         *
         *      if (leftPeak.mdbl_mz > 0) //if there is an experimental peak...
         *      {
         *          //get spacing score
         *          spacingScore = spacingWeight * 1;
         *
         *          //get S/N score
         *          if (leftPeak.mdbl_SN > signalToNoiseThresh)
         *          {
         *              signalToNoiseScore = signalToNoiseWeight * 1;
         *          }
         *
         *          //get Ratio score
         *          double leftPeakRatio = leftPeak.mdbl_intensity / peak.mdbl_intensity;
         *          double theorLeftPeakRatio = theorLeftPeakIntensity / 1;
         *          //TODO: need to check if this most abundant theor peak's intensity is 1
         *      }
         *
         *      //get Ratio score
         *  }
         *  //get S/N score
         *  //get Fit score
         *  //calculate maximum score
         *  //get overall score
         *  return 0;
         * }*/

        public PeakData GetTheoreticalIsotopicDistributionPeakList(List <double> xvals, List <double> yvals)
        {
            var peakList  = new PeakData();
            var processor = new PeakProcessor();

            processor.SetOptions(0.5, 1, false, PeakFitType.Apex);
            processor.DiscoverPeaks(xvals, yvals, 0, 10000);

            var numpeaks = processor.PeakData.GetNumPeaks();

            for (var i = 0; i < numpeaks; i++)
            {
                ThrashV1Peak peak;
                processor.PeakData.GetPeak(i, out peak);
                peakList.AddPeak(peak);
            }

            return(peakList);
        }
Beispiel #5
0
        /// <summary>
        /// Finds peaks in XY Data within the specified range of X values. Optionally, to use all XY data points, enter 0 for both min and max values
        /// </summary>
        /// <param name="xydata"></param>
        /// <param name="minX"></param>
        /// <param name="maxX"></param>
        /// <returns></returns>
        public override List <Peak> FindPeaks(XYData xydata, double minX, double maxX)
        {
            if (xydata == null || xydata.Xvalues == null || xydata.Xvalues.Length == 0)
            {
                return(null);
            }

            var xvals = xydata.Xvalues.ToList();
            var yvals = xydata.Yvalues.ToList();

            //initialize DeconEngine's peakFinding class
            peakProcessor = new PeakProcessor();

            //initialize options

            //this.isDataThresholded = resultList.Run.IsDataThresholded;   [commented out:  2010_04_05 by gord]
            UpdateDeconEngineParameters();

            BackgroundIntensity = peakProcessor.GetBackgroundIntensity(yvals);
            peakProcessor.SetOptions(SignalToNoiseThreshold, BackgroundIntensity * PeakToBackgroundRatio, IsDataThresholded, GetDeconPeakFitType(PeakFitType));

            //Find peaks using DeconEngine
            if (minX == 0 && maxX == 0)
            {
                minX = xydata.Xvalues.First();
                maxX = xydata.Xvalues.Last();
            }

            try
            {
                peakProcessor.DiscoverPeaks(xvals, yvals, minX, maxX);
            }
            catch (Exception ex)
            {
                Logger.Instance.AddEntry("DeconToolsPeakDetector.FindPeaks exception: " + ex.Message, Logger.Instance.OutputFilename);
                throw;
            }

            DeconEnginePeakList = peakProcessor.PeakData.PeakTops;

            return(ConvertDeconEnginePeakList(DeconEnginePeakList));
        }
Beispiel #6
0
 private void UpdateDeconEngineParameters()
 {
     peakProcessor.SetOptions(SignalToNoiseThreshold, 0, IsDataThresholded, GetDeconPeakFitType(PeakFitType));
 }