35 #ifndef OPENMS_FILTERING_SMOOTHING_SAVITZKYGOLAYFILTER_H 36 #define OPENMS_FILTERING_SMOOTHING_SAVITZKYGOLAYFILTER_H 115 template<
class InputIt,
class OutputIt>
116 void filter(InputIt first, InputIt last, OutputIt d_first)
118 size_t n = std::distance(first, last);
120 if (frame_size_ > n) {
return; }
124 int mid = (frame_size_ / 2);
128 OutputIt out_it = d_first;
130 for (i = 0; i <= mid; ++i)
132 InputIt it_forward = (first - i);
134 for (j = 0; j < frame_size_; ++j)
136 help += it_forward->getIntensity() * coeffs_[(i + 1) * frame_size_ - 1 - j];
140 out_it->setPosition(first->getPosition());
141 out_it->setIntensity(std::max(0.0, help));
147 InputIt it_help = (last - mid);
149 while (first != it_help)
151 InputIt it_forward = (first - mid);
154 for (j = 0; j < frame_size_; ++j)
156 help += it_forward->getIntensity() * coeffs_[mid * frame_size_ + j];
160 out_it->setPosition(first->getPosition());
161 out_it->setIntensity(std::max(0.0, help));
167 for (i = (mid - 1); i >= 0; --i)
169 InputIt it_forward = (first - (frame_size_ - i - 1));
172 for (j = 0; j < frame_size_; ++j)
174 help += it_forward->getIntensity() * coeffs_[i * frame_size_ + j];
178 out_it->setPosition(first->getPosition());
179 out_it->setIntensity(std::max(0.0, help));
194 filter(spectrum.begin(), spectrum.end(), output.begin());
196 std::swap(spectrum, output);
207 filter(chromatogram.begin(), chromatogram.end(), output.begin());
209 std::swap(chromatogram, output);
219 for (
Size i = 0; i < map.
size(); ++i)
222 setProgress(++progress);
227 setProgress(++progress);
243 virtual void updateMembers_();
247 #endif // OPENMS_FILTERING_SMOOTHING_SAVITZKYGOLAYFILTER_H void filter(InputIt first, InputIt last, OutputIt d_first)
Definition: SavitzkyGolayFilter.h:116
const std::vector< MSChromatogram > & getChromatograms() const
returns the chromatogram list
Definition: MSExperiment.h:861
void filter(MSSpectrum &spectrum)
Removed the noise from an MSSpectrum containing profile data.
Definition: SavitzkyGolayFilter.h:189
The representation of a chromatogram.
Definition: MSChromatogram.h:55
unsigned int UInt
Unsigned integer type.
Definition: Types.h:95
UInt frame_size_
UInt of the filter kernel (number of pre-tabulated coefficients)
Definition: SavitzkyGolayFilter.h:237
Size size() const
Definition: MSExperiment.h:132
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
void filterExperiment(PeakMap &map)
Removed the noise from an MSExperiment containing profile data.
Definition: SavitzkyGolayFilter.h:215
UInt order_
The order of the smoothing polynomial.
Definition: SavitzkyGolayFilter.h:240
The representation of a 1D spectrum.
Definition: MSSpectrum.h:67
Computes the Savitzky-Golay filter coefficients using QR decomposition.
Definition: SavitzkyGolayFilter.h:102
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:82
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:128
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:55
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:92
std::vector< double > coeffs_
Coefficients.
Definition: SavitzkyGolayFilter.h:234
MSChromatogram & getChromatogram(Size id)
returns a single chromatogram
Definition: MSExperiment.h:875
void filter(MSChromatogram &chromatogram)
Removed the noise from an MSChromatogram.
Definition: SavitzkyGolayFilter.h:202