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-2013.
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: Alexandra Zerck $
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 #include <iostream>
42 
43 namespace OpenMS
44 {
48  class OPENMS_DLLAPI ContinuousWaveletTransform
49  {
50 public:
52  typedef std::vector<Peak1D>::const_iterator PeakConstIterator;
53 
54 
57  scale_(0),
58  spacing_(0),
59  signal_length_(0),
60  end_left_padding_(0),
61  begin_right_padding_(0)
62  {}
63 
66  {}
67 
69  inline const std::vector<Peak1D> & getSignal() const
70  {
71  return signal_;
72  }
73 
75  inline std::vector<Peak1D> & getSignal()
76  {
77  return signal_;
78  }
79 
81  inline void setSignal(const std::vector<Peak1D> & signal)
82  {
83  signal_ = signal;
84  }
85 
87  inline const std::vector<double> & getWavelet() const
88  {
89  return wavelet_;
90  }
91 
93  inline std::vector<double> & getWavelet()
94  {
95  return wavelet_;
96  }
97 
99  inline void setWavelet(const std::vector<double> & wavelet)
100  {
101  wavelet_ = wavelet;
102  }
103 
104  // Non-mutable access to the scale of the wavelet
105  inline DoubleReal getScale() const
106  {
107  return scale_;
108  }
109 
111  inline double & getScale()
112  {
113  return scale_;
114  }
115 
117  inline void setScale(DoubleReal scale)
118  {
119  scale_ = scale;
120  }
121 
122  // Non-mutable access to the spacing of raw data
123  inline DoubleReal getSpacing() const
124  {
125  return spacing_;
126  }
127 
129  inline double & getSpacing()
130  {
131  return spacing_;
132  }
133 
135  inline void setSpacing(double spacing)
136  {
137  spacing_ = spacing;
138  }
139 
142  {
143  return end_left_padding_;
144  }
145 
148  {
149  return end_left_padding_;
150  }
151 
153  inline void setLeftPaddingIndex(const SignedSize end_left_padding)
154  {
155  end_left_padding_ = end_left_padding;
156  }
157 
160  {
161  return begin_right_padding_;
162  }
163 
166  {
167  return begin_right_padding_;
168  }
169 
171  inline void setRightPaddingIndex(const SignedSize begin_right_padding)
172  {
173  begin_right_padding_ = begin_right_padding;
174  }
175 
178  {
179  return signal_length_;
180  }
181 
184  {
185  return signal_length_;
186  }
187 
189  inline void setSignalLength(const SignedSize signal_length)
190  {
191  signal_length_ = signal_length;
192  }
193 
195  inline int getSize() const
196  {
197  return (int) signal_.size();
198  }
199 
203  virtual void init(double scale, double spacing);
204 
205 
207  inline double operator[](unsigned int i)
208  {
209  return signal_[i].getIntensity();
210  }
211 
212  inline double operator[](unsigned int i) const
213  {
214  return signal_[i].getIntensity();
215  }
216 
217 protected:
219  std::vector<Peak1D> signal_;
220 
222  std::vector<double> wavelet_;
223 
225  double scale_;
226  double spacing_;
228 
234 
235  template <typename InputPeakIterator>
236  double getInterpolatedValue_(double x, InputPeakIterator it_left)
237  {
238  // Interpolate between the point to the left and the point to the right.
239  double left_position = it_left->getMZ();
240  double right_position = (it_left + 1)->getMZ();
241  double d = (x - left_position) / (right_position - left_position);
242 
243  return (it_left + 1)->getIntensity() * d + it_left->getIntensity() * (1 - d);
244  }
245 
246  };
247 
248 } //namespace OpenMS
249 
250 #endif
SignedSize & getLeftPaddingIndex()
Mutable access to the position where the signal starts.
Definition: ContinuousWaveletTransform.h:147
SignedSize & getRightPaddingIndex()
Mutable access to the position where the signal starts.
Definition: ContinuousWaveletTransform.h:165
virtual ~ContinuousWaveletTransform()
Destructor.
Definition: ContinuousWaveletTransform.h:65
const std::vector< double > & getWavelet() const
Non-mutable access to the wavelet.
Definition: ContinuousWaveletTransform.h:87
SignedSize getLeftPaddingIndex() const
Non-mutable access to the position where the signal starts (in the intervall [0,end_left_padding_) ar...
Definition: ContinuousWaveletTransform.h:141
double operator[](unsigned int i) const
Definition: ContinuousWaveletTransform.h:212
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:151
double scale_
Spacing and scale of the wavelet and length of the signal.
Definition: ContinuousWaveletTransform.h:225
double getInterpolatedValue_(double x, InputPeakIterator it_left)
Definition: ContinuousWaveletTransform.h:236
This class is the base class of the continuous wavelet transformation.
Definition: ContinuousWaveletTransform.h:48
void setRightPaddingIndex(const SignedSize begin_right_padding)
Mutable access to position where the signal starts.
Definition: ContinuousWaveletTransform.h:171
const std::vector< Peak1D > & getSignal() const
Non-mutable access to the wavelet transform of the signal.
Definition: ContinuousWaveletTransform.h:69
double & getScale()
Mutable access to the spacing of raw data.
Definition: ContinuousWaveletTransform.h:111
void setSignalLength(const SignedSize signal_length)
Mutable access to signal length [end_left_padding,begin_right_padding].
Definition: ContinuousWaveletTransform.h:189
SignedSize begin_right_padding_
Definition: ContinuousWaveletTransform.h:233
ContinuousWaveletTransform()
Constructor.
Definition: ContinuousWaveletTransform.h:56
std::vector< double > & getWavelet()
Mutable access to the wavelet.
Definition: ContinuousWaveletTransform.h:93
void setScale(DoubleReal scale)
Mutable access to the spacing of raw data.
Definition: ContinuousWaveletTransform.h:117
SignedSize end_left_padding_
Definition: ContinuousWaveletTransform.h:232
SignedSize signal_length_
Definition: ContinuousWaveletTransform.h:227
DoubleReal getScale() const
Definition: ContinuousWaveletTransform.h:105
void setSpacing(double spacing)
Mutable access to the spacing of raw data.
Definition: ContinuousWaveletTransform.h:135
SignedSize & getSignalLength()
Mutable access to signal length [end_left_padding,begin_right_padding].
Definition: ContinuousWaveletTransform.h:183
void setLeftPaddingIndex(const SignedSize end_left_padding)
Mutable access to position where the signal starts.
Definition: ContinuousWaveletTransform.h:153
double operator[](unsigned int i)
Yields the signal (intensity) at position i.
Definition: ContinuousWaveletTransform.h:207
std::vector< Peak1D > signal_
The transformed signal.
Definition: ContinuousWaveletTransform.h:219
std::vector< double > wavelet_
The pretabulated wavelet used for the transform.
Definition: ContinuousWaveletTransform.h:222
std::vector< Peak1D >::const_iterator PeakConstIterator
Raw data const iterator type.
Definition: ContinuousWaveletTransform.h:52
double spacing_
Definition: ContinuousWaveletTransform.h:226
SignedSize getSignalLength() const
Non-mutable access to signal length [end_left_padding,begin_right_padding].
Definition: ContinuousWaveletTransform.h:177
void setWavelet(const std::vector< double > &wavelet)
Mutable access to the signal.
Definition: ContinuousWaveletTransform.h:99
SignedSize getRightPaddingIndex() const
Non-mutable access to the position where the signal ends (in the intervall (begin_right_padding_,end] are the padded zeros)
Definition: ContinuousWaveletTransform.h:159
int getSize() const
Non-mutable access to signal length including padded zeros [0,end].
Definition: ContinuousWaveletTransform.h:195
std::vector< Peak1D > & getSignal()
Mutable access to the wavelet transform of the signal.
Definition: ContinuousWaveletTransform.h:75
void setSignal(const std::vector< Peak1D > &signal)
Mutable access to the wavelet transform of the signal.
Definition: ContinuousWaveletTransform.h:81
DoubleReal getSpacing() const
Definition: ContinuousWaveletTransform.h:123
double & getSpacing()
Mutable access to the spacing of raw data.
Definition: ContinuousWaveletTransform.h:129

OpenMS / TOPP release 1.11.1 Documentation generated on Thu Nov 14 2013 11:19:12 using doxygen 1.8.5