OpenMS
Loading...
Searching...
No Matches
LinearResamplerAlign Class Reference

Linear Resampling of raw data with alignment. More...

#include <OpenMS/PROCESSING/RESAMPLING/LinearResamplerAlign.h>

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

Public Member Functions

 LinearResamplerAlign ()
 
template<class PeakContainerT >
void raster (PeakContainerT &container)
 Applies the resampling algorithm to a container (MSSpectrum or MSChromatogram).
 
template<typename PeakContainerT >
void raster_align (PeakContainerT &container, double start_pos, double end_pos)
 Applies the resampling algorithm to a container (MSSpectrum or MSChromatogram) with fixed coordinates. The container will be resampled at equally spaced points between the supplied start and end positions. The resampling frequency can be controlled by the "spacing" parameter.
 
template<typename PeakTypeIterator , typename ConstPeakTypeIterator >
void raster (ConstPeakTypeIterator raw_it, ConstPeakTypeIterator raw_end, PeakTypeIterator resampled_begin, PeakTypeIterator resampled_end)
 Resample points (e.g. Peak1D) from an input range onto a prepopulated output range with given m/z, modifying the output intensities.
 
template<typename PeakTypeIterator , typename ConstPeakTypeIterator >
void raster (ConstPeakTypeIterator mz_raw_it, ConstPeakTypeIterator mz_raw_end, ConstPeakTypeIterator int_raw_it, ConstPeakTypeIterator int_raw_end, ConstPeakTypeIterator mz_resample_it, ConstPeakTypeIterator mz_resample_end, PeakTypeIterator int_resample_it, PeakTypeIterator int_resample_end)
 Resample points (with m/z and intensity in separate containers, but of same length) from an input range onto a prepopulated output m/z & intensity range (each in separate containers, but of same length).
 
template<typename PeakTypeIterator >
void raster_interpolate (PeakTypeIterator raw_it, PeakTypeIterator raw_end, PeakTypeIterator resampled_start, PeakTypeIterator resampled_end)
 Applies the resampling algorithm using a linear interpolation.
 
void rasterExperiment (PeakMap &exp)
 Applies the resampling algorithm to all spectra of an MSExperiment.
 
- Public Member Functions inherited from DefaultParamHandler
 DefaultParamHandler (const std::string &name)
 Constructor with name that is displayed in error messages.
 
 DefaultParamHandler (const DefaultParamHandler &rhs)
 Copy constructor.
 
virtual ~DefaultParamHandler ()
 Destructor.
 
DefaultParamHandleroperator= (const DefaultParamHandler &rhs)
 Assignment operator.
 
virtual bool operator== (const DefaultParamHandler &rhs) const
 Equality operator.
 
void setParameters (const Param &param)
 Sets the parameters.
 
const ParamgetParameters () const
 Non-mutable access to the parameters.
 
const ParamgetDefaults () const
 Non-mutable access to the default parameters.
 
const std::string & getName () const
 Non-mutable access to the name.
 
void setName (const std::string &name)
 Mutable access to the name.
 
const std::vector< std::string > & getSubsections () const
 Non-mutable access to the registered subsections.
 
- Public Member Functions inherited from ProgressLogger
 ProgressLogger ()
 Constructor.
 
virtual ~ProgressLogger ()
 Destructor.
 
 ProgressLogger (const ProgressLogger &other)
 Copy constructor.
 
ProgressLoggeroperator= (const ProgressLogger &other)
 Assignment Operator.
 
void setLogType (LogType type) const
 Sets the progress log that should be used. The default type is NONE!
 
LogType getLogType () const
 Returns the type of progress log being used.
 
void setLogger (ProgressLoggerImpl *logger)
 Sets the logger to be used for progress logging.
 
void startProgress (SignedSize begin, SignedSize end, const std::string &label) const
 Initializes the progress display.
 
void setProgress (SignedSize value) const
 Sets the current progress.
 
void endProgress (UInt64 bytes_processed=0) const
 
void nextProgress () const
 increment progress by 1 (according to range begin-end)
 

Protected Member Functions

void updateMembers_ () override
 This method is used to update extra member variables at the end of the setParameters() method.
 
template<typename PeakType >
void populate_raster_ (std::vector< PeakType > &resampled_peak_container, double start_pos, double end_pos, int number_resampled_points)
 Generate raster for resampled peak container.
 
template<typename PeakTypeIterator >
void verifySpacing_ (PeakTypeIterator it, PeakTypeIterator end, auto access)
 helper function to warn the user when the resampling rate is too high
 
- Protected Member Functions inherited from DefaultParamHandler
void defaultsToParam_ ()
 Updates the parameters after the defaults have been set in the constructor.
 

Protected Attributes

double spacing_
 Spacing of the resampled data.
 
bool ppm_
 Whether spacing_ is interpreted in ppm (true) or Th (false)
 
- Protected Attributes inherited from DefaultParamHandler
Param param_
 Container for current parameters.
 
Param defaults_
 Container for default parameters. This member should be filled in the constructor of derived classes!
 
std::vector< std::string > subsections_
 Container for registered subsections. This member should be filled in the constructor of derived classes!
 
std::string error_name_
 Name that is displayed in error messages during the parameter checking.
 
bool check_defaults_
 If this member is set to false no checking if parameters in done;.
 
bool warn_empty_defaults_
 If this member is set to false no warning is emitted when defaults are empty;.
 
- Protected Attributes inherited from ProgressLogger
LogType type_
 
time_t last_invoke_
 
ProgressLoggerImplcurrent_logger_
 

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 std::string &key_prefix="")
 Writes all parameters to meta values.
 
- Static Protected Attributes inherited from ProgressLogger
static int recursion_depth_
 

Detailed Description

Linear Resampling of raw data with alignment.

This class can be used to generate uniform data from non-uniform raw data (e.g. ESI-TOF or MALDI-TOF experiments). Therefore the intensity at every position x in the input raw data is spread to the two adjacent resampling points. This method preserves the area of the input signal and also the centroid position of a peak.

This class also allows to fix the points at which resampling will occur. This is useful if the resampling points are known in advance, e.g. if one needs to resample a chromatogram at the positions of another chromatogram. Therefore it is recommended for quantitation as well as for ProteinIdentification experiments.

Warning
If the configured spacing is smaller than the minimal distance between two adjacent input data points, intensity redistribution may produce spurious peaks. This can occur when the sampling rate is finer than the detector's dead time.

Constructor & Destructor Documentation

◆ LinearResamplerAlign()

Member Function Documentation

◆ populate_raster_()

template<typename PeakType >
void populate_raster_ ( std::vector< PeakType > &  resampled_peak_container,
double  start_pos,
double  end_pos,
int  number_resampled_points 
)
inlineprotected

Generate raster for resampled peak container.

References Peak2D::setIntensity().

◆ raster() [1/3]

template<typename PeakTypeIterator , typename ConstPeakTypeIterator >
void raster ( ConstPeakTypeIterator  mz_raw_it,
ConstPeakTypeIterator  mz_raw_end,
ConstPeakTypeIterator  int_raw_it,
ConstPeakTypeIterator  int_raw_end,
ConstPeakTypeIterator  mz_resample_it,
ConstPeakTypeIterator  mz_resample_end,
PeakTypeIterator  int_resample_it,
PeakTypeIterator  int_resample_end 
)
inline

Resample points (with m/z and intensity in separate containers, but of same length) from an input range onto a prepopulated output m/z & intensity range (each in separate containers, but of same length).

This will use the raster provided by the output container, i.e. with alignment, to resample the data provided in the input container. The intensities will be added to the intensities in the output container (which in most cases will be zero).

The intensities will be distributed between the two closest resampling points, thus conserving the sum of intensity over the whole container.

Note that all intensity in the input data container that is in peaks outside the range of the output container will simply be added to the first or last data point.

Parameters
[in]mz_raw_itStart of the input container to be resampled (containing the m/z data)
[in]mz_raw_endEnd of the input container to be resampled (containing the m/z data)
[in]int_raw_itStart of the input container to be resampled (containing the intensity data)
[in]int_raw_endEnd of the input container to be resampled (containing the intensity data)
[in]mz_resample_itIterator pointing to start of the output spectrum range (m/z which need to be populated)
[in]mz_resample_endIterator pointing to end of the output spectrum range (m/z which need to be populated)
[in,out]int_resample_itIterator pointing to start of the output spectrum range (intensities)
[in,out]int_resample_endIterator pointing to end of the output spectrum range (intensities)

References OPENMS_PRECONDITION.

◆ raster() [2/3]

template<typename PeakTypeIterator , typename ConstPeakTypeIterator >
void raster ( ConstPeakTypeIterator  raw_it,
ConstPeakTypeIterator  raw_end,
PeakTypeIterator  resampled_begin,
PeakTypeIterator  resampled_end 
)
inline

Resample points (e.g. Peak1D) from an input range onto a prepopulated output range with given m/z, modifying the output intensities.

This will use the raster provided by the output container, i.e. with alignment, to resample the data provided in the input container. The intensities will be added to the intensities in the output container (which in most cases will be zero).

The intensities will be distributed between the two closest resampling points, thus conserving the sum of intensity over the whole container.

Note that all intensity in the input data container that is in peaks outside the range of the output container will simply be added to the first or last data point.

Parameters
[in]raw_itStart of the input container to be resampled (containing the data)
[in]raw_endEnd of the input container to be resampled (containing the data)
[in,out]resampled_beginIterator pointing to start of the output spectrum range (m/z need to be populated, intensities should be zero)
[in,out]resampled_endIterator pointing to end of the output spectrum range (m/z need to be populated, intensities should be zero)

References OPENMS_PRECONDITION.

◆ raster() [3/3]

template<class PeakContainerT >
void raster ( PeakContainerT &  container)
inline

Applies the resampling algorithm to a container (MSSpectrum or MSChromatogram).

The container will be resampled at equally spaced points between the start and end of the container. The resampling frequency can be controlled by the "spacing" parameter.

Parameters
[in,out]containerThe container to be resampled

Referenced by MRMTransitionGroupPicker::resampleChromatogram_().

◆ raster_align()

template<typename PeakContainerT >
void raster_align ( PeakContainerT &  container,
double  start_pos,
double  end_pos 
)
inline

Applies the resampling algorithm to a container (MSSpectrum or MSChromatogram) with fixed coordinates. The container will be resampled at equally spaced points between the supplied start and end positions. The resampling frequency can be controlled by the "spacing" parameter.

This allows the user to specify the grid for alignment explicitly. This is especially useful if multiple spectra or chromatograms need to be resampled according to the same raster.

Parameters
[in,out]containerThe container to be resampled
[in]start_posThe start position to be used for resampling
[in]end_posThe end position to be used for resampling

◆ raster_interpolate()

template<typename PeakTypeIterator >
void raster_interpolate ( PeakTypeIterator  raw_it,
PeakTypeIterator  raw_end,
PeakTypeIterator  resampled_start,
PeakTypeIterator  resampled_end 
)
inline

Applies the resampling algorithm using a linear interpolation.

This will use the raster provided by the output container to resample the data provided in the input container. The intensities will be added to the intensities in the output container (which in most cases will be zero).

The intensities at the resampling point is computed by a linear interpolation between the two closest resampling points.

Parameters
[in]raw_itStart of the input (raw) spectrum to be resampled
[in]raw_endEnd of the input (raw) spectrum to be resampled
[in,out]resampled_startIterator pointing to start of the output spectrum range (m/z need to be populated, intensities should be zero)
[in,out]resampled_endIterator pointing to end of the output spectrum range (m/z need to be populated, intensities should be zero)

References OPENMS_PRECONDITION.

◆ rasterExperiment()

void rasterExperiment ( PeakMap exp)
inline

Applies the resampling algorithm to all spectra of an MSExperiment.

Chromatograms stored in exp are not resampled.

Parameters
[in,out]expThe experiment whose spectra will be resampled in place.

References MSExperiment::size().

◆ updateMembers_()

void updateMembers_ ( )
inlineoverrideprotectedvirtual

This method is used to update extra member variables at the end of the setParameters() method.

Also call it at the end of the derived classes' copy constructor and assignment operator.

The default implementation is empty.

Reimplemented from DefaultParamHandler.

◆ verifySpacing_()

template<typename PeakTypeIterator >
void verifySpacing_ ( PeakTypeIterator  it,
PeakTypeIterator  end,
auto  access 
)
inlineprotected

helper function to warn the user when the resampling rate is too high

References OPENMS_LOG_WARN, and OpenMS::suppress_resampling_spacing_warning.

Member Data Documentation

◆ ppm_

bool ppm_
protected

Whether spacing_ is interpreted in ppm (true) or Th (false)

◆ spacing_

double spacing_
protected

Spacing of the resampled data.