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

ContinuousWaveletTransform.h (Maintainer: Eva Lange)

Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 // --------------------------------------------------------------------------
00005 //                   OpenMS Mass Spectrometry Framework
00006 // --------------------------------------------------------------------------
00007 //  Copyright (C) 2003-2008 -- Oliver Kohlbacher, Knut Reinert
00008 //
00009 //  This library is free software; you can redistribute it and/or
00010 //  modify it under the terms of the GNU Lesser General Public
00011 //  License as published by the Free Software Foundation; either
00012 //  version 2.1 of the License, or (at your option) any later version.
00013 //
00014 //  This library is distributed in the hope that it will be useful,
00015 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 //  Lesser General Public License for more details.
00018 //
00019 //  You should have received a copy of the GNU Lesser General Public
00020 //  License along with this library; if not, write to the Free Software
00021 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 //
00023 // --------------------------------------------------------------------------
00024 // $Maintainer: Eva Lange $
00025 // --------------------------------------------------------------------------
00026 
00027 #ifndef OPENMS_TRANSFORMATIONS_RAW2PEAK_CONTINUOUSWAVELETTRANSFORM_H
00028 #define OPENMS_TRANSFORMATIONS_RAW2PEAK_CONTINUOUSWAVELETTRANSFORM_H
00029 
00030 #include <OpenMS/KERNEL/DPeakArray.h>
00031 #include <OpenMS/KERNEL/RawDataPoint1D.h>
00032 
00033 #include <vector>
00034 #include <iostream>
00035 
00036 namespace OpenMS
00037 {
00041   class ContinuousWaveletTransform
00042   {
00043   public:
00045     typedef std::vector<RawDataPoint1D >::const_iterator RawDataPointConstIterator;
00046 
00047 
00049     ContinuousWaveletTransform()
00050       : scale_(0),
00051         spacing_(0),
00052         signal_length_(0),
00053         end_left_padding_(0),
00054         begin_right_padding_(0)
00055     {}
00056 
00058     virtual ~ContinuousWaveletTransform()
00059     {}
00060 
00062     inline const DPeakArray<RawDataPoint1D >& getSignal() const
00063     {
00064       return signal_;
00065     }
00067     inline DPeakArray<RawDataPoint1D >& getSignal()
00068     {
00069       return signal_;
00070     }
00072     inline void setSignal(const DPeakArray<RawDataPoint1D >& signal)
00073     {
00074       signal_ = signal;
00075     }
00076 
00078     inline const std::vector<double>& getWavelet() const
00079     {
00080       return wavelet_;
00081     }
00083     inline std::vector<double>& getWavelet()
00084     {
00085       return wavelet_;
00086     }
00088     inline void setWavelet(const std::vector<double>& wavelet)
00089     {
00090       wavelet_ = wavelet;
00091     }
00092 
00093     // Non-mutable access to the scale of the wavelet
00094     inline DoubleReal getScale() const
00095     {
00096       return scale_;
00097     }
00099     inline double& getScale()
00100     {
00101       return scale_;
00102     }
00104     inline void setScale(DoubleReal scale)
00105     {
00106       scale_ = scale;
00107     }
00108 
00109     // Non-mutable access to the spacing of raw data
00110     inline DoubleReal getSpacing() const
00111     {
00112       return spacing_;
00113     }
00115     inline double& getSpacing()
00116     {
00117       return spacing_;
00118     }
00120     inline void setSpacing(double spacing)
00121     {
00122       spacing_ = spacing;
00123     }
00124 
00126     inline Int getLeftPaddingIndex() const
00127     {
00128       return end_left_padding_;
00129     }
00131     inline int& getLeftPaddingIndex()
00132     {
00133       return end_left_padding_;
00134     }
00136     inline void setLeftPaddingIndex(const int end_left_padding)
00137     {
00138       end_left_padding_ = end_left_padding;
00139     }
00140 
00142     inline Int getRightPaddingIndex() const
00143     {
00144       return begin_right_padding_;
00145     }
00147     inline int& getRightPaddingIndex()
00148     {
00149       return begin_right_padding_;
00150     }
00152     inline void setRightPaddingIndex(const int begin_right_padding)
00153     {
00154       begin_right_padding_ = begin_right_padding;
00155     }
00156 
00158     inline Int getSignalLength() const
00159     {
00160       return signal_length_;
00161     }
00163     inline int& getSignalLength()
00164     {
00165       return signal_length_;
00166     }
00168     inline void setSignalLength(const int signal_length)
00169     {
00170       signal_length_ = signal_length;
00171     }
00172 
00174     inline int getSize() const
00175     {
00176       return signal_.size();
00177     }
00178 
00179 
00183     virtual void init(double scale, double spacing);
00184 
00185 
00187     inline double operator [] (unsigned int i)
00188     {
00189       return signal_[i].getIntensity();
00190     }
00191 
00192     inline double operator [] (unsigned int i) const
00193     {
00194       return signal_[i].getIntensity();
00195     }
00196     
00197 
00198 
00199 
00200   protected:
00202     DPeakArray<RawDataPoint1D > signal_;
00203 
00205     std::vector<double> wavelet_;
00206 
00208     double scale_;
00209     double spacing_;
00210     int signal_length_;
00211 
00215     int end_left_padding_;
00216     int begin_right_padding_;
00217 
00220     double getInterpolatedValue_(double x, RawDataPointConstIterator it_left);
00221 
00222     template < typename InputPeakIterator >
00223     double getInterpolatedValue_(double x, InputPeakIterator it_left)
00224     {
00225       // Interpolate between the point to the left and the point to the right.
00226       double left_position = it_left->getMZ();
00227       double right_position = (it_left+1)->getMZ();
00228       double d=(x-left_position)/(right_position-left_position);
00229 
00230       return ((it_left+1)->getIntensity()*d+it_left->getIntensity()*(1-d));
00231     }
00232 
00233   };
00234 
00235 } //namespace OpenMS
00236 
00237 #endif
00238 

Generated Tue Apr 1 15:36:33 2008 -- using doxygen 1.5.4 OpenMS / TOPP 1.1