118 defaults_.setValue(
"signal_to_noise_", 1.0,
"Signal to noise value, each peak is required to be above this value (turn off by setting it to 0.0)");
119 defaults_.setValue(
"peak_width", 0.0,
"Expected peak width half width in Dalton - peaks will be extended until this half width is reached (even if the intensitity is increasing). In conjunction with check_width_internally it will also be used to remove peaks whose spacing is larger than this value.");
122 defaults_.setValue(
"spacing_difference", 1.5,
"Difference between peaks in multiples of the minimal difference to continue. The higher this value is set, the further apart peaks are allowed to be to still extend a peak. E.g. if the value is set to 1.5 and in a current peak the minimal spacing between peaks is 10 mDa, then only peaks at most 15 mDa apart will be added to the peak.", {
"advanced"});
123 defaults_.setValue(
"sn_bin_count_", 30,
"Bin count for the Signal to Noise estimation.", {
"advanced"});
124 defaults_.setValue(
"nr_iterations_", 5,
"Nr of iterations to perform (how many times the peaks are re-centered).", {
"advanced"});
125 defaults_.setMinInt(
"nr_iterations_", 1);
126 defaults_.setValue(
"sn_win_len_", 20.0,
"Window length for the Signal to Noise estimation.", {
"advanced"});
128 defaults_.setValue(
"check_width_internally",
"false",
"Delete peaks where the spacing is larger than the peak width (should be set to true to avoid artefacts)", {
"advanced"});
129 defaults_.setValidStrings(
"check_width_internally", {
"true",
"false"});
131 defaults_.setValue(
"ms1_only",
"false",
"Only do MS1");
132 defaults_.setValidStrings(
"ms1_only", {
"true",
"false"});
133 defaults_.setValue(
"clear_meta_data",
"false",
"Delete meta data about peak width");
134 defaults_.setValidStrings(
"clear_meta_data", {
"true",
"false"});
142 signal_to_noise_ = (double)param_.getValue(
"signal_to_noise_");
143 peak_width_ = (double)param_.getValue(
"peak_width");
144 spacing_difference_ = (double)param_.getValue(
"spacing_difference");
145 sn_bin_count_ = (double)param_.getValue(
"sn_bin_count_");
146 nr_iterations_ = (double)param_.getValue(
"nr_iterations_");
147 sn_win_len_ = (double)param_.getValue(
"sn_win_len_");
149 check_width_internally_ = param_.getValue(
"check_width_internally").toBool();
169 std::vector<PeakCandidate>& PeakCandidates,
172 for (
Size peak_it = 0; peak_it < PeakCandidates.size(); peak_it++)
174 int i = PeakCandidates[peak_it].index;
175 double central_peak_mz = input[i].getMZ(), central_peak_int = input[i].getIntensity();
176 double left_neighbor_mz = input[i - 1].getMZ(), left_neighbor_int = input[i - 1].getIntensity();
177 double right_neighbor_mz = input[i + 1].getMZ(), right_neighbor_int = input[i + 1].getIntensity();
180 double left_to_central = std::fabs(central_peak_mz - left_neighbor_mz);
181 double central_to_right = std::fabs(right_neighbor_mz - central_peak_mz);
182 double min_spacing = (left_to_central < central_to_right) ? left_to_central : central_to_right;
183 double est_peak_width = peak_width_;
185 if (check_width_internally_ && (left_to_central > est_peak_width || central_to_right > est_peak_width))
188 PeakCandidates[peak_it].integrated_intensity = -1;
189 PeakCandidates[peak_it].leftWidth = -1;
190 PeakCandidates[peak_it].rightWidth = -1;
191 PeakCandidates[peak_it].mz = -1;
195 std::map<double, double> peak_raw_data;
197 peak_raw_data[central_peak_mz] = central_peak_int;
198 peak_raw_data[left_neighbor_mz] = left_neighbor_int;
199 peak_raw_data[right_neighbor_mz] = right_neighbor_int;
205 while ((i -
k + 1) > 0
206 && std::fabs(input[i -
k].getMZ() - peak_raw_data.begin()->first) < spacing_difference_ * min_spacing
207 && (input[i -
k].getIntensity() < peak_raw_data.begin()->second
208 || std::fabs(input[i -
k].getMZ() - central_peak_mz) < est_peak_width)
211 if (signal_to_noise_ > 0.0)
218 peak_raw_data[input[i -
k].getMZ()] = input[i -
k].getIntensity();
221 double leftborder = input[i -
k + 1].getMZ();
225 while ((i +
k) < input.size()
226 && std::fabs(input[i +
k].getMZ() - peak_raw_data.rbegin()->first) < spacing_difference_ * min_spacing
227 && (input[i +
k].getIntensity() < peak_raw_data.rbegin()->second
228 || std::fabs(input[i +
k].getMZ() - central_peak_mz) < est_peak_width)
231 if (signal_to_noise_ > 0.0)
239 peak_raw_data[input[i +
k].getMZ()] = input[i +
k].getIntensity();
245 double rightborder = input[i +
k - 1].getMZ();
247 double weighted_mz = 0;
248 double integrated_intensity = 0;
249 for (std::map<double, double>::const_iterator map_it = peak_raw_data.begin(); map_it != peak_raw_data.end(); ++map_it)
251 weighted_mz += map_it->first * map_it->second;
252 integrated_intensity += map_it->second;
254 weighted_mz /= integrated_intensity;
257 PeakCandidates[peak_it].integrated_intensity = integrated_intensity;
258 PeakCandidates[peak_it].leftWidth = leftborder;
259 PeakCandidates[peak_it].rightWidth = rightborder;
260 PeakCandidates[peak_it].mz = weighted_mz;
263 double min_diff = std::fabs(weighted_mz - input[i].getMZ());
267 for (
int m = 1; i - m > 0 && leftborder < input[i - m].getMZ(); m++)
269 if (std::fabs(weighted_mz - input[i - m].getMZ()) < min_diff)
271 min_diff = std::fabs(weighted_mz - input[i - m].getMZ());
276 for (
int m = 1; i - m > 0 && rightborder > input[i + m].getMZ(); m++)
278 if (std::fabs(weighted_mz - input[i + m].getMZ()) < min_diff)
280 min_diff = std::fabs(weighted_mz - input[i + m].getMZ());
284 PeakCandidates[peak_it].index = min_i;
303 if (input.size() < 3)
return;
310 std::vector<PeakCandidate> PeakCandidates;
316 pepi_param.
setValue(
"signal_to_noise", signal_to_noise_);
317 pepi_param.
setValue(
"spacing_difference", spacing_difference_);
319 pp.
pick(input, picked_spectrum);
322 std::vector<PeakCandidate> newPeakCandidates_;
325 for (
Size k = 0;
k < input.size() && j < picked_spectrum.size();
k++)
327 if (input[
k].getMZ() > picked_spectrum[j].getMZ())
330 PeakCandidate pc = {
static_cast<int>(
k), picked_spectrum[j].getIntensity(), -1, -1, -1, -1};
331 newPeakCandidates_.push_back(pc);
336 PeakCandidates = newPeakCandidates_;
341 if (signal_to_noise_ > 0.0)
344 snt_parameters.
setValue(
"win_len", sn_win_len_);
345 snt_parameters.
setValue(
"bin_count", sn_bin_count_);
351 for (
int i = 0; i < nr_iterations_; i++)
353 pickRecenterPeaks_(input, PeakCandidates, snt);
364 for (
Size peak_it = 0; peak_it < PeakCandidates.size(); peak_it++)
366 if (PeakCandidates[peak_it].leftWidth < 0)
continue;
369 for (
Size m = peak_it + 1; m < PeakCandidates.size(); m++)
371 if (PeakCandidates[m].mz >= PeakCandidates[peak_it].leftWidth && PeakCandidates[m].mz <= PeakCandidates[peak_it].rightWidth)
373 OPENMS_LOG_DEBUG <<
"Remove peak " << m <<
" : " << PeakCandidates[m].mz <<
" " <<
374 PeakCandidates[m].peak_apex_intensity <<
" (too close to " << PeakCandidates[peak_it].mz <<
375 " " << PeakCandidates[peak_it].peak_apex_intensity <<
")" << std::endl;
376 PeakCandidates[m].leftWidth = PeakCandidates[m].rightWidth = -1;
381 peak.
setMZ(PeakCandidates[peak_it].mz);
382 peak.
setIntensity(PeakCandidates[peak_it].integrated_intensity);
383 output.push_back(peak);
386 output.
getFloatDataArrays()[0].push_back(PeakCandidates[peak_it].integrated_intensity);
391 OPENMS_LOG_DEBUG <<
"Found seeds: " << PeakCandidates.size() <<
" / Found peaks: " << output.size() << std::endl;
406 bool ms1_only = param_.getValue(
"ms1_only").toBool();
407 bool clear_meta_data = param_.getValue(
"clear_meta_data").toBool();
410 startProgress(0, input.
size(),
"picking peaks");
411 for (
Size scan_idx = 0; scan_idx != input.
size(); ++scan_idx)
413 if (ms1_only && (input[scan_idx].getMSLevel() != 1))
415 output[scan_idx] = input[scan_idx];
419 pick(input[scan_idx], output[scan_idx]);
420 if (clear_meta_data) {output[scan_idx].getFloatDataArrays().
clear();}
422 setProgress(progress++);
#define OPENMS_LOG_DEBUG
Macro for general debugging information.
Definition: LogStream.h:470
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:93
const Param & getParameters() const
Non-mutable access to the parameters.
void setParameters(const Param ¶m)
Sets the parameters.
const Param & getDefaults() const
Non-mutable access to the default parameters.
Description of the experimental settings.
Definition: ExperimentalSettings.h:62
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:73
void resize(Size s)
Definition: MSExperiment.h:125
Size size() const
Definition: MSExperiment.h:120
void clear(bool clear_meta_data)
Clears all data and meta data.
The representation of a 1D spectrum.
Definition: MSSpectrum.h:70
void sortByPosition()
Lexicographically sorts the peaks by their position.
const FloatDataArrays & getFloatDataArrays() const
Returns a const reference to the float meta data arrays.
Management and storage of parameters / INI files.
Definition: Param.h:70
void setValue(const std::string &key, const ParamValue &value, const std::string &description="", const std::vector< std::string > &tags=std::vector< std::string >())
Sets a value.
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:54
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: Peak1D.h:104
void setMZ(CoordinateType mz)
Mutable access to m/z.
Definition: Peak1D.h:113
This class implements a fast peak-picking algorithm best suited for high resolution MS data (FT-ICR-M...
Definition: PeakPickerHiRes.h:76
void pick(const MSSpectrum &input, MSSpectrum &output) const
Applies the peak-picking algorithm to a single spectrum (MSSpectrum). The resulting picked peaks are ...
This class implements a peak-picking algorithm for high-resolution MS data (specifically designed for...
Definition: PeakPickerIterative.h:100
void pickExperiment(const PeakMap &input, PeakMap &output)
Definition: PeakPickerIterative.h:395
int nr_iterations_
Definition: PeakPickerIterative.h:107
double sn_win_len_
Definition: PeakPickerIterative.h:108
PeakPickerIterative()
Constructor.
Definition: PeakPickerIterative.h:114
~PeakPickerIterative() override
Destructor.
Definition: PeakPickerIterative.h:153
double spacing_difference_
Definition: PeakPickerIterative.h:105
bool check_width_internally_
Definition: PeakPickerIterative.h:109
double signal_to_noise_
Definition: PeakPickerIterative.h:103
int sn_bin_count_
Definition: PeakPickerIterative.h:106
double peak_width_
Definition: PeakPickerIterative.h:104
void updateMembers_() override
This method is used to update extra member variables at the end of the setParameters() method.
Definition: PeakPickerIterative.h:140
void pick(const MSSpectrum &input, MSSpectrum &output)
Definition: PeakPickerIterative.h:300
void pickRecenterPeaks_(const MSSpectrum &input, std::vector< PeakCandidate > &PeakCandidates, SignalToNoiseEstimatorMedian< MSSpectrum > &snt) const
Definition: PeakPickerIterative.h:168
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:53
virtual void init(const Container &c)
Set the start and endpoint of the raw data interval, for which signal to noise ratios will be estimat...
Definition: SignalToNoiseEstimator.h:101
virtual double getSignalToNoise(const Size index) const
Definition: SignalToNoiseEstimator.h:109
void setType(SpectrumType type)
sets the spectrum type
@ CENTROID
centroid data or stick data
Definition: SpectrumSettings.h:73
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
const double k
Definition: Constants.h:153
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
double leftWidth
Definition: PeakPickerIterative.h:57
bool sort_peaks_by_intensity(const PeakCandidate &a, const PeakCandidate &b)
Definition: PeakPickerIterative.h:63
double peak_apex_intensity
Definition: PeakPickerIterative.h:54
int index
Definition: PeakPickerIterative.h:53
double integrated_intensity
Definition: PeakPickerIterative.h:56
void copySpectrumMeta(const MSSpectrum &input, MSSpectrum &output, bool clear_spectrum=true)
Copies only the meta data contained in the input spectrum to the output spectrum.
float mz
Definition: PeakPickerIterative.h:59
double rightWidth
Definition: PeakPickerIterative.h:58
A small structure to hold peak candidates.
Definition: PeakPickerIterative.h:52