ProteoWizard
Functions
pwiz::math::MatchedFilter::details Namespace Reference

Functions

template<typename Kernel >
KernelTraits< Kernel >::filter_type createFilter (const Kernel &kernel, int sampleRadius, typename KernelTraits< Kernel >::abscissa_type dx, typename KernelTraits< Kernel >::abscissa_type shift)
 
double norm (double d)
 
double conj (double d)
 
template<typename Filter >
void normalizeFilter (Filter &filter)
 
template<typename Kernel >
std::vector< typename KernelTraits< Kernel >::filter_type > createFilters (const Kernel &kernel, int sampleRadius, int subsampleFactor, typename KernelTraits< Kernel >::abscissa_type dx)
 
template<typename Kernel >
void computeCorrelation (typename KernelTraits< Kernel >::samples_type::const_iterator samples, typename KernelTraits< Kernel >::samples_type::const_iterator samplesEnd, typename KernelTraits< Kernel >::samples_type::const_iterator filter, typename KernelTraits< Kernel >::correlation_type &result)
 

Function Documentation

§ createFilter()

template<typename Kernel >
KernelTraits<Kernel>::filter_type pwiz::math::MatchedFilter::details::createFilter ( const Kernel &  kernel,
int  sampleRadius,
typename KernelTraits< Kernel >::abscissa_type  dx,
typename KernelTraits< Kernel >::abscissa_type  shift 
)

Definition at line 206 of file MatchedFilter.hpp.

References ralab::base::filter::filter().

Referenced by createFilters(), and test_createFilter().

210 {
211  checkKernelConcept<Kernel>();
212 
213  typename KernelTraits<Kernel>::filter_type filter;
214  for (int i=-sampleRadius; i<=sampleRadius; i++)
215  filter.push_back(kernel(i*dx - shift));
216  return filter;
217 }
void filter(const TContainer &data, const TContainer &filter, TContainer &result, bool circular=false, uint32_t sides=2)
Applies linear convolution (filtering) to a univariate time series.
Definition: filter.hpp:112

§ norm()

double pwiz::math::MatchedFilter::details::norm ( double  d)
inline

§ conj()

double pwiz::math::MatchedFilter::details::conj ( double  d)
inline

§ normalizeFilter()

template<typename Filter >
void pwiz::math::MatchedFilter::details::normalizeFilter ( Filter &  filter)

Definition at line 226 of file MatchedFilter.hpp.

References norm().

227 {
228  double normalization = 0;
229  for (typename Filter::const_iterator it=filter.begin(); it!=filter.end(); ++it)
230  normalization += norm(*it);
231  normalization = sqrt(normalization);
232 
233  for (typename Filter::iterator it=filter.begin(); it!=filter.end(); ++it)
234  *it /= normalization;
235 }
void filter(const TContainer &data, const TContainer &filter, TContainer &result, bool circular=false, uint32_t sides=2)
Applies linear convolution (filtering) to a univariate time series.
Definition: filter.hpp:112

§ createFilters()

template<typename Kernel >
std::vector<typename KernelTraits<Kernel>::filter_type> pwiz::math::MatchedFilter::details::createFilters ( const Kernel &  kernel,
int  sampleRadius,
int  subsampleFactor,
typename KernelTraits< Kernel >::abscissa_type  dx 
)

Definition at line 240 of file MatchedFilter.hpp.

References createFilter().

Referenced by pwiz::math::MatchedFilter::computeCorrelationData(), and test_createFilters().

244 {
245  checkKernelConcept<Kernel>();
246 
247  typedef typename KernelTraits<Kernel>::filter_type filter_type;
248  std::vector<filter_type> filters;
249 
250  for (int i=0; i<subsampleFactor; i++)
251  filters.push_back(createFilter(kernel, sampleRadius, dx, dx*i/subsampleFactor));
252 
253  for_each(filters.begin(), filters.end(), normalizeFilter<filter_type>);
254 
255  return filters;
256 }
KernelTraits< Kernel >::filter_type createFilter(const Kernel &kernel, int sampleRadius, typename KernelTraits< Kernel >::abscissa_type dx, typename KernelTraits< Kernel >::abscissa_type shift)

§ computeCorrelation()

template<typename Kernel >
void pwiz::math::MatchedFilter::details::computeCorrelation ( typename KernelTraits< Kernel >::samples_type::const_iterator  samples,
typename KernelTraits< Kernel >::samples_type::const_iterator  samplesEnd,
typename KernelTraits< Kernel >::samples_type::const_iterator  filter,
typename KernelTraits< Kernel >::correlation_type &  result 
)

Definition at line 261 of file MatchedFilter.hpp.

References conj(), pwiz::math::MatchedFilter::Correlation< Y >::dot, pwiz::math::MatchedFilter::Correlation< Y >::e2, ralab::base::filter::filter(), norm(), and pwiz::math::MatchedFilter::Correlation< Y >::tan2angle.

265 {
266  checkKernelConcept<Kernel>();
267  result.dot = 0;
268  double normData = 0;
269 
270  for (; samples!=samplesEnd; ++samples, ++filter)
271  {
272  result.dot += (*samples) * conj(*filter);
273  normData += norm(*samples);
274  }
275 
276  double normDot = norm(result.dot);
277  result.e2 = (std::max)(normData - normDot, 0.);
278  result.tan2angle = normDot>0 ? result.e2/normDot : std::numeric_limits<double>::infinity();
279 }
void filter(const TContainer &data, const TContainer &filter, TContainer &result, bool circular=false, uint32_t sides=2)
Applies linear convolution (filtering) to a univariate time series.
Definition: filter.hpp:112