/// <summary> /// Get a chromatogram with properly sorted time values. /// </summary> public void ReleaseChromatogram(byte[] bytesFromDisk, out TimeIntensities timeIntensities) { var times = Times.ToArray(bytesFromDisk); var intensities = Intensities.ToArray(bytesFromDisk); var massErrors = MassErrors != null ? MassErrors.ToArray(bytesFromDisk) : null; var scanIds = Scans != null ? Scans.ToArray(bytesFromDisk) : null; // Make sure times and intensities match in length. if (times.Length != intensities.Length) { throw new InvalidDataException( string.Format(Resources.ChromCollected_ChromCollected_Times__0__and_intensities__1__disagree_in_point_count, times.Length, intensities.Length)); } if (massErrors != null && massErrors.Length != intensities.Length) { throw new InvalidDataException( string.Format(Resources.ChromCollector_ReleaseChromatogram_Intensities___0___and_mass_errors___1___disagree_in_point_count_, intensities.Length, massErrors.Length)); } timeIntensities = new TimeIntensities(times, intensities, massErrors, scanIds); // Release memory. Times = null; Intensities = null; MassErrors = null; Scans = null; }
public void FindPeaks(double[] retentionTimes, TimeIntervals timeIntervals, ExplicitRetentionTimeInfo explicitRT) { Finder = Crawdads.NewCrawdadPeakFinder(); Finder.SetChromatogram(Times, Intensities); if (timeIntervals == null) { RawPeaks = Finder.CalcPeaks(MAX_PEAKS, TimesToIndices(retentionTimes)); } else { var identifiedIndices = TimesToIndices(retentionTimes); var allPeaks = timeIntervals.Intervals.SelectMany(interval => FindIntervalPeaks(interval.Key, interval.Value, identifiedIndices)); RawPeaks = allPeaks.OrderByDescending(peak => Tuple.Create(peak.Identified, peak.Area)) .Take(MAX_PEAKS).ToArray(); } // Calculate smoothing for later use in extending the Crawdad peaks IntensitiesSmooth = ChromatogramInfo.SavitzkyGolaySmooth(Intensities.ToArray()); // Accept only peaks within the user-provided RT window, if any if (explicitRT != null) { var winLow = (float)(explicitRT.RetentionTime - 0.5 * (explicitRT.RetentionTimeWindow ?? 0)); var winHigh = winLow + (float)(explicitRT.RetentionTimeWindow ?? 0); RawPeaks = RawPeaks.Where(rp => { var t = Times[rp.TimeIndex]; return(winLow <= t && t <= winHigh); }); } }
/// <summary> /// Get a chromatogram with properly sorted time values. /// </summary> public void ReleaseChromatogram(byte[] bytesFromDisk, out float[] times, out float[] intensities, out float[] massErrors, out int[] scanIds) { times = Times.ToArray(bytesFromDisk); intensities = Intensities.ToArray(bytesFromDisk); massErrors = MassErrors != null ? MassErrors.ToArray(bytesFromDisk) : null; scanIds = Scans != null ? Scans.ToArray(bytesFromDisk) : null; // Release memory. Times = null; Intensities = null; MassErrors = null; Scans = null; // Make sure times and intensities match in length. if (times.Length != intensities.Length) { throw new InvalidDataException( string.Format(Resources.ChromCollected_ChromCollected_Times__0__and_intensities__1__disagree_in_point_count, times.Length, intensities.Length)); } }
public void FindPeaks(double[] retentionTimes) { Finder = Crawdads.NewCrawdadPeakFinder(); Finder.SetChromatogram(Times, Intensities); RawPeaks = Finder.CalcPeaks(MAX_PEAKS, TimesToIndices(retentionTimes)); // Calculate smoothing for later use in extending the Crawdad peaks IntensitiesSmooth = ChromatogramInfo.SavitzkyGolaySmooth(Intensities.ToArray()); }
public void FindPeaks(double[] retentionTimes, bool requireDocNode) { Finder = Crawdads.NewCrawdadPeakFinder(); Finder.SetChromatogram(Times, Intensities); if (requireDocNode && DocNode == null) { RawPeaks = new IFoundPeak[0]; } else { RawPeaks = Finder.CalcPeaks(MAX_PEAKS, TimesToIndices(retentionTimes)); // Calculate smoothing for later use in extending the Crawdad peaks IntensitiesSmooth = ChromatogramInfo.SavitzkyGolaySmooth(Intensities.ToArray()); } }