public ISpectrum Process(ISpectrum spectrum) { List <IPeak> peaks = spectrum.GetPeaks(); double[] signal = peaks.Select(p => p.GetIntensity()).ToArray(); SortedDictionary <double, List <double> > matrix = new SortedDictionary <double, List <double> >(); for (double a = 1.0; a <= maxScale; a += steps) { double[] processed = Algorithm.CWT.Transform(signal, a); matrix[a] = processed.ToList(); } List <RidgeLine> lines = finder.Find( spectrum.GetPeaks().Select(p => p.GetMZ()).ToList(), matrix); HashSet <double> mz = new HashSet <double>(lines.Select(p => p.Pos).ToList()); List <IPeak> processedPeaks = peaks.Where(p => mz.Contains(p.GetMZ())).ToList(); ISpectrum newSpectrum = spectrum.Clone(); newSpectrum.SetPeaks(processedPeaks); return(newSpectrum); }
public ISpectrum Process(ISpectrum spectrum) { List <IPeak> peaks = peakpick(spectrum.GetPeaks(), maxPeaks); peaks.Sort(); NormalizePeaks(peaks, factor); spectrum.SetPeaks(peaks); return(spectrum); }
public void Process(ISpectrum spectrum) { List <IPeak> peaks = spectrum.GetPeaks() .OrderByDescending(pk => pk.GetIntensity()) .Take(maxPeaks) .OrderBy(pk => pk.GetMZ()).ToList();; spectrum.SetPeaks(peaks); }
public ISpectrum Process(ISpectrum spectrum) { ISpectrum filtered = peakPicking.Process(spectrum); List <IPeak> peaks = new List <IPeak>(); double minIntensity = filtered.GetPeaks().Min(p => p.GetIntensity()); filtered.SetPeaks( peaks.Where(p => p.GetIntensity() > ratio * minIntensity).ToList()); return(filtered); }
public ISpectrum Process(ISpectrum spectrum) { if (spectrum.GetPeaks().Count == 0) { return(spectrum); } // insert pseudo peaks for large gap List <IPeak> peaks = new List <IPeak>(); double mz = spectrum.GetPeaks().First().GetMZ(); peaks.Add(new GeneralPeak(mz - precision, 0)); foreach (IPeak peak in spectrum.GetPeaks()) { if (peak.GetMZ() - mz > precision) { double middle = (mz + peak.GetMZ()) / 2; peaks.Add(new GeneralPeak(middle, 0)); } peaks.Add(peak); mz = peak.GetMZ(); } peaks.Add(new GeneralPeak(mz + precision, 0)); List <IPeak> processedPeaks = new List <IPeak>(); int index = 1; int end = peaks.Count - 1; int head = index + 1; while (index < end) { if (peaks[index - 1].GetIntensity() < peaks[index].GetIntensity()) { head = index + 1; } while (head < end && peaks[head].GetIntensity() == peaks[index].GetIntensity()) { head++; } if (peaks[head].GetIntensity() < peaks[index].GetIntensity()) { processedPeaks.Add(peaks[index]); index = head; } index++; } ISpectrum newSpectrum = spectrum.Clone(); newSpectrum.SetPeaks(processedPeaks); return(newSpectrum); }
public void Process(ISpectrum spectrum) { List <IPeak> peaks = spectrum.GetPeaks(); //double sumsIntensity = Math.Log10(peaks.Sum(x => x.GetIntensity())); for (int i = 0; i < peaks.Count; i++) { peaks[i].SetIntensity(Math.Log10(peaks[i].GetIntensity()) * scale); } spectrum.SetPeaks(peaks); }
public ISpectrum Process(ISpectrum spectrum) { ISpectrum centroid = peakPicking.Process(spectrum); List <IPeak> peaks = new List <IPeak>(); foreach (IPeak cPeak in centroid.GetPeaks()) { List <IPeak> neighbors = NeighborPeaks(cPeak, spectrum.GetPeaks()); peaks.Add(Average(cPeak, neighbors)); } centroid.SetPeaks(peaks); return(centroid); }
public ISpectrum Process(ISpectrum spectrum) { if (spectrum.GetPeaks().Count == 0) { return(spectrum); } // insert pseudo peaks for large gap List <IPeak> peaks = InsertPeaks(spectrum); List <IPeak> processedPeaks = new List <IPeak>(); int index = 1; int end = peaks.Count - 1; int head = index + 1; while (index < end) { if (peaks[index - 1].GetIntensity() < peaks[index].GetIntensity()) { head = index + 1; } while (head < end && peaks[head].GetIntensity() == peaks[index].GetIntensity()) { head++; } if (peaks[head].GetIntensity() < peaks[index].GetIntensity()) { processedPeaks.Add(peaks[index]); index = head; } index++; } ISpectrum newSpectrum = spectrum.Clone(); newSpectrum.SetPeaks(processedPeaks); return(newSpectrum); }
public void Process(ISpectrum spectrum) { List <IPeak> peaks = peakPicker.Picking(spectrum.GetPeaks()); spectrum.SetPeaks(peaks); }