libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
localsignaltonoiseestimator.h
Go to the documentation of this file.
1// Copyright 2026 Filippo Rusconi
2// Largely inspired by code in OpenMS, by Chris Bielow
3
4#pragma once
5
6/////////////////////// stdlib includes
7
8
9/////////////////////// Qt includes
10#include <QList>
11#include <QMap>
12
13/////////////////////// pappsomspp includes
15
16
17/////////////////////// Local includes
19
20namespace pappso
21{
22
23using TraceIterator = std::vector<DataPoint>::const_iterator;
24
26{
27
28 public:
29 // We will need that in the Parameters below.
36
38 {
39 // Maximal intensity considered during binning (values above get discarded)
40 // This ensures that absurdly-intense peaks are not used to compute the
41 // stats about the maximum intensity of the trace.
42 double maxIntensity = -1;
43
44 // parameter for initial automatic estimation of "max_intensity_": a stdev
45 // multiplier
47
48 // parameter for initial automatic estimation of "max_intensity_" percentile
49 // or a stde
50 double maxIntPercentile = 95;
51
52 // Which method is used for estimating m_maxIntensity "max intensity of
53 // trace". valid are MANUAL, AUTOMABYSTDEV or AUTOMAXBYPERCENTILE
55
56 // range of data points which belong to a window in Thomson
57 double windowSize = 200;
58
59 // number of bins in the histogram
60 int binCount = 30;
61
62 // minimal number of elements a window needs to cover to be used
64
65 // used as noise value for windows which cover less than
66 // "min_required_elements_" use a very high value if you want to get a low
67 // S/N result
68 double noiseValueForEmptyWindow = std::pow(10.0, 20);
69
71 Parameters(double max_intensity,
72 double max_int_std_dev_factor,
73 double max_int_percentile,
74 int max_int_mode,
75 double window_size,
76 int bin_count,
77 int min_required_elements,
78 double noise_value_for_empty_window)
79 {
80 maxIntensity = max_intensity;
81 maxIntStdDevFactor = max_int_std_dev_factor;
82 maxIntPercentile = max_int_percentile;
83 maxIntMode = max_int_mode;
84 windowSize = window_size;
85 binCount = bin_count;
86 minRequiredElements = min_required_elements;
87 noiseValueForEmptyWindow = noise_value_for_empty_window;
88 }
89
101 };
102
103 explicit LocalSignalToNoiseEstimator(const Parameters &parameters);
105
107 {
108 // mean of estimated Gaussian
109 double mean;
110 // variance of estimated Gaussian
111 double variance;
112 };
113
115 estimateGaussian(const TraceIterator &iter_first_data_point,
116 const TraceIterator &iter_last_data_point) const;
117
118 void initialize(const Trace &trace);
119 void computeSignaToNoiseRatio(const Trace &trace);
120 double getSignalToNoiseRatio(qsizetype index) const;
121
122 protected:
124
125 // counter for sparse windows
127 // counter for histogram overflow
129
131};
132
133
134} // namespace pappso
LocalSignalToNoiseEstimator(const Parameters &parameters)
GaussianEstimateParams estimateGaussian(const TraceIterator &iter_first_data_point, const TraceIterator &iter_last_data_point) const
double getSignalToNoiseRatio(qsizetype index) const
A simple container of DataPoint instances.
Definition trace.h:152
#define PMSPP_LIB_DECL
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
std::vector< DataPoint >::const_iterator TraceIterator
Parameters(double max_intensity, double max_int_std_dev_factor, double max_int_percentile, int max_int_mode, double window_size, int bin_count, int min_required_elements, double noise_value_for_empty_window)