| OpenMS 2.5.0

PeakPickerCWT.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2020.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Timo Sachsenberg $
32 // $Authors: Eva Lange, Alexandra Zerck $
33 // --------------------------------------------------------------------------
34 //
35 #pragma once
36
37 #include <OpenMS/KERNEL/StandardTypes.h>
38 #include <OpenMS/KERNEL/MSExperiment.h>
39 #include <OpenMS/DATASTRUCTURES/DefaultParamHandler.h>
40 #include <OpenMS/CONCEPT/ProgressLogger.h>
41 #include <OpenMS/TRANSFORMATIONS/RAW2PEAK/OptimizePeakDeconvolution.h>
42 #include <OpenMS/TRANSFORMATIONS/RAW2PEAK/ContinuousWaveletTransform.h>
43 #include <OpenMS/TRANSFORMATIONS/RAW2PEAK/ContinuousWaveletTransformNumIntegration.h>
44
45 //#define DEBUG_PEAK_PICKING
46 #undef DEBUG_PEAK_PICKING
47 //#define DEBUG_DECONV
48 namespace OpenMS
49 {
50 class PeakShape;
51
78 class OPENMS_DLLAPI PeakPickerCWT :
79 public DefaultParamHandler,
80 public ProgressLogger
81 {
82 public:
84 typedef MSSpectrum::iterator PeakIterator;
86 typedef MSSpectrum::const_iterator ConstPeakIterator;
87
89 PeakPickerCWT();
90
92 ~PeakPickerCWT() override;
93
99 void pick(const MSSpectrum & input, MSSpectrum & output) const;
100
108 void pickExperiment(const PeakMap & input, PeakMap & output);
109
120 double estimatePeakWidth(const PeakMap & input);
121
122 protected:
123
125 float peak_bound_;
126
128 float peak_bound_ms2_level_;
129
131 float signal_to_noise_;
132
134 float fwhm_bound_;
135
137 UInt radius_;
138
140 float scale_;
141
143 float peak_corr_bound_;
144
146 float noise_level_;
147
149 bool optimization_;
150
152 bool deconvolution_;
153
155 bool two_d_optimization_;
156
157
158 void updateMembers_() override;
159
170 struct OPENMS_DLLAPI PeakArea_
171 {
172 typedef MSSpectrum::iterator PeakIterator;
173 PeakIterator left;
174 PeakIterator max;
175 PeakIterator right;
176 DPosition<1> centroid_position;
177 };
178
180 void getPeakArea_(const PeakArea_ & area, double & area_left, double & area_right) const;
181
183 PeakShape fitPeakShape_(const PeakArea_ & area) const;
184
191 double correlate_(const PeakShape & peak, const PeakArea_ & area, Int direction = 0) const;
192
193
202 bool getMaxPosition_(const PeakIterator first, const PeakIterator last, const ContinuousWaveletTransform & wt,
203 PeakArea_ & area, const Int distance_from_scan_border,
204 const double peak_bound_cwt, const double peak_bound_ms2_level_cwt, const Int direction = 1) const;
205
206
226 bool getPeakEndPoints_(PeakIterator first, PeakIterator last, PeakArea_ & area, Int distance_from_scan_border,
227 Int & peak_left_index, Int & peak_right_index, ContinuousWaveletTransformNumIntegration & wt) const;
228
229
236 void getPeakCentroid_(PeakArea_ & area) const;
237
239 inline double lorentz_(const double height, const double lambda, const double pos, const double x) const
240 {
241 const double x2 = lambda * (x - pos);
242 return height / (1 + x2*x2);
243 }
244
254 void initializeWT_(ContinuousWaveletTransformNumIntegration& wt, const double peak_bound_in, double& peak_bound_ms_cwt) const;
255
259
266 bool deconvolutePeak_(PeakShape & shape, std::vector<PeakShape> & peak_shapes, double peak_bound_cwt) const;
267
269 Int getNumberOfPeaks_(ConstPeakIterator first, ConstPeakIterator last, std::vector<double> & peak_values,
270 Int direction, double resolution, ContinuousWaveletTransformNumIntegration & wt, double peak_bound_cwt) const;
271
273 Int determineChargeState_(std::vector<double> & peak_values) const;
274
276 void addPeak_(std::vector<PeakShape> & peaks_DC, PeakArea_ & area, double left_width, double right_width, OptimizePeakDeconvolution::Data & data) const;
278 }; // end PeakPickerCWT
279
280 } // namespace OpenMS
281
OpenMS::PeakPickerCWT::ConstPeakIterator
MSSpectrum::const_iterator ConstPeakIterator
Const profile data iterator type.
Definition: PeakPickerCWT.h:86
OpenMS::PeakPickerCWT::lorentz_
double lorentz_(const double height, const double lambda, const double pos, const double x) const
Computes the value of a theoretical Lorentz peak at position x.
Definition: PeakPickerCWT.h:239
OpenMS::DefaultParamHandler
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:91
OpenMS::ContinuousWaveletTransform
This class is the base class of the continuous wavelet transformation.
Definition: ContinuousWaveletTransform.h:46
OpenMS::MSExperiment
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:77
OpenMS::PeakPickerCWT::deconvolution_
bool deconvolution_
Switch for the deconvolution of peak parameters.
Definition: PeakPickerCWT.h:152
StandardTypes.h
OpenMS::PeakPickerCWT::two_d_optimization_
bool two_d_optimization_
Switch for the 2D optimization of peak parameters.
Definition: PeakPickerCWT.h:155
OpenMS::PeakPickerCWT::PeakArea_::left
PeakIterator left
iterator to the leftmost valid point
Definition: PeakPickerCWT.h:173
OpenMS::PeakPickerCWT::peak_bound_
float peak_bound_
Threshold for the peak height in the MS 1 level.
Definition: PeakPickerCWT.h:125
ContinuousWaveletTransformNumIntegration.h
OpenMS::OptimizePeakDeconvolution::Data
Class containing the data needed for optimization.
Definition: OptimizePeakDeconvolution.h:110
OpenMS::MSSpectrum
The representation of a 1D spectrum.
Definition: MSSpectrum.h:67
OpenMS::PeakPickerCWT::scale_
float scale_
The dilation of the wavelet.
Definition: PeakPickerCWT.h:140
OptimizePeakDeconvolution.h
OpenMS::PeakShape
Internal representation of a peak shape (used by the PeakPickerCWT)
Definition: PeakShape.h:50
ProgressLogger.h
OpenMS::PeakPickerCWT::peak_corr_bound_
float peak_corr_bound_
The threshold for correlation.
Definition: PeakPickerCWT.h:143
OpenMS::PeakPickerCWT::PeakArea_::right
PeakIterator right
iterator to the rightmost valid point (inclusive)
Definition: PeakPickerCWT.h:175
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
MSExperiment.h
OpenMS::ProgressLogger
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:54
OpenMS::ContinuousWaveletTransformNumIntegration
This class computes the continuous wavelet transformation using a marr wavelet.
Definition: ContinuousWaveletTransformNumIntegration.h:56
OpenMS::PeakPickerCWT::PeakIterator
MSSpectrum::iterator PeakIterator
Profile data iterator type.
Definition: PeakPickerCWT.h:84
DefaultParamHandler.h
ContinuousWaveletTransform.h
OpenMS::PeakPickerCWT
This class implements a peak picking algorithm using wavelet techniques.
Definition: PeakPickerCWT.h:78
OpenMS::PeakPickerCWT::PeakArea_::centroid_position
DPosition< 1 > centroid_position
The estimated centroid position in m/z.
Definition: PeakPickerCWT.h:176
OpenMS::UInt
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
OpenMS::PeakPickerCWT::fwhm_bound_
float fwhm_bound_
The minimal full width at half maximum.
Definition: PeakPickerCWT.h:134
OpenMS::PeakPickerCWT::noise_level_
float noise_level_
The threshold for the noise level (TODO: Use the information of the signal to noise estimator) ...
Definition: PeakPickerCWT.h:146
OpenMS::DPosition< 1 >
OpenMS::PeakPickerCWT::PeakArea_
Class for the internal peak representation.
Definition: PeakPickerCWT.h:170
OpenMS::PeakPickerCWT::signal_to_noise_
float signal_to_noise_
Signal to noise threshold.
Definition: PeakPickerCWT.h:131
OpenMS::PeakPickerCWT::optimization_
bool optimization_
Switch for the optimization of peak parameters.
Definition: PeakPickerCWT.h:149
int
OpenMS::PeakPickerCWT::radius_
UInt radius_
The search radius for the determination of a peak&#39;s maximum position.
Definition: PeakPickerCWT.h:137
OpenMS::PeakPickerCWT::PeakArea_::max
PeakIterator max
iterator to the maximum position
Definition: PeakPickerCWT.h:174
OpenMS::PeakPickerCWT::peak_bound_ms2_level_
float peak_bound_ms2_level_
Threshold for the peak height in the MS 2 level.
Definition: PeakPickerCWT.h:128