Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
ContinuousWaveletTransform.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-2017.
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 $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_TRANSFORMATIONS_RAW2PEAK_CONTINUOUSWAVELETTRANSFORM_H
36 #define OPENMS_TRANSFORMATIONS_RAW2PEAK_CONTINUOUSWAVELETTRANSFORM_H
37 
38 #include <OpenMS/KERNEL/Peak1D.h>
39 
40 #include <vector>
41 
42 namespace OpenMS
43 {
47  class OPENMS_DLLAPI ContinuousWaveletTransform
48  {
49 public:
51  typedef std::vector<Peak1D>::const_iterator PeakConstIterator;
52 
53 
56  scale_(0),
57  spacing_(0),
58  signal_length_(0),
59  end_left_padding_(0),
60  begin_right_padding_(0)
61  {}
62 
65  {}
66 
68  inline const std::vector<Peak1D> & getSignal() const
69  {
70  return signal_;
71  }
72 
74  inline std::vector<Peak1D> & getSignal()
75  {
76  return signal_;
77  }
78 
80  inline void setSignal(const std::vector<Peak1D> & signal)
81  {
82  signal_ = signal;
83  }
84 
86  inline const std::vector<double> & getWavelet() const
87  {
88  return wavelet_;
89  }
90 
92  inline std::vector<double> & getWavelet()
93  {
94  return wavelet_;
95  }
96 
98  inline void setWavelet(const std::vector<double> & wavelet)
99  {
100  wavelet_ = wavelet;
101  }
102 
103  // Non-mutable access to the scale of the wavelet
104  inline double getScale() const
105  {
106  return scale_;
107  }
108 
110  inline double & getScale()
111  {
112  return scale_;
113  }
114 
116  inline void setScale(double scale)
117  {
118  scale_ = scale;
119  }
120 
121  // Non-mutable access to the spacing of raw data
122  inline double getSpacing() const
123  {
124  return spacing_;
125  }
126 
128  inline double & getSpacing()
129  {
130  return spacing_;
131  }
132 
134  inline void setSpacing(double spacing)
135  {
136  spacing_ = spacing;
137  }
138 
141  {
142  return end_left_padding_;
143  }
144 
147  {
148  return end_left_padding_;
149  }
150 
152  inline void setLeftPaddingIndex(const SignedSize end_left_padding)
153  {
154  end_left_padding_ = end_left_padding;
155  }
156 
159  {
160  return begin_right_padding_;
161  }
162 
165  {
166  return begin_right_padding_;
167  }
168 
170  inline void setRightPaddingIndex(const SignedSize begin_right_padding)
171  {
172  begin_right_padding_ = begin_right_padding;
173  }
174 
177  {
178  return signal_length_;
179  }
180 
183  {
184  return signal_length_;
185  }
186 
188  inline void setSignalLength(const SignedSize signal_length)
189  {
190  signal_length_ = signal_length;
191  }
192 
194  inline int getSize() const
195  {
196  return (int) signal_.size();
197  }
198 
202  virtual void init(double scale, double spacing);
203 
204 
206  inline double operator[](unsigned int i)
207  {
208  return signal_[i].getIntensity();
209  }
210 
211  inline double operator[](unsigned int i) const
212  {
213  return signal_[i].getIntensity();
214  }
215 
216 protected:
218  std::vector<Peak1D> signal_;
219 
221  std::vector<double> wavelet_;
222 
224  double scale_;
225  double spacing_;
227 
233 
234  template <typename InputPeakIterator>
235  double getInterpolatedValue_(double x, InputPeakIterator it_left)
236  {
237  // Interpolate between the point to the left and the point to the right.
238  double left_position = it_left->getMZ();
239  double right_position = (it_left + 1)->getMZ();
240  double d = (x - left_position) / (right_position - left_position);
241 
242  return (it_left + 1)->getIntensity() * d + it_left->getIntensity() * (1 - d);
243  }
244 
245  };
246 
247 } //namespace OpenMS
248 
249 #endif
SignedSize & getLeftPaddingIndex()
Mutable access to the position where the signal starts.
Definition: ContinuousWaveletTransform.h:146
SignedSize & getRightPaddingIndex()
Mutable access to the position where the signal starts.
Definition: ContinuousWaveletTransform.h:164
virtual ~ContinuousWaveletTransform()
Destructor.
Definition: ContinuousWaveletTransform.h:64
double getScale() const
Definition: ContinuousWaveletTransform.h:104
int getSize() const
Non-mutable access to signal length including padded zeros [0,end].
Definition: ContinuousWaveletTransform.h:194
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:135
double scale_
Spacing and scale of the wavelet and length of the signal.
Definition: ContinuousWaveletTransform.h:224
double getInterpolatedValue_(double x, InputPeakIterator it_left)
Definition: ContinuousWaveletTransform.h:235
double getSpacing() const
Definition: ContinuousWaveletTransform.h:122
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
This class is the base class of the continuous wavelet transformation.
Definition: ContinuousWaveletTransform.h:47
void setRightPaddingIndex(const SignedSize begin_right_padding)
Mutable access to position where the signal starts.
Definition: ContinuousWaveletTransform.h:170
double & getScale()
Mutable access to the spacing of raw data.
Definition: ContinuousWaveletTransform.h:110
SignedSize getRightPaddingIndex() const
Non-mutable access to the position where the signal ends (in the interval (begin_right_padding_,end] are the padded zeros)
Definition: ContinuousWaveletTransform.h:158
void setScale(double scale)
Mutable access to the spacing of raw data.
Definition: ContinuousWaveletTransform.h:116
void setSignalLength(const SignedSize signal_length)
Mutable access to signal length [end_left_padding,begin_right_padding].
Definition: ContinuousWaveletTransform.h:188
const std::vector< Peak1D > & getSignal() const
Non-mutable access to the wavelet transform of the signal.
Definition: ContinuousWaveletTransform.h:68
SignedSize begin_right_padding_
Definition: ContinuousWaveletTransform.h:232
ContinuousWaveletTransform()
Constructor.
Definition: ContinuousWaveletTransform.h:55
std::vector< double > & getWavelet()
Mutable access to the wavelet.
Definition: ContinuousWaveletTransform.h:92
const std::vector< double > & getWavelet() const
Non-mutable access to the wavelet.
Definition: ContinuousWaveletTransform.h:86
SignedSize end_left_padding_
Definition: ContinuousWaveletTransform.h:231
SignedSize signal_length_
Definition: ContinuousWaveletTransform.h:226
SignedSize getSignalLength() const
Non-mutable access to signal length [end_left_padding,begin_right_padding].
Definition: ContinuousWaveletTransform.h:176
void setSpacing(double spacing)
Mutable access to the spacing of raw data.
Definition: ContinuousWaveletTransform.h:134
SignedSize & getSignalLength()
Mutable access to signal length [end_left_padding,begin_right_padding].
Definition: ContinuousWaveletTransform.h:182
void setLeftPaddingIndex(const SignedSize end_left_padding)
Mutable access to position where the signal starts.
Definition: ContinuousWaveletTransform.h:152
double operator[](unsigned int i)
Yields the signal (intensity) at position i.
Definition: ContinuousWaveletTransform.h:206
std::vector< Peak1D > signal_
The transformed signal.
Definition: ContinuousWaveletTransform.h:218
std::vector< double > wavelet_
The pre-tabulated wavelet used for the transform.
Definition: ContinuousWaveletTransform.h:221
double operator[](unsigned int i) const
Definition: ContinuousWaveletTransform.h:211
std::vector< Peak1D >::const_iterator PeakConstIterator
Raw data const iterator type.
Definition: ContinuousWaveletTransform.h:51
SignedSize getLeftPaddingIndex() const
Non-mutable access to the position where the signal starts (in the interval [0,end_left_padding_) are...
Definition: ContinuousWaveletTransform.h:140
double spacing_
Definition: ContinuousWaveletTransform.h:225
void setWavelet(const std::vector< double > &wavelet)
Mutable access to the signal.
Definition: ContinuousWaveletTransform.h:98
std::vector< Peak1D > & getSignal()
Mutable access to the wavelet transform of the signal.
Definition: ContinuousWaveletTransform.h:74
void setSignal(const std::vector< Peak1D > &signal)
Mutable access to the wavelet transform of the signal.
Definition: ContinuousWaveletTransform.h:80
double & getSpacing()
Mutable access to the spacing of raw data.
Definition: ContinuousWaveletTransform.h:128

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:21:59 using doxygen 1.8.13