public static ExtractedIonChromatogram AverageXICFromFrames(DataReader uimfReader, int frameNumberFrom, int frameNumberTo, double centerMz, double massToleranceInPpm, double centerDriftTimeInMs, double driftTimeErrorInMs) { ExtractedIonChromatogram result = new ExtractedIonChromatogram(); for ( int i = frameNumberFrom; i <= frameNumberTo; i++) { var xic = new ExtractedIonChromatogram(uimfReader, i, centerMz, massToleranceInPpm, centerDriftTimeInMs, driftTimeErrorInMs); if (i == frameNumberFrom) { result = xic; } else { result += xic; } } return result; }
/// <summary> /// Initializes a new instance of the <see cref="ExtractedIonChromatogram"/> class. /// XIC is a list of intensity points sorted by Mobility Scan number from low to high. /// </summary> /// <param name="a"> /// The a. /// </param> /// <param name="b"> /// The b. /// </param> /// <exception cref="InvalidOperationException"> /// </exception> private ExtractedIonChromatogram(ExtractedIonChromatogram a, ExtractedIonChromatogram b) { if (a.NumberOfMobilityScans != b.NumberOfMobilityScans || !a.CenterMz.Equals(b.CenterMz)) { throw new InvalidOperationException("Cannot sum XICs with different number of mobilities or different MZ."); } this.CenterMz = a.CenterMz; this.NumberOfMobilityScans = b.NumberOfMobilityScans; this.IntensityPoints = addSortedIntensityPointList(a.IntensityPoints, b.IntensityPoints, this.NumberOfMobilityScans); }
/// <summary> /// The +. /// </summary> /// <param name="A"> /// The a. /// </param> /// <param name="B"> /// The b. /// </param> /// <returns> /// </returns> public static ExtractedIonChromatogram operator +(ExtractedIonChromatogram A, ExtractedIonChromatogram B) { ExtractedIonChromatogram result = new ExtractedIonChromatogram(A, B); return result; }
/// <summary> /// The find peaks based on xic. /// </summary> /// <param name="group"> /// The group. /// </param> /// <param name="chromatogram"> /// The chromatogram. /// </param> /// <param name="target"> /// The target. /// </param> /// <returns> /// The <see cref="IList"/>. /// </returns> /// <exception cref="NotImplementedException"> /// </exception> private List<StandardImsPeak> FindPeaksBasedOnXIC(VoltageGroup voltageGroup, ExtractedIonChromatogram chromatogram, IImsTarget target) { if (this.Parameters.PeakDetectorSelection == PeakDetectorEnum.WaterShed) { // Find peaks using multidimensional peak finder. List<IntensityPoint> intensityPoints = chromatogram.IntensityPoints; List<FeatureBlob> featureBlobs = PeakFinding.FindPeakUsingWatershed(intensityPoints, this.smoother, this.Parameters.FeatureFilterLevel); // Recapture the 2D peak using the 1D feature blob from multidimensional peak finder. return featureBlobs.Select(featureBlob => new StandardImsPeak(featureBlob, this.uimfReader, voltageGroup, target.MassWithAdduct, this.Parameters.MzWindowHalfWidthInPpm)).ToList(); } else if (this.Parameters.PeakDetectorSelection == PeakDetectorEnum.MASICPeakFinder) { // Find peaks using MASIC peak finder List<IntensityPoint> intensityPoints = chromatogram.IntensityPoints; IList<clsPeak> masicPeaks = PeakFinding.FindPeakUsingMasic(intensityPoints, this.NumberOfScans); // Recapture the 2D peak using the 1D feature blob from multidimensional peak finder. return masicPeaks.Select(peak => new StandardImsPeak(peak)).ToList(); } else { throw new NotImplementedException(string.Format("{0} not supported", this.Parameters.PeakDetectorSelection)); } }