public static float[] IntegrateTranslatedPeak(Peak peak, double delta, SpectrumCache spectrumCache, IRawFile rawFile, bool subtractBackground, int backgroundSubtractionQuantile) { int[] scanIndices = peak.GetScanIndices(); float[] intensities = peak.GetOriginalIntensities(); int q = ArrayUtil.MaxInd(intensities); float maxInt = intensities[q]; int maxScanIndex = scanIndices[q]; float[] result = new float[scanIndices.Length]; for (int i = 0; i < scanIndices.Length; i++) { int scanIndex = scanIndices[i]; if (intensities[i] < maxInt * 0.01) { continue; } if (scanIndex > maxScanIndex + 20 || scanIndex < maxScanIndex - 20) { continue; } Spectrum spectrum; if (!spectrumCache.ContainsScanIndex(scanIndex)) { spectrum = rawFile.GetMS1Spectrum(scanIndex, subtractBackground, backgroundSubtractionQuantile); spectrumCache.Add(scanIndex, spectrum); } else { spectrum = spectrumCache[scanIndex]; } double minMass = peak.GetMinMass(i) + delta; double maxMass = peak.GetMaxMass(i) + delta; int minInd = spectrum.GetCeilIndex(minMass); int maxInd = spectrum.GetFloorIndex(maxMass); if (minInd == -1 || maxInd == -1) { result[i] = 0; } else { float[] intensityProfile = new float[maxInd - minInd + 1]; for (int ind = minInd; ind <= maxInd; ind++) { intensityProfile[ind - minInd] = spectrum.GetIntensity(ind); } result[i] = IntegrateProfile(intensityProfile, T01PeakDetection.maxIntensity); } } return(result); }