OpenMS
TOFCalibration Class Reference

This class implements an external calibration for TOF data using external calibrant spectra. More...

#include <OpenMS/FILTERING/CALIBRATION/TOFCalibration.h>

Inheritance diagram for TOFCalibration:
[legend]
Collaboration diagram for TOFCalibration:
[legend]

Public Member Functions

 TOFCalibration ()
 Default constructor. More...
 
 ~TOFCalibration () override
 Destructor. More...
 
void pickAndCalibrate (PeakMap &calib_spectra, PeakMap &exp, std::vector< double > &exp_masses)
 
void calibrate (PeakMap &calib_spectra, PeakMap &exp, std::vector< double > &exp_masses)
 
const std::vector< double > & getML1s () const
 Non-mutable access to the first calibration constant. More...
 
void setML1s (const std::vector< double > &ml1s)
 mutable access to the first calibration constant More...
 
const std::vector< double > & getML2s () const
 Non-mutable access to the second calibration constant. More...
 
void setML2s (const std::vector< double > &ml2s)
 mutable access to the second calibration constant More...
 
const std::vector< double > & getML3s () const
 Non-mutable access to the third calibration constant. More...
 
void setML3s (const std::vector< double > &ml3s)
 mutable access to the third calibration constant More...
 
- Public Member Functions inherited from DefaultParamHandler
 DefaultParamHandler (const String &name)
 Constructor with name that is displayed in error messages. More...
 
 DefaultParamHandler (const DefaultParamHandler &rhs)
 Copy constructor. More...
 
virtual ~DefaultParamHandler ()
 Destructor. More...
 
DefaultParamHandleroperator= (const DefaultParamHandler &rhs)
 Assignment operator. More...
 
virtual bool operator== (const DefaultParamHandler &rhs) const
 Equality operator. More...
 
void setParameters (const Param &param)
 Sets the parameters. More...
 
const ParamgetParameters () const
 Non-mutable access to the parameters. More...
 
const ParamgetDefaults () const
 Non-mutable access to the default parameters. More...
 
const StringgetName () const
 Non-mutable access to the name. More...
 
void setName (const String &name)
 Mutable access to the name. More...
 
const std::vector< String > & getSubsections () const
 Non-mutable access to the registered subsections. More...
 
- Public Member Functions inherited from ProgressLogger
 ProgressLogger ()
 Constructor. More...
 
virtual ~ProgressLogger ()
 Destructor. More...
 
 ProgressLogger (const ProgressLogger &other)
 Copy constructor. More...
 
ProgressLoggeroperator= (const ProgressLogger &other)
 Assignment Operator. More...
 
void setLogType (LogType type) const
 Sets the progress log that should be used. The default type is NONE! More...
 
LogType getLogType () const
 Returns the type of progress log being used. More...
 
void startProgress (SignedSize begin, SignedSize end, const String &label) const
 Initializes the progress display. More...
 
void setProgress (SignedSize value) const
 Sets the current progress. More...
 
void endProgress (UInt64 bytes_processed=0) const
 
void nextProgress () const
 increment progress by 1 (according to range begin-end) More...
 

Private Member Functions

void calculateCalibCoeffs_ (PeakMap &calib_peaks_ft)
 Calculates the coefficients of the quadratic fit used for external calibration. More...
 
void getMonoisotopicPeaks_ (PeakMap &calib_peaks, std::vector< std::vector< unsigned int > > &monoiso_peaks)
 determines the monoisotopic peaks More...
 
void applyTOFConversion_ (PeakMap &calib_spectra)
 Applies the conversion from TOF to m/z-values to all peaks. More...
 
void matchMasses_ (PeakMap &calib_peaks, std::vector< std::vector< unsigned int > > &monoiso_peaks, std::vector< unsigned int > &obs_masses, std::vector< double > &exp_masses, unsigned int idx)
 determine the monoisotopic masses that have matching expected masses More...
 
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 specific spectrum. More...
 
double mQAv_ (double ft) const
 Calculate the mass value for a given flight time using the averaged coefficients of the quadratic fit. More...
 
void averageErrors_ ()
 Calculate the average errors of the reference masses over all scans. More...
 
void averageCoefficients_ ()
 Average the coefficients of the quadratic fit. More...
 

Private Attributes

PeakMap calib_peaks_ft_
 the calibrant spectra still using flight times instead of m/z-values More...
 
std::vector< double > exp_masses_
 the expected calibrant masses More...
 
std::map< double, std::vector< double > > errors_
 error in ppm after quadratic fit More...
 
std::vector< double > error_medians_
 median errors More...
 
std::vector< double > calib_masses_
 
std::vector< double > ml1s_
 calibration constants from the instrument needed for the conversion of the calibrant spectra More...
 
std::vector< double > ml2s_
 
std::vector< double > ml3s_
 
std::vector< double > coeff_quad_fit_
 all coefficients of the quadratic fit More...
 
double a_
 mean coefficients More...
 
double b_
 
double c_
 

Additional Inherited Members

- Public Types inherited from ProgressLogger
enum  LogType { CMD , GUI , NONE }
 Possible log types. More...
 
- Static Public Member Functions inherited from DefaultParamHandler
static void writeParametersToMetaValues (const Param &write_this, MetaInfoInterface &write_here, const String &key_prefix="")
 Writes all parameters to meta values. More...
 
- Protected Member Functions inherited from DefaultParamHandler
virtual void updateMembers_ ()
 This method is used to update extra member variables at the end of the setParameters() method. More...
 
void defaultsToParam_ ()
 Updates the parameters after the defaults have been set in the constructor. More...
 
- Static Protected Member Functions inherited from ProgressLogger
static String logTypeToFactoryName_ (LogType type)
 Return the name of the factory product used for this log type. More...
 
- Protected Attributes inherited from DefaultParamHandler
Param param_
 Container for current parameters. More...
 
Param defaults_
 Container for default parameters. This member should be filled in the constructor of derived classes! More...
 
std::vector< Stringsubsections_
 Container for registered subsections. This member should be filled in the constructor of derived classes! More...
 
String error_name_
 Name that is displayed in error messages during the parameter checking. More...
 
bool check_defaults_
 If this member is set to false no checking if parameters in done;. More...
 
bool warn_empty_defaults_
 If this member is set to false no warning is emitted when defaults are empty;. More...
 
- Protected Attributes inherited from ProgressLogger
LogType type_
 
time_t last_invoke_
 
ProgressLoggerImplcurrent_logger_
 
- Static Protected Attributes inherited from ProgressLogger
static int recursion_depth_
 

Detailed Description

This class implements an external calibration for TOF data using external calibrant spectra.

The procedure is very similar to the one described in Gobom et al. (Anal Chem. 2002, 74 (15) pp 3915-23). The input experiment data need to be flight times. They are converted into m/z-values using the calibrant spectra. The calibrant spectra and their expected masses are used to determine the quadratic dependence of TOF and m/z values.

Note
The input spectra need to contain flight times.
The peaks must be sorted according to ascending m/z!

Constructor & Destructor Documentation

◆ TOFCalibration()

Default constructor.

◆ ~TOFCalibration()

~TOFCalibration ( )
override

Destructor.

Member Function Documentation

◆ applyTOFConversion_()

void applyTOFConversion_ ( PeakMap calib_spectra)
private

Applies the conversion from TOF to m/z-values to all peaks.

Either a 2-point or a 3-point time of flight conversion can be used, as well as different constants for each calibrant spectra or one set for all of them.

The 2-point equation is mass = ml1/10^12 * (TOF * 1000 - ml2). The 3-point equation is time = ml2 + sqrt(10^12/ml1 * mass) + ml3*mass.

◆ averageCoefficients_()

void averageCoefficients_ ( )
private

Average the coefficients of the quadratic fit.

◆ averageErrors_()

void averageErrors_ ( )
private

Calculate the average errors of the reference masses over all scans.

◆ calculateCalibCoeffs_()

void calculateCalibCoeffs_ ( PeakMap calib_peaks_ft)
private

Calculates the coefficients of the quadratic fit used for external calibration.

◆ calibrate()

void calibrate ( PeakMap calib_spectra,
PeakMap exp,
std::vector< double > &  exp_masses 
)

◆ getML1s()

const std::vector<double>& getML1s ( ) const
inline

Non-mutable access to the first calibration constant.

◆ getML2s()

const std::vector<double>& getML2s ( ) const
inline

Non-mutable access to the second calibration constant.

◆ getML3s()

const std::vector<double>& getML3s ( ) const
inline

Non-mutable access to the third calibration constant.

◆ getMonoisotopicPeaks_()

void getMonoisotopicPeaks_ ( PeakMap calib_peaks,
std::vector< std::vector< unsigned int > > &  monoiso_peaks 
)
private

determines the monoisotopic peaks

◆ matchMasses_()

void matchMasses_ ( PeakMap calib_peaks,
std::vector< std::vector< unsigned int > > &  monoiso_peaks,
std::vector< unsigned int > &  obs_masses,
std::vector< double > &  exp_masses,
unsigned int  idx 
)
private

determine the monoisotopic masses that have matching expected masses

◆ mQ_()

double mQ_ ( double  ft,
unsigned int  spec 
)
inlineprivate

Calculate the mass value for a given flight time using the coefficients of the quadratic fit in a specific spectrum.

◆ mQAv_()

double mQAv_ ( double  ft) const
inlineprivate

Calculate the mass value for a given flight time using the averaged coefficients of the quadratic fit.

◆ pickAndCalibrate()

void pickAndCalibrate ( PeakMap calib_spectra,
PeakMap exp,
std::vector< double > &  exp_masses 
)

◆ setML1s()

void setML1s ( const std::vector< double > &  ml1s)
inline

mutable access to the first calibration constant

◆ setML2s()

void setML2s ( const std::vector< double > &  ml2s)
inline

mutable access to the second calibration constant

◆ setML3s()

void setML3s ( const std::vector< double > &  ml3s)
inline

mutable access to the third calibration constant

Member Data Documentation

◆ a_

double a_
private

mean coefficients

◆ b_

double b_
private

◆ c_

double c_
private

◆ calib_masses_

std::vector<double> calib_masses_
private

◆ calib_peaks_ft_

PeakMap calib_peaks_ft_
private

the calibrant spectra still using flight times instead of m/z-values

◆ coeff_quad_fit_

std::vector<double> coeff_quad_fit_
private

all coefficients of the quadratic fit

◆ error_medians_

std::vector<double> error_medians_
private

median errors

◆ errors_

std::map<double, std::vector<double> > errors_
private

error in ppm after quadratic fit

◆ exp_masses_

std::vector<double> exp_masses_
private

the expected calibrant masses

◆ ml1s_

std::vector<double> ml1s_
private

calibration constants from the instrument needed for the conversion of the calibrant spectra

◆ ml2s_

std::vector<double> ml2s_
private

◆ ml3s_

std::vector<double> ml3s_
private