26 #include "../resample/convert2dense.hpp"
27 #include "pwiz/utility/findmf/base/filter/filter.hpp"
29 #include "pwiz/utility/findmf/base/filter/gaussfilter.hpp"
30 #include "pwiz/utility/findmf/base/base/interpolate.hpp"
31 #include "pwiz/utility/findmf/base/resample/determinebinwidth.hpp"
32 #include "pwiz/utility/findmf/base/base/copyif.hpp"
43 template<
typename TReal>
50 template<
typename Tzerocross,
typename T
intensity,
typename Tout>
53 [[maybe_unused]] Tintensity intensity,
57 typedef typename std::iterator_traits<Tout>::value_type AreaType;
58 for( ; beginZ != endZ ; ++beginZ, ++area )
60 size_t idx =
static_cast<size_t>( *beginZ );
61 size_t start =
static_cast<size_t>( std::round( idx -
integwith_ ) );
62 size_t end =
static_cast<size_t>( std::round( idx +
integwith_ + 2.) );
64 for( ; start != end ; ++start )
66 aread += *(resmpled + start);
75 template<
typename TReal>
88 template<
typename Tzerocross,
typename T
intensity,
typename Tout >
95 typedef typename std::iterator_traits<Tout>::value_type AreaType;
96 for( ; beginZ != endZ ; ++beginZ, ++area )
98 size_t idx =
static_cast<size_t>( *beginZ );
99 size_t start =
static_cast<size_t>( std::round( idx -
integwith_ ) );
100 size_t end =
static_cast<size_t>( std::round( idx +
integwith_ + 2) );
102 Tintensity st = intensity + start;
103 Tintensity en = intensity + end;
104 Tintensity center = intensity + idx;
105 std::ptrdiff_t x1 = std::distance(st, center);
106 std::ptrdiff_t y1 = std::distance(center,en);
108 std::ptrdiff_t x2 = std::distance(intensity,st);
109 std::ptrdiff_t y2 = std::distance(intensity,en);
110 std::ptrdiff_t pp = std::distance(st,en);
111 AreaType areav = std::accumulate(resampled+x2,resampled+y2,0.);
118 template<
typename TInt >
119 void mextend( TInt &start, TInt &end, TInt idx)
const
121 typedef typename std::iterator_traits<TInt>::value_type Intensitytype;
123 for(TInt intens = idx ; intens >= start; --intens) {
124 Intensitytype val1 = *intens;
125 Intensitytype val2 = *(intens-1);
138 for(TInt intens = idx ; intens <= end; ++intens) {
139 Intensitytype val1 = *intens;
140 Intensitytype val2 = *(intens+1);
158 template<
typename TReal,
template <
typename B>
class TIntegrator >
171 ralab::base::resample::SamplingWith
sw_;
178 std::pair<TReal, TReal> & massrange,
181 TReal intensitythreshold = 10.,
183 uint32_t maxnumberofpeaks = 0,
189 c2d_.
defBreak(massrange,ralab::base::resample::resolution2ppm(resolution));
191 ralab::base::filter::getGaussianFilterQuantile(
filter_,width);
195 template<
typename Tmass,
typename T
intensity>
196 void operator()(Tmass begmz, Tmass endmz, Tintensity begint )
199 typename std::iterator_traits<Tintensity>::value_type minint = *std::upper_bound(begint,begint+std::distance(begmz,endmz),0.1);
202 double a =
sw_(begmz,endmz);
237 if(threshmax > threshold)
238 threshold = threshmax;
242 if(threshold > 0.01) {
263 peakmass_.begin(),boost::bind(std::greater<TReal>(),_1,threshold));
265 typename std::vector<TReal>::iterator b = ralab::base::utils::copy_if(
peakarea_.begin(),
peakarea_.end(),
266 peakarea_.begin(),boost::bind(std::greater<TReal>(),_1,threshold));
void mextend(TInt &start, TInt &end, TInt idx) const
exend peak to left and rigth
void operator()(Tzerocross beginZ, Tzerocross endZ, Tintensity intensity, Tintensity resampled, Tout area) const
intagrates the peak intesnities
LocalMinPeakArea(TReal integwith, TReal threshold=.1)
uint32_t maxnumbersofpeaks_
std::vector< TReal > resampledmz_
std::vector< TReal > smoothedintensity_
std::vector< TReal > filter_
const std::vector< TReal > & getPeakMass()
const std::vector< TReal > & getSmoothedIntensity()
TIntegrator< value_type > PeakIntegrator
TReal getNToppeaks()
get min instensity of peak to qualify for max-intensity;
PeakIntegrator integrator_
const std::vector< TReal > & getResampledIntensity()
ralab::base::resample::Convert2Dense c2d_
std::vector< TReal > peakarea_
ralab::base::ms::SimplePicker< TReal > simplepicker_
void filter(TReal threshold)
clean the masses using the threshold
PeakPicker(TReal resolution, std::pair< TReal, TReal > &massrange, TReal width=2., TReal intwidth=2., TReal intensitythreshold=10., bool area=true, uint32_t maxnumberofpeaks=0, double c2d=1e-5)
std::vector< TReal > resampledintensity_
const std::vector< TReal > & getResampledMZ()
ralab::base::resample::SamplingWith sw_
void operator()(Tmass begmz, Tmass endmz, Tintensity begint)
TReal intensitythreshold_
std::vector< TReal > peakmass_
const std::vector< TReal > & getPeakArea()
std::vector< TReal > zerocross_
SimplePeakArea(TReal integwith)
void operator()(Tzerocross beginZ, Tzerocross endZ, [[maybe_unused]] Tintensity intensity, Tintensity resmpled, Tout area) const
intagrates the peak intesnities
computes first derivative of a sequence, looks for zero crossings
std::size_t defBreak(std::pair< double, double > &mzrange, double ppm)
computes split points of an map.
void getMids(std::vector< double > &mids)
void convert2dense(Tmass beginMass, Tmass endMass, Tintens intens, Tout ass)
Converts a sparse spec to a dense spec.