OpenMS  2.7.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-2021.
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 
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 
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 
129 
132 
134  float fwhm_bound_;
135 
138 
140  float scale_;
141 
144 
147 
150 
153 
156 
157 
158  void updateMembers_() override;
159 
170  struct OPENMS_DLLAPI PeakArea_
171  {
172  typedef MSSpectrum::iterator PeakIterator;
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 
This class computes the continuous wavelet transformation using a marr wavelet.
Definition: ContinuousWaveletTransformNumIntegration.h:58
This class is the base class of the continuous wavelet transformation.
Definition: ContinuousWaveletTransform.h:47
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:93
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:80
The representation of a 1D spectrum.
Definition: MSSpectrum.h:71
Class containing the data needed for optimization.
Definition: OptimizePeakDeconvolution.h:111
This class implements a peak picking algorithm using wavelet techniques.
Definition: PeakPickerCWT.h:81
float scale_
The dilation of the wavelet.
Definition: PeakPickerCWT.h:140
bool optimization_
Switch for the optimization of peak parameters.
Definition: PeakPickerCWT.h:149
bool deconvolution_
Switch for the deconvolution of peak parameters.
Definition: PeakPickerCWT.h:152
Int getNumberOfPeaks_(ConstPeakIterator first, ConstPeakIterator last, std::vector< double > &peak_values, Int direction, double resolution, ContinuousWaveletTransformNumIntegration &wt, double peak_bound_cwt) const
Determines the number of peaks in the given mass range using the cwt.
float signal_to_noise_
Signal to noise threshold.
Definition: PeakPickerCWT.h:131
float peak_bound_
Threshold for the peak height in the MS 1 level.
Definition: PeakPickerCWT.h:125
void pickExperiment(const PeakMap &input, PeakMap &output)
Picks the peaks in an MSExperiment.
void pick(const MSSpectrum &input, MSSpectrum &output) const
Applies the peak picking algorithm to a single spectrum.
UInt radius_
The search radius for the determination of a peak's maximum position.
Definition: PeakPickerCWT.h:137
bool two_d_optimization_
Switch for the 2D optimization of peak parameters.
Definition: PeakPickerCWT.h:155
bool deconvolutePeak_(PeakShape &shape, std::vector< PeakShape > &peak_shapes, double peak_bound_cwt) const
Separates overlapping peaks.
void addPeak_(std::vector< PeakShape > &peaks_DC, PeakArea_ &area, double left_width, double right_width, OptimizePeakDeconvolution::Data &data) const
Add a peak.
void initializeWT_(ContinuousWaveletTransformNumIntegration &wt, const double peak_bound_in, double &peak_bound_ms_cwt) const
Computes the threshold for the peak height in the wavelet transform and initializes the wavelet trans...
PeakPickerCWT()
Constructor.
PeakIterator left
iterator to the leftmost valid point
Definition: PeakPickerCWT.h:173
MSSpectrum::const_iterator ConstPeakIterator
Const profile data iterator type.
Definition: PeakPickerCWT.h:86
double correlate_(const PeakShape &peak, const PeakArea_ &area, Int direction=0) const
Returns the squared Pearson coefficient.
void getPeakCentroid_(PeakArea_ &area) const
Estimates a peak's centroid position.
PeakIterator right
iterator to the rightmost valid point (inclusive)
Definition: PeakPickerCWT.h:175
DPosition< 1 > centroid_position
The estimated centroid position in m/z.
Definition: PeakPickerCWT.h:176
float peak_corr_bound_
The threshold for correlation.
Definition: PeakPickerCWT.h:143
double estimatePeakWidth(const PeakMap &input)
Estimates average peak width that can then be used for peak picking.
float peak_bound_ms2_level_
Threshold for the peak height in the MS 2 level.
Definition: PeakPickerCWT.h:128
void getPeakArea_(const PeakArea_ &area, double &area_left, double &area_right) const
Computes the peak's left and right area.
bool getMaxPosition_(const PeakIterator first, const PeakIterator last, const ContinuousWaveletTransform &wt, PeakArea_ &area, const Int distance_from_scan_border, const double peak_bound_cwt, const double peak_bound_ms2_level_cwt, const Int direction=1) const
Finds the next maximum position in the wavelet transform wt.
float noise_level_
The threshold for the noise level (TODO: Use the information of the signal to noise estimator)
Definition: PeakPickerCWT.h:146
float fwhm_bound_
The minimal full width at half maximum.
Definition: PeakPickerCWT.h:134
MSSpectrum::iterator PeakIterator
Profile data iterator type.
Definition: PeakPickerCWT.h:84
void updateMembers_() override
This method is used to update extra member variables at the end of the setParameters() method.
~PeakPickerCWT() override
Destructor.
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
bool getPeakEndPoints_(PeakIterator first, PeakIterator last, PeakArea_ &area, Int distance_from_scan_border, Int &peak_left_index, Int &peak_right_index, ContinuousWaveletTransformNumIntegration &wt) const
Determines a peaks's endpoints.
PeakShape fitPeakShape_(const PeakArea_ &area) const
Returns the best fitting peakshape.
PeakIterator max
iterator to the maximum position
Definition: PeakPickerCWT.h:174
Int determineChargeState_(std::vector< double > &peak_values) const
Estimate the charge state of the peaks.
Class for the internal peak representation.
Definition: PeakPickerCWT.h:171
Internal representation of a peak shape (used by the PeakPickerCWT)
Definition: PeakShape.h:51
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:55
int Int
Signed integer type.
Definition: Types.h:102
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47