89 template<
class InputIt,
class OutputIt>
90 void filter(InputIt first, InputIt last, OutputIt d_first)
92 size_t n = std::distance(first, last);
94 if (frame_size_ > n) {
return; }
98 int mid = (frame_size_ / 2);
102 OutputIt out_it = d_first;
104 for (i = 0; i <= mid; ++i)
106 InputIt it_forward = (first - i);
108 for (j = 0; j < frame_size_; ++j)
110 help += it_forward->getIntensity() * coeffs_[(i + 1) * frame_size_ - 1 - j];
114 out_it->setPosition(first->getPosition());
115 out_it->setIntensity(std::max(0.0, help));
121 InputIt it_help = (last - mid);
123 while (first != it_help)
125 InputIt it_forward = (first - mid);
128 for (j = 0; j < frame_size_; ++j)
130 help += it_forward->getIntensity() * coeffs_[mid * frame_size_ + j];
134 out_it->setPosition(first->getPosition());
135 out_it->setIntensity(std::max(0.0, help));
141 for (i = (mid - 1); i >= 0; --i)
143 InputIt it_forward = (first - (frame_size_ - i - 1));
146 for (j = 0; j < frame_size_; ++j)
148 help += it_forward->getIntensity() * coeffs_[i * frame_size_ + j];
152 out_it->setPosition(first->getPosition());
153 out_it->setIntensity(std::max(0.0, help));
168 filter(spectrum.begin(), spectrum.end(), output.begin());
170 std::swap(spectrum, output);
181 filter(chromatogram.begin(), chromatogram.end(), output.begin());
183 std::swap(chromatogram, output);
194 filter(mobilogram.
begin(), mobilogram.
end(), output.
begin());
196 std::swap(mobilogram, output);
206 for (
Size i = 0; i < map.
size(); ++i)
209 setProgress(++progress);
214 setProgress(++progress);
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:66
The representation of a chromatogram.
Definition: MSChromatogram.h:30
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:46
const std::vector< MSChromatogram > & getChromatograms() const
returns the chromatogram list
MSChromatogram & getChromatogram(Size id)
returns a single chromatogram
Size size() const noexcept
The number of spectra.
Definition: MSExperiment.h:121
The representation of a 1D spectrum.
Definition: MSSpectrum.h:44
The representation of a 1D ion mobilogram.
Definition: Mobilogram.h:32
Iterator begin() noexcept
Definition: Mobilogram.h:144
Iterator end() noexcept
Definition: Mobilogram.h:157
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:27
Computes the Savitzky-Golay filter coefficients using QR decomposition.
Definition: SavitzkyGolayFilter.h:79
std::vector< double > coeffs_
Coefficients.
Definition: SavitzkyGolayFilter.h:221
void filter(MSChromatogram &chromatogram)
Removed the noise from an MSChromatogram.
Definition: SavitzkyGolayFilter.h:176
void filter(InputIt first, InputIt last, OutputIt d_first)
Definition: SavitzkyGolayFilter.h:90
void filter(MSSpectrum &spectrum)
Removed the noise from an MSSpectrum containing profile data.
Definition: SavitzkyGolayFilter.h:163
SavitzkyGolayFilter()
Constructor.
void filter(Mobilogram &mobilogram)
Removed the noise from an Mobilogram.
Definition: SavitzkyGolayFilter.h:189
~SavitzkyGolayFilter() override
Destructor.
void filterExperiment(PeakMap &map)
Removed the noise from an MSExperiment containing profile data.
Definition: SavitzkyGolayFilter.h:202
void updateMembers_() override
This method is used to update extra member variables at the end of the setParameters() method.
UInt frame_size_
UInt of the filter kernel (number of pre-tabulated coefficients)
Definition: SavitzkyGolayFilter.h:224
UInt order_
The order of the smoothing polynomial.
Definition: SavitzkyGolayFilter.h:227
unsigned int UInt
Unsigned integer type.
Definition: Types.h:64
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