OpenMS
PeakPickerCWT.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: Eva Lange, Alexandra Zerck $
7 // --------------------------------------------------------------------------
8 //
9 #pragma once
10 
18 
19 //#define DEBUG_PEAK_PICKING
20 #undef DEBUG_PEAK_PICKING
21 //#define DEBUG_DECONV
22 namespace OpenMS
23 {
24  class PeakShape;
25 
52  class OPENMS_DLLAPI PeakPickerCWT :
53  public DefaultParamHandler,
54  public ProgressLogger
55  {
56 public:
58  typedef MSSpectrum::iterator PeakIterator;
60  typedef MSSpectrum::const_iterator ConstPeakIterator;
61 
64 
66  ~PeakPickerCWT() override;
67 
73  void pick(const MSSpectrum & input, MSSpectrum & output) const;
74 
82  void pickExperiment(const PeakMap & input, PeakMap & output);
83 
94  double estimatePeakWidth(const PeakMap & input);
95 
96 protected:
97 
99  float peak_bound_;
100 
103 
106 
108  float fwhm_bound_;
109 
112 
114  float scale_;
115 
118 
121 
124 
127 
130 
131 
132  void updateMembers_() override;
133 
144  struct OPENMS_DLLAPI PeakArea_
145  {
146  typedef MSSpectrum::iterator PeakIterator;
151  };
152 
154  void getPeakArea_(const PeakArea_ & area, double & area_left, double & area_right) const;
155 
157  PeakShape fitPeakShape_(const PeakArea_ & area) const;
158 
165  double correlate_(const PeakShape & peak, const PeakArea_ & area, Int direction = 0) const;
166 
167 
176  bool getMaxPosition_(const PeakIterator first, const PeakIterator last, const ContinuousWaveletTransform & wt,
177  PeakArea_ & area, const Int distance_from_scan_border,
178  const double peak_bound_cwt, const double peak_bound_ms2_level_cwt, const Int direction = 1) const;
179 
180 
200  bool getPeakEndPoints_(PeakIterator first, PeakIterator last, PeakArea_ & area, Int distance_from_scan_border,
201  Int & peak_left_index, Int & peak_right_index, ContinuousWaveletTransformNumIntegration & wt) const;
202 
203 
210  void getPeakCentroid_(PeakArea_ & area) const;
211 
213  inline double lorentz_(const double height, const double lambda, const double pos, const double x) const
214  {
215  const double x2 = lambda * (x - pos);
216  return height / (1 + x2*x2);
217  }
218 
228  void initializeWT_(ContinuousWaveletTransformNumIntegration& wt, const double peak_bound_in, double& peak_bound_ms_cwt) const;
229 
233 
240  bool deconvolutePeak_(PeakShape & shape, std::vector<PeakShape> & peak_shapes, double peak_bound_cwt) const;
241 
243  Int getNumberOfPeaks_(ConstPeakIterator first, ConstPeakIterator last, std::vector<double> & peak_values,
244  Int direction, double resolution, ContinuousWaveletTransformNumIntegration & wt, double peak_bound_cwt) const;
245 
247  Int determineChargeState_(std::vector<double> & peak_values) const;
248 
250  void addPeak_(std::vector<PeakShape> & peaks_DC, PeakArea_ & area, double left_width, double right_width, OptimizePeakDeconvolution::Data & data) const;
252  }; // end PeakPickerCWT
253 
254 } // namespace OpenMS
255 
This class computes the continuous wavelet transformation using a marr wavelet.
Definition: ContinuousWaveletTransformNumIntegration.h:32
This class is the base class of the continuous wavelet transformation.
Definition: ContinuousWaveletTransform.h:21
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
Class containing the data needed for optimization.
Definition: OptimizePeakDeconvolution.h:85
This class implements a peak picking algorithm using wavelet techniques.
Definition: PeakPickerCWT.h:55
float scale_
The dilation of the wavelet.
Definition: PeakPickerCWT.h:114
bool optimization_
Switch for the optimization of peak parameters.
Definition: PeakPickerCWT.h:123
bool deconvolution_
Switch for the deconvolution of peak parameters.
Definition: PeakPickerCWT.h:126
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:105
float peak_bound_
Threshold for the peak height in the MS 1 level.
Definition: PeakPickerCWT.h:99
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:111
bool two_d_optimization_
Switch for the 2D optimization of peak parameters.
Definition: PeakPickerCWT.h:129
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:147
MSSpectrum::const_iterator ConstPeakIterator
Const profile data iterator type.
Definition: PeakPickerCWT.h:60
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:149
DPosition< 1 > centroid_position
The estimated centroid position in m/z.
Definition: PeakPickerCWT.h:150
float peak_corr_bound_
The threshold for correlation.
Definition: PeakPickerCWT.h:117
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:102
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:120
float fwhm_bound_
The minimal full width at half maximum.
Definition: PeakPickerCWT.h:108
MSSpectrum::iterator PeakIterator
Profile data iterator type.
Definition: PeakPickerCWT.h:58
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:213
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:148
Int determineChargeState_(std::vector< double > &peak_values) const
Estimate the charge state of the peaks.
Class for the internal peak representation.
Definition: PeakPickerCWT.h:145
Internal representation of a peak shape (used by the PeakPickerCWT)
Definition: PeakShape.h:25
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:27
int Int
Signed integer type.
Definition: Types.h:76
unsigned int UInt
Unsigned integer type.
Definition: Types.h:68
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22