35 #ifndef OPENMS_FORMAT_PEAKTYPEESTIMATOR_H 36 #define OPENMS_FORMAT_PEAKTYPEESTIMATOR_H 58 template <
typename PeakConstIterator>
61 const Size MAX_SAMPLED_DISTANCES = 1000;
62 const double DISTANCE_VARIANCE_THRESHOLD = 0.5;
72 std::vector<double> distances;
74 PeakConstIterator peak(begin);
76 for (; peak->getIntensity() <= 0 && peak != end - 2; ++peak)
80 double scnd_last_mz(peak->getMZ());
82 for (++peak; peak->getIntensity() <= 0 && peak != end - 1; ++peak)
86 double last_mz(peak->getMZ());
88 double last_dist(last_mz - scnd_last_mz);
90 for (++peak; peak != end && count < MAX_SAMPLED_DISTANCES; ++peak)
92 if (peak->getIntensity() > 0)
94 double mz(peak->getMZ());
95 double dist(mz - last_mz);
96 distances.push_back(std::min(last_dist, dist));
98 scnd_last_mz = last_mz;
109 double mean(std::accumulate(distances.begin(), distances.end(), 0) / count);
113 for (std::vector<double>::iterator value = distances.begin(); value != distances.end(); ++value)
115 double delta = (*value -
mean);
116 variance += delta * delta;
118 variance /= count - 1;
121 double standard_deviation(std::sqrt(variance));
123 if (standard_deviation < DISTANCE_VARIANCE_THRESHOLD)
137 #endif // OPENMS_FORMAT_PEAKTYPEESTIMATOR_H static double variance(IteratorType begin, IteratorType end, double mean=std::numeric_limits< double >::max())
Calculates the variance of a range of values.
Definition: StatisticFunctions.h:280
Peak data (also called centroided data or stick data)
Definition: SpectrumSettings.h:74
SpectrumType
Spectrum peak type.
Definition: SpectrumSettings.h:71
Raw data (also called profile data)
Definition: SpectrumSettings.h:75
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Unknown spectrum type.
Definition: SpectrumSettings.h:73
static double mean(IteratorType begin, IteratorType end)
Calculates the mean of a range of values.
Definition: StatisticFunctions.h:135
SpectrumSettings::SpectrumType estimateType(const PeakConstIterator &begin, const PeakConstIterator &end) const
Estimates the peak type of the peaks in the iterator range based on the variance of inter-peak distan...
Definition: PeakTypeEstimator.h:59
Estimates if the data of a spectrum is raw data or peak data.
Definition: PeakTypeEstimator.h:50
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:128