1
// -*- mode: C++; tab-width: 2; -*-
4
// --------------------------------------------------------------------------
5
// OpenMS Mass Spectrometry Framework
6
// --------------------------------------------------------------------------
7
// Copyright (C) 2003-2011 -- Oliver Kohlbacher, Knut Reinert
9
// This library is free software; you can redistribute it and/or
10
// modify it under the terms of the GNU Lesser General Public
11
// License as published by the Free Software Foundation; either
12
// version 2.1 of the License, or (at your option) any later version.
14
// This library is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
// Lesser General Public License for more details.
19
// You should have received a copy of the GNU Lesser General Public
20
// License along with this library; if not, write to the Free Software
21
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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.
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.
23
30
// --------------------------------------------------------------------------
24
31
// $Maintainer: Alexandra Zerck $
61
68
/// Non-mutable access to the wavelet transform of the signal
62
inline const std::vector<Peak1D>& getSignal() const
66
/// Mutable access to the wavelet transform of the signal
67
inline std::vector<Peak1D>& getSignal()
71
/// Mutable access to the wavelet transform of the signal
72
inline void setSignal(const std::vector<Peak1D>& signal)
69
inline const std::vector<Peak1D> & getSignal() const
74
/// Mutable access to the wavelet transform of the signal
75
inline std::vector<Peak1D> & getSignal()
80
/// Mutable access to the wavelet transform of the signal
81
inline void setSignal(const std::vector<Peak1D> & signal)
77
86
/// Non-mutable access to the wavelet
78
inline const std::vector<double>& getWavelet() const
87
inline const std::vector<double> & getWavelet() const
82
92
/// Mutable access to the wavelet
83
inline std::vector<double>& getWavelet()
93
inline std::vector<double> & getWavelet()
87
98
/// Mutable access to the signal
88
inline void setWavelet(const std::vector<double>& wavelet)
99
inline void setWavelet(const std::vector<double> & wavelet)
93
104
// Non-mutable access to the scale of the wavelet
94
105
inline DoubleReal getScale() const
98
110
/// Mutable access to the spacing of raw data
99
inline double& getScale()
111
inline double & getScale()
103
116
/// Mutable access to the spacing of raw data
104
117
inline void setScale(DoubleReal scale)
109
122
// Non-mutable access to the spacing of raw data
110
123
inline DoubleReal getSpacing() const
114
128
/// Mutable access to the spacing of raw data
115
inline double& getSpacing()
129
inline double & getSpacing()
119
134
/// Mutable access to the spacing of raw data
120
135
inline void setSpacing(double spacing)
125
140
/// Non-mutable access to the position where the signal starts (in the intervall [0,end_left_padding_) are the padded zeros)
126
141
inline SignedSize getLeftPaddingIndex() const
128
return end_left_padding_;
143
return end_left_padding_;
130
146
/// Mutable access to the position where the signal starts
131
inline SignedSize& getLeftPaddingIndex()
147
inline SignedSize & getLeftPaddingIndex()
133
return end_left_padding_;
149
return end_left_padding_;
135
152
/// Mutable access to position where the signal starts
136
153
inline void setLeftPaddingIndex(const SignedSize end_left_padding)
138
end_left_padding_ = end_left_padding;
155
end_left_padding_ = end_left_padding;
141
158
/// Non-mutable access to the position where the signal ends (in the intervall (begin_right_padding_,end] are the padded zeros)
142
159
inline SignedSize getRightPaddingIndex() const
144
return begin_right_padding_;
161
return begin_right_padding_;
146
164
/// Mutable access to the position where the signal starts
147
inline SignedSize& getRightPaddingIndex()
165
inline SignedSize & getRightPaddingIndex()
149
return begin_right_padding_;
167
return begin_right_padding_;
151
170
/// Mutable access to position where the signal starts
152
171
inline void setRightPaddingIndex(const SignedSize begin_right_padding)
154
begin_right_padding_ = begin_right_padding;
173
begin_right_padding_ = begin_right_padding;
157
176
/// Non-mutable access to signal length [end_left_padding,begin_right_padding]
158
177
inline SignedSize getSignalLength() const
160
return signal_length_;
179
return signal_length_;
162
182
/// Mutable access to signal length [end_left_padding,begin_right_padding]
163
inline SignedSize& getSignalLength()
183
inline SignedSize & getSignalLength()
165
return signal_length_;
185
return signal_length_;
167
188
/// Mutable access to signal length [end_left_padding,begin_right_padding]
168
189
inline void setSignalLength(const SignedSize signal_length)
170
signal_length_ = signal_length;
191
signal_length_ = signal_length;
173
194
/// Non-mutable access to signal length including padded zeros [0,end]
174
195
inline int getSize() const
176
return (int) signal_.size();
197
return (int) signal_.size();
181
@brief Perform possibly necessary preprocessing steps, like tabulating the Wavelet.
201
@brief Perform possibly necessary preprocessing steps, like tabulating the Wavelet.
183
203
virtual void init(double scale, double spacing);
186
206
/// Yields the signal (intensity) at position i
187
inline double operator [] (unsigned int i)
189
return signal_[i].getIntensity();
192
inline double operator [] (unsigned int i) const
194
return signal_[i].getIntensity();
207
inline double operator[](unsigned int i)
209
return signal_[i].getIntensity();
212
inline double operator[](unsigned int i) const
214
return signal_[i].getIntensity();
201
218
/// The transformed signal
202
std::vector<Peak1D> signal_;
219
std::vector<Peak1D> signal_;
204
221
/// The pretabulated wavelet used for the transform
205
222
std::vector<double> wavelet_;
215
232
SignedSize end_left_padding_;
216
233
SignedSize begin_right_padding_;
218
template < typename InputPeakIterator >
219
double getInterpolatedValue_(double x, InputPeakIterator it_left)
221
// Interpolate between the point to the left and the point to the right.
222
double left_position = it_left->getMZ();
223
double right_position = (it_left+1)->getMZ();
224
double d=(x-left_position)/(right_position-left_position);
226
return ((it_left+1)->getIntensity()*d+it_left->getIntensity()*(1-d));
235
template <typename InputPeakIterator>
236
double getInterpolatedValue_(double x, InputPeakIterator it_left)
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);
243
return (it_left + 1)->getIntensity() * d + it_left->getIntensity() * (1 - d);
231
248
} //namespace OpenMS