OpenMS
SqrtScaler.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Mathias Walzer $
6 // $Authors: $
7 // --------------------------------------------------------------------------
8 //
9 #pragma once
10 
15 
16 #include <cmath>
17 
18 namespace OpenMS
19 {
25  class OPENMS_DLLAPI SqrtScaler :
26  public DefaultParamHandler
27  {
28 public:
29 
30  // @name Constructors and Destructors
31  // @{
35  ~SqrtScaler() override;
36 
38  SqrtScaler(const SqrtScaler & source);
40  SqrtScaler & operator=(const SqrtScaler & source);
41  // @}
42 
44  template <typename SpectrumType>
45  void filterSpectrum(SpectrumType & spectrum)
46  {
47  bool warning = false;
48  for (typename SpectrumType::Iterator it = spectrum.begin(); it != spectrum.end(); ++it)
49  {
50  double intens = it->getIntensity();
51  if (intens < 0)
52  {
53  intens = 0;
54  warning = true;
55  }
56  it->setIntensity(std::sqrt(intens));
57  }
58  if (warning)
59  {
60  std::cerr << "Warning negative intensities were set to zero" << std::endl;
61  }
62  return;
63  }
64 
65  void filterPeakSpectrum(PeakSpectrum & spectrum);
66 
67  void filterPeakMap(PeakMap & exp);
68 
69  //TODO reimplement DefaultParamHandler::updateMembers_()
70 
71  // @}
72 
73  };
74 
75 }
76 
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:66
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:46
The representation of a 1D spectrum.
Definition: MSSpectrum.h:44
ContainerType::iterator Iterator
Mutable iterator.
Definition: MSSpectrum.h:108
Scales the intensity of peaks to the sqrt.
Definition: SqrtScaler.h:27
SqrtScaler & operator=(const SqrtScaler &source)
assignment operator
SqrtScaler(const SqrtScaler &source)
copy constructor
SqrtScaler()
default constructor
void filterPeakSpectrum(PeakSpectrum &spectrum)
void filterPeakMap(PeakMap &exp)
void filterSpectrum(SpectrumType &spectrum)
Definition: SqrtScaler.h:45
~SqrtScaler() override
destructor
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19