Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
TOFCalibration.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: $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_FILTERING_CALIBRATION_TOFCALIBRATION_H
36 #define OPENMS_FILTERING_CALIBRATION_TOFCALIBRATION_H
37 
43 
46 
47 #include <vector>
48 #include <map>
49 
50 //#define DEBUG_CALIBRATION
51 namespace OpenMS
52 {
67  class OPENMS_DLLAPI TOFCalibration :
68  public DefaultParamHandler,
69  public ProgressLogger
70  {
71 public:
72 
75 
77  ~TOFCalibration();
78 
79 
80  /*
81  @ brief Apply the external calibration using raw calibrant spectra.
82 
83  @exception Exception::UnableToCalibrate is thrown if not enough reference masses are observed.
84 
85  */
86  void pickAndCalibrate(PeakMap & calib_spectra, PeakMap & exp, std::vector<double> & exp_masses);
87 
88  /*
89  @ brief Apply the external calibration using picked calibrant spectra.
90 
91  @exception Exception::UnableToCalibrate is thrown if not enough reference masses are observed.
92 
93  */
94  void calibrate(PeakMap & calib_spectra, PeakMap & exp, std::vector<double> & exp_masses);
95 
97  inline const std::vector<double> & getML1s() const {return ml1s_; }
99  inline void setML1s(const std::vector<double> & ml1s)
100  {
101  ml1s_ = ml1s;
102  }
103 
105  inline const std::vector<double> & getML2s() const {return ml2s_; }
107  inline void setML2s(const std::vector<double> & ml2s)
108  {
109  ml2s_ = ml2s;
110  }
111 
113  inline const std::vector<double> & getML3s() const {return ml3s_; }
115  inline void setML3s(const std::vector<double> & ml3s)
116  {
117  ml3s_ = ml3s;
118  }
119 
120 private:
123 
124 
126  std::vector<double> exp_masses_;
127 
129  std::map<double, std::vector<double> > errors_;
130 
132  std::vector<double> error_medians_;
133 
135  std::vector<double> calib_masses_;
136 
138  std::vector<double> ml1s_;
139  std::vector<double> ml2s_;
140  std::vector<double> ml3s_;
141 
143  std::vector<double> coeff_quad_fit_;
144 
146  double a_, b_, c_;
147 
148 
150  void calculateCalibCoeffs_(PeakMap & calib_peaks_ft);
151 
152 
154  void getMonoisotopicPeaks_(PeakMap & calib_peaks, std::vector<std::vector<unsigned int> > & monoiso_peaks);
155 
166  void applyTOFConversion_(PeakMap & calib_spectra);
167 
169  void matchMasses_(PeakMap & calib_peaks,
170  std::vector<std::vector<unsigned int> > & monoiso_peaks,
171  std::vector<unsigned int> & obs_masses,
172  std::vector<double> & exp_masses,
173  unsigned int idx);
174 
176  inline double mQ_(double ft, unsigned int spec)
177  {
178  return coeff_quad_fit_[3 * spec] + ft * coeff_quad_fit_[3 * spec + 1] + ft * ft * coeff_quad_fit_[3 * spec + 2];
179  }
180 
182  inline double mQAv_(double ft)
183  {
184  return a_ + ft * b_ + ft * ft * c_;
185  }
186 
188  void averageErrors_();
189 
191  void averageCoefficients_();
192  };
193 
194 } // namespace OpenMS
195 
196 #endif // OPENMS_FILTERING_CALIBRATION_TOFCALIBRATION_H
const std::vector< double > & getML2s() const
Non-mutable access to the second calibration constant.
Definition: TOFCalibration.h:105
void setML3s(const std::vector< double > &ml3s)
mutable access to the third calibration constant
Definition: TOFCalibration.h:115
This class implements an external calibration for TOF data using external calibrant spectra...
Definition: TOFCalibration.h:67
std::vector< double > coeff_quad_fit_
all coefficients of the quadratic fit
Definition: TOFCalibration.h:143
std::vector< double > error_medians_
median errors
Definition: TOFCalibration.h:132
std::vector< double > ml3s_
Definition: TOFCalibration.h:140
std::vector< double > ml2s_
Definition: TOFCalibration.h:139
void setML1s(const std::vector< double > &ml1s)
mutable access to the first calibration constant
Definition: TOFCalibration.h:99
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
const std::vector< double > & getML3s() const
Non-mutable access to the third calibration constant.
Definition: TOFCalibration.h:113
std::vector< double > exp_masses_
the expected calibrant masses
Definition: TOFCalibration.h:126
std::vector< double > ml1s_
calibration constants from the instrument needed for the conversion of the calibrant spectra ...
Definition: TOFCalibration.h:138
double c_
Definition: TOFCalibration.h:146
PeakMap calib_peaks_ft_
the calibrant spectra still using flight times instead of m/z-values
Definition: TOFCalibration.h:122
std::map< double, std::vector< double > > errors_
error in ppm after quadratic fit
Definition: TOFCalibration.h:129
const std::vector< double > & getML1s() const
Non-mutable access to the first calibration constant.
Definition: TOFCalibration.h:97
double mQ_(double ft, unsigned int spec)
Calculate the mass value for a given flight time using the coefficients of the quadratic fit in a spe...
Definition: TOFCalibration.h:176
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:82
std::vector< double > calib_masses_
Definition: TOFCalibration.h:135
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:55
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:92
double mQAv_(double ft)
Calculate the mass value for a given flight time using the averaged coefficients of the quadratic fit...
Definition: TOFCalibration.h:182
void setML2s(const std::vector< double > &ml2s)
mutable access to the second calibration constant
Definition: TOFCalibration.h:107

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