Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages

ContinuousWaveletTransform.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------------
00002 //                   OpenMS -- Open-Source Mass Spectrometry
00003 // --------------------------------------------------------------------------
00004 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
00005 // ETH Zurich, and Freie Universitaet Berlin 2002-2012.
00006 //
00007 // This software is released under a three-clause BSD license:
00008 //  * Redistributions of source code must retain the above copyright
00009 //    notice, this list of conditions and the following disclaimer.
00010 //  * Redistributions in binary form must reproduce the above copyright
00011 //    notice, this list of conditions and the following disclaimer in the
00012 //    documentation and/or other materials provided with the distribution.
00013 //  * Neither the name of any author or any participating institution
00014 //    may be used to endorse or promote products derived from this software
00015 //    without specific prior written permission.
00016 // For a full list of authors, refer to the file AUTHORS.
00017 // --------------------------------------------------------------------------
00018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00019 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
00022 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00023 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00024 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00025 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00026 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00027 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00028 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 //
00030 // --------------------------------------------------------------------------
00031 // $Maintainer: Alexandra Zerck $
00032 // $Authors: Eva Lange $
00033 // --------------------------------------------------------------------------
00034 
00035 #ifndef OPENMS_TRANSFORMATIONS_RAW2PEAK_CONTINUOUSWAVELETTRANSFORM_H
00036 #define OPENMS_TRANSFORMATIONS_RAW2PEAK_CONTINUOUSWAVELETTRANSFORM_H
00037 
00038 #include <OpenMS/KERNEL/Peak1D.h>
00039 
00040 #include <vector>
00041 #include <iostream>
00042 
00043 namespace OpenMS
00044 {
00048   class OPENMS_DLLAPI ContinuousWaveletTransform
00049   {
00050 public:
00052     typedef std::vector<Peak1D>::const_iterator PeakConstIterator;
00053 
00054 
00056     ContinuousWaveletTransform() :
00057       scale_(0),
00058       spacing_(0),
00059       signal_length_(0),
00060       end_left_padding_(0),
00061       begin_right_padding_(0)
00062     {}
00063 
00065     virtual ~ContinuousWaveletTransform()
00066     {}
00067 
00069     inline const std::vector<Peak1D> & getSignal() const
00070     {
00071       return signal_;
00072     }
00073 
00075     inline std::vector<Peak1D> & getSignal()
00076     {
00077       return signal_;
00078     }
00079 
00081     inline void setSignal(const std::vector<Peak1D> & signal)
00082     {
00083       signal_ = signal;
00084     }
00085 
00087     inline const std::vector<double> & getWavelet() const
00088     {
00089       return wavelet_;
00090     }
00091 
00093     inline std::vector<double> & getWavelet()
00094     {
00095       return wavelet_;
00096     }
00097 
00099     inline void setWavelet(const std::vector<double> & wavelet)
00100     {
00101       wavelet_ = wavelet;
00102     }
00103 
00104     // Non-mutable access to the scale of the wavelet
00105     inline DoubleReal getScale() const
00106     {
00107       return scale_;
00108     }
00109 
00111     inline double & getScale()
00112     {
00113       return scale_;
00114     }
00115 
00117     inline void setScale(DoubleReal scale)
00118     {
00119       scale_ = scale;
00120     }
00121 
00122     // Non-mutable access to the spacing of raw data
00123     inline DoubleReal getSpacing() const
00124     {
00125       return spacing_;
00126     }
00127 
00129     inline double & getSpacing()
00130     {
00131       return spacing_;
00132     }
00133 
00135     inline void setSpacing(double spacing)
00136     {
00137       spacing_ = spacing;
00138     }
00139 
00141     inline SignedSize getLeftPaddingIndex() const
00142     {
00143       return end_left_padding_;
00144     }
00145 
00147     inline SignedSize & getLeftPaddingIndex()
00148     {
00149       return end_left_padding_;
00150     }
00151 
00153     inline void setLeftPaddingIndex(const SignedSize end_left_padding)
00154     {
00155       end_left_padding_ = end_left_padding;
00156     }
00157 
00159     inline SignedSize getRightPaddingIndex() const
00160     {
00161       return begin_right_padding_;
00162     }
00163 
00165     inline SignedSize & getRightPaddingIndex()
00166     {
00167       return begin_right_padding_;
00168     }
00169 
00171     inline void setRightPaddingIndex(const SignedSize begin_right_padding)
00172     {
00173       begin_right_padding_ = begin_right_padding;
00174     }
00175 
00177     inline SignedSize getSignalLength() const
00178     {
00179       return signal_length_;
00180     }
00181 
00183     inline SignedSize & getSignalLength()
00184     {
00185       return signal_length_;
00186     }
00187 
00189     inline void setSignalLength(const SignedSize signal_length)
00190     {
00191       signal_length_ = signal_length;
00192     }
00193 
00195     inline int getSize() const
00196     {
00197       return (int) signal_.size();
00198     }
00199 
00203     virtual void init(double scale, double spacing);
00204 
00205 
00207     inline double operator[](unsigned int i)
00208     {
00209       return signal_[i].getIntensity();
00210     }
00211 
00212     inline double operator[](unsigned int i) const
00213     {
00214       return signal_[i].getIntensity();
00215     }
00216 
00217 protected:
00219     std::vector<Peak1D> signal_;
00220 
00222     std::vector<double> wavelet_;
00223 
00225     double scale_;
00226     double spacing_;
00227     SignedSize signal_length_;
00228 
00232     SignedSize end_left_padding_;
00233     SignedSize begin_right_padding_;
00234 
00235     template <typename InputPeakIterator>
00236     double getInterpolatedValue_(double x, InputPeakIterator it_left)
00237     {
00238       // Interpolate between the point to the left and the point to the right.
00239       double left_position = it_left->getMZ();
00240       double right_position = (it_left + 1)->getMZ();
00241       double d = (x - left_position) / (right_position - left_position);
00242 
00243       return (it_left + 1)->getIntensity() * d + it_left->getIntensity() * (1 - d);
00244     }
00245 
00246   };
00247 
00248 } //namespace OpenMS
00249 
00250 #endif

OpenMS / TOPP release 1.10.0 Documentation generated on Thu Mar 7 2013 09:42:38 using doxygen 1.7.1