//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); }
/// <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)); }