42 template <
typename PeakConstIterator>
45 typedef typename PeakConstIterator::value_type PeakT;
52 const int max_peaks = 5;
53 int profile_evidence = 0;
54 int centroid_evidence = 0;
57 std::vector<PeakT> data(begin, end);
59 double total_int = std::accumulate(begin, end, 0.0, [](
double int_,
const PeakT& p) {
return int_ + p.getIntensity(); } );
60 double explained_int = 0;
62 for (
int i = 0; i < max_peaks; ++i)
66 if (explained_int > 0.5 * total_int)
break;
69 Size idx = std::numeric_limits<Size>::max();
71 for (
Size i = 0; i < data.size(); ++i)
73 if (data[i].getIntensity() > int_max)
75 int_max = data[i].getIntensity();
80 if (idx == std::numeric_limits<Size>::max())
break;
83 typedef typename std::vector<PeakT>::iterator PeakIterator;
84 PeakIterator it_max = data.begin() + idx;
85 PeakIterator it = it_max;
86 double int_last = int_max;
87 while (it != data.begin()
88 && it->getIntensity() <= int_last
89 && it->getIntensity() > 0
90 && (it->getIntensity() / int_last) > 0.1
91 && it->getMZ() + 1 > it_max->getMZ())
93 int_last = it->getIntensity();
94 explained_int += int_last;
101 if (it->getIntensity() > int_last) (it+1)->setIntensity(int_last);
104 bool break_left =
false;
105 if (it_max - it < 2+1)
111 it_max->setIntensity(int_max);
112 explained_int -= int_max;
115 while (it != data.end()
116 && it->getIntensity() <= int_last
117 && it->getIntensity() > 0
118 && (it->getIntensity() / int_last) > 0.1
119 && it->getMZ() - 1 < it_max->getMZ())
121 int_last = it->getIntensity();
122 explained_int += int_last;
130 if (it != data.end() && it->getIntensity() > int_last) (it-1)->setIntensity(int_last);
132 if (break_left || it - it_max < 2+1)
144 float evidence_ratio = profile_evidence / float(profile_evidence + centroid_evidence);
147 if (evidence_ratio > 0.75)
Estimates if the data of a spectrum is raw data or peak data.
Definition: PeakTypeEstimator.h:24
static SpectrumSettings::SpectrumType estimateType(const PeakConstIterator &begin, const PeakConstIterator &end)
Estimates the peak type of the peaks in the iterator range based on intensity characteristics of up t...
Definition: PeakTypeEstimator.h:43
SpectrumType
Spectrum peak type.
Definition: SpectrumSettings.h:45
@ UNKNOWN
Unknown spectrum type.
Definition: SpectrumSettings.h:46
@ PROFILE
profile data
Definition: SpectrumSettings.h:48
@ CENTROID
centroid data or stick data
Definition: SpectrumSettings.h:47
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:97
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19