OpenMS
PeakPickerSH.h
Go to the documentation of this file.
1// Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Timo Sachsenberg $
6// $Authors: Florian Zeller $
7// --------------------------------------------------------------------------
8
9#pragma once
10
15
16// TODO: Check if I need this # PeakPickerSH.h
17#define DEBUG_PEAK_PICKING
18#undef DEBUG_PEAK_PICKING
19
20namespace OpenMS
21{
22 class OPENMS_DLLAPI PeakPickerSH :
24 public ProgressLogger
25 {
26public:
28
29 ~PeakPickerSH() override;
30
34 void pick(const MSSpectrum & input, MSSpectrum & output, float fWindowWidth)
35 {
36 int i, hw, j;
37 double cm, toti, min_dh;
38
39 // Hack: Prepare data structures for Lukas' algorithm
40 std::vector<double> masses, intens;
41 // TODO: Probably we could save some time when we resize the vectors... # PeakPickerSH.cpp
42 //masses.resize(input.size());
43 //intens.resize(input.size());
44 for (Size k = 0; k < input.size() - 1; ++k)
45 {
46 // Lukas requires a minimum of intensity (=50). His vectors do not contain
47 // other data, so I strip the low ones out right here.
48 // TODO: Read 50.0 from parameters # PeakPickerSH.cpp
49 if (input[k].getIntensity() >= 50.0)
50 {
51 masses.push_back(input[k].getMZ());
52 intens.push_back(input[k].getIntensity());
53 }
54 }
55
56 min_dh = 50.0; // min height
57 hw = fWindowWidth / 2;
58
59 for (i = 2; i < (int)masses.size() - 2; i++)
60 {
61
62 // Peak must be concave in the interval [i-2 .. i+2]
63 if (intens[i] > min_dh && intens[i] > intens[i - 1] + min_dh && intens[i] >= intens[i + 1] && intens[i - 1] > intens[i - 2] + min_dh && intens[i + 1] >= intens[i + 2])
64 {
65
66 cm = 0.0; // centroid mass:
67 toti = 0.0; // total intensity:
68
69 for (j = -hw; j <= hw; j++)
70 {
71 double inte = intens[i - j];
72 double mz = masses[i - j];
73
74 cm += inte * mz;
75 toti += (double) intens[i - j];
76 }
77 cm = cm / toti; // Centre of gravity = centroid
78
79 Peak1D peak;
80 peak.setMZ(cm);
81 peak.setIntensity(intens[i]);
82 output.push_back(peak);
83 }
84 }
85 }
86
93 void pickExperiment(const PeakMap & input, PeakMap & output);
94 };
95}
96
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:66
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:46
The representation of a 1D spectrum.
Definition: MSSpectrum.h:44
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:28
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: Peak1D.h:84
void setMZ(CoordinateType mz)
Mutable access to m/z.
Definition: Peak1D.h:93
Definition: PeakPickerSH.h:25
~PeakPickerSH() override
void pickExperiment(const PeakMap &input, PeakMap &output)
Applies the peak-picking algorithm to a map (MSExperiment).
void pick(const MSSpectrum &input, MSSpectrum &output, float fWindowWidth)
Picks peaks in one spectrum.
Definition: PeakPickerSH.h:34
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:27
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:101
const double k
Definition: Constants.h:132
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22