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

Estimates the signal/noise (S/N) ratio of each data point in a scan by using the median (window based) More...

#include <OpenMS/PROCESSING/NOISEESTIMATION/SignalToNoiseEstimatorMedianRapid.h>

Classes

struct  NoiseEstimator
 Class to compute the noise value at a given position. More...
 

Public Member Functions

 SignalToNoiseEstimatorMedianRapid (double window_length)
 default constructor
 
NoiseEstimator estimateNoise (OpenMS::Interfaces::SpectrumPtr spectrum)
 Compute noise estimator for an m/z and intensity array using windows.
 
NoiseEstimator estimateNoise (OpenMS::Interfaces::ChromatogramPtr chrom)
 Compute noise estimator for an m/z and intensity array using windows.
 
NoiseEstimator estimateNoise (const std::vector< double > &mz_array, const std::vector< double > &int_array)
 Compute noise estimator for an m/z and intensity array using windows.
 

Private Member Functions

void computeNoiseInWindows_ (const std::vector< double > &mz_array, std::vector< double > int_array, std::vector< double > &result, double mz_start)
 Computes the noise in windows for two input arrays and stores the median intensity in the result (internal)
 
double computeMedian_ (std::vector< double >::iterator &first, std::vector< double >::iterator &last)
 Median computation on a part of an array [first,last)
 

Private Attributes

double window_length_
 Window length parameter.
 

Detailed Description

Estimates the signal/noise (S/N) ratio of each data point in a scan by using the median (window based)

For each scan, we define a set of windows of a pre-defined size (param: window_length_) in m/z domain for which the intensity median is calculated. The noise for a data point is estimated to be the median of the intensities of the current window.

To get a more robust noise estimate, the nose value is calculated two times for two sets of windows that are shifted by 1/2 of the window size and the reported noise value is the average of the two.

A call to estimateNoise will return an object of type NoiseEstimator which then provides a function get_noise_value which will return the noise value for a given m/z value.

The idea behind this class is to have an estimator for signal to noise that gives similar results to SignalToNoiseEstimatorMedian but performs faster. Note that it will not give identical results as SignalToNoiseEstimatorMedian but for many application the results from this class will be sufficient.

Constructor & Destructor Documentation

◆ SignalToNoiseEstimatorMedianRapid()

SignalToNoiseEstimatorMedianRapid ( double  window_length)
inline

default constructor

Member Function Documentation

◆ computeMedian_()

double computeMedian_ ( std::vector< double >::iterator &  first,
std::vector< double >::iterator &  last 
)
private

Median computation on a part of an array [first,last)

Note
Does not guarantee that the elements between [first, last) are in the same order as before (they most likely will not be).

◆ computeNoiseInWindows_()

void computeNoiseInWindows_ ( const std::vector< double > &  mz_array,
std::vector< double >  int_array,
std::vector< double > &  result,
double  mz_start 
)
private

Computes the noise in windows for two input arrays and stores the median intensity in the result (internal)

The x-axis (mz_array) is partitioned into result.size() consecutive, non-overlapping windows of width window_length_ starting at mz_start. For each window the median of the intensities falling into it is stored in result. Windows whose median is exactly 0 (e.g. empty windows) receive an imputed fallback value derived from the mean and standard deviation of the whole intensity array.

Parameters
[in]mz_arrayPositions along the separation axis, in ascending (sorted) order. Units depend on the caller: Thomson (m/z) for spectra, seconds (retention time) for chromatograms. Must contain > 2 elements and have the same length as int_array. The values are only required to be monotonically non-decreasing (they are searched with std::lower_bound).
[in]int_arrayIntensities (arbitrary units, expected non-negative), one per mz_array entry, in the same order. Passed by value on purpose: computeMedian_ reorders it in place while selecting medians, so a private copy is required and the caller's array is left untouched.
[out]resultPre-sized (by the caller) to the number of windows to evaluate; its size alone determines how many windows are produced. On return, result[i] holds the noise estimate for the i-th window (same units as int_array): the median intensity of that window, or the imputed fallback value (see above) when that median is exactly 0. Window i spans the coordinate range [mz_start + i*window_length_, mz_start + (i+1)*window_length_).
[in]mz_startPosition (same units as mz_array) of the left edge of the very first window. Typically mz_array.front() for the "even" set of windows, or mz_array.front() - window_length_/2 for the half-shifted "odd" set; hence it may legitimately lie below mz_array.front().

◆ estimateNoise() [1/3]

NoiseEstimator estimateNoise ( const std::vector< double > &  mz_array,
const std::vector< double > &  int_array 
)
inline

Compute noise estimator for an m/z and intensity array using windows.

Will return a noise estimator object.

References SignalToNoiseEstimatorMedianRapid::NoiseEstimator::result_windows_even, and SignalToNoiseEstimatorMedianRapid::NoiseEstimator::result_windows_odd.

◆ estimateNoise() [2/3]

NoiseEstimator estimateNoise ( OpenMS::Interfaces::ChromatogramPtr  chrom)
inline

Compute noise estimator for an m/z and intensity array using windows.

Will return a noise estimator object.

◆ estimateNoise() [3/3]

NoiseEstimator estimateNoise ( OpenMS::Interfaces::SpectrumPtr  spectrum)
inline

Compute noise estimator for an m/z and intensity array using windows.

Will return a noise estimator object.

Member Data Documentation

◆ window_length_

double window_length_
private

Window length parameter.