92 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)");
93 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.");
96 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"});
97 defaults_.setValue(
"sn_bin_count_", 30,
"Bin count for the Signal to Noise estimation.", {
"advanced"});
98 defaults_.setValue(
"nr_iterations_", 5,
"Nr of iterations to perform (how many times the peaks are re-centered).", {
"advanced"});
99 defaults_.setMinInt(
"nr_iterations_", 1);
100 defaults_.setValue(
"sn_win_len_", 20.0,
"Window length for the Signal to Noise estimation.", {
"advanced"});
102 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"});
103 defaults_.setValidStrings(
"check_width_internally", {
"true",
"false"});
105 defaults_.setValue(
"ms1_only",
"false",
"Only do MS1");
106 defaults_.setValidStrings(
"ms1_only", {
"true",
"false"});
107 defaults_.setValue(
"clear_meta_data",
"false",
"Delete meta data about peak width");
108 defaults_.setValidStrings(
"clear_meta_data", {
"true",
"false"});
116 signal_to_noise_ = (double)param_.getValue(
"signal_to_noise_");
117 peak_width_ = (double)param_.getValue(
"peak_width");
118 spacing_difference_ = (double)param_.getValue(
"spacing_difference");
119 sn_bin_count_ = (double)param_.getValue(
"sn_bin_count_");
120 nr_iterations_ = (double)param_.getValue(
"nr_iterations_");
121 sn_win_len_ = (double)param_.getValue(
"sn_win_len_");
123 check_width_internally_ = param_.getValue(
"check_width_internally").toBool();
143 std::vector<PeakCandidate>& PeakCandidates,
146 for (
Size peak_it = 0; peak_it < PeakCandidates.size(); peak_it++)
148 int i = PeakCandidates[peak_it].index;
149 double central_peak_mz = input[i].getMZ(), central_peak_int = input[i].getIntensity();
150 double left_neighbor_mz = input[i - 1].getMZ(), left_neighbor_int = input[i - 1].getIntensity();
151 double right_neighbor_mz = input[i + 1].getMZ(), right_neighbor_int = input[i + 1].getIntensity();
154 double left_to_central = std::fabs(central_peak_mz - left_neighbor_mz);
155 double central_to_right = std::fabs(right_neighbor_mz - central_peak_mz);
156 double min_spacing = (left_to_central < central_to_right) ? left_to_central : central_to_right;
157 double est_peak_width = peak_width_;
159 if (check_width_internally_ && (left_to_central > est_peak_width || central_to_right > est_peak_width))
162 PeakCandidates[peak_it].integrated_intensity = -1;
163 PeakCandidates[peak_it].leftWidth = -1;
164 PeakCandidates[peak_it].rightWidth = -1;
165 PeakCandidates[peak_it].mz = -1;
169 std::map<double, double> peak_raw_data;
171 peak_raw_data[central_peak_mz] = central_peak_int;
172 peak_raw_data[left_neighbor_mz] = left_neighbor_int;
173 peak_raw_data[right_neighbor_mz] = right_neighbor_int;
179 while ((i -
k + 1) > 0
180 && std::fabs(input[i -
k].getMZ() - peak_raw_data.begin()->first) < spacing_difference_ * min_spacing
181 && (input[i -
k].getIntensity() < peak_raw_data.begin()->second
182 || std::fabs(input[i -
k].getMZ() - central_peak_mz) < est_peak_width)
185 if (signal_to_noise_ > 0.0)
192 peak_raw_data[input[i -
k].getMZ()] = input[i -
k].getIntensity();
195 double leftborder = input[i -
k + 1].getMZ();
199 while ((i +
k) < input.size()
200 && std::fabs(input[i +
k].getMZ() - peak_raw_data.rbegin()->first) < spacing_difference_ * min_spacing
201 && (input[i +
k].getIntensity() < peak_raw_data.rbegin()->second
202 || std::fabs(input[i +
k].getMZ() - central_peak_mz) < est_peak_width)
205 if (signal_to_noise_ > 0.0)
213 peak_raw_data[input[i +
k].getMZ()] = input[i +
k].getIntensity();
219 double rightborder = input[i +
k - 1].getMZ();
221 double weighted_mz = 0;
222 double integrated_intensity = 0;
223 for (std::map<double, double>::const_iterator map_it = peak_raw_data.begin(); map_it != peak_raw_data.end(); ++map_it)
225 weighted_mz += map_it->first * map_it->second;
226 integrated_intensity += map_it->second;
228 weighted_mz /= integrated_intensity;
231 PeakCandidates[peak_it].integrated_intensity = integrated_intensity;
232 PeakCandidates[peak_it].leftWidth = leftborder;
233 PeakCandidates[peak_it].rightWidth = rightborder;
234 PeakCandidates[peak_it].mz = weighted_mz;
237 double min_diff = std::fabs(weighted_mz - input[i].getMZ());
241 for (
int m = 1; i - m > 0 && leftborder < input[i - m].getMZ(); m++)
243 if (std::fabs(weighted_mz - input[i - m].getMZ()) < min_diff)
245 min_diff = std::fabs(weighted_mz - input[i - m].getMZ());
250 for (
int m = 1; i - m > 0 && rightborder > input[i + m].getMZ(); m++)
252 if (std::fabs(weighted_mz - input[i + m].getMZ()) < min_diff)
254 min_diff = std::fabs(weighted_mz - input[i + m].getMZ());
258 PeakCandidates[peak_it].index = min_i;
277 if (input.size() < 3)
return;
284 std::vector<PeakCandidate> PeakCandidates;
290 pepi_param.
setValue(
"signal_to_noise", signal_to_noise_);
291 pepi_param.
setValue(
"spacing_difference", spacing_difference_);
293 pp.
pick(input, picked_spectrum);
296 std::vector<PeakCandidate> newPeakCandidates_;
299 for (
Size k = 0;
k < input.size() && j < picked_spectrum.size();
k++)
301 if (input[
k].getMZ() > picked_spectrum[j].getMZ())
304 PeakCandidate pc = {
static_cast<int>(
k), picked_spectrum[j].getIntensity(), -1, -1, -1, -1};
305 newPeakCandidates_.push_back(pc);
310 PeakCandidates = newPeakCandidates_;
315 if (signal_to_noise_ > 0.0)
318 snt_parameters.
setValue(
"win_len", sn_win_len_);
319 snt_parameters.
setValue(
"bin_count", sn_bin_count_);
325 for (
int i = 0; i < nr_iterations_; i++)
327 pickRecenterPeaks_(input, PeakCandidates, snt);
338 for (
Size peak_it = 0; peak_it < PeakCandidates.size(); peak_it++)
340 if (PeakCandidates[peak_it].leftWidth < 0)
continue;
343 for (
Size m = peak_it + 1; m < PeakCandidates.size(); m++)
345 if (PeakCandidates[m].mz >= PeakCandidates[peak_it].leftWidth && PeakCandidates[m].mz <= PeakCandidates[peak_it].rightWidth)
347 OPENMS_LOG_DEBUG <<
"Remove peak " << m <<
" : " << PeakCandidates[m].mz <<
" " <<
348 PeakCandidates[m].peak_apex_intensity <<
" (too close to " << PeakCandidates[peak_it].mz <<
349 " " << PeakCandidates[peak_it].peak_apex_intensity <<
")" << std::endl;
350 PeakCandidates[m].leftWidth = PeakCandidates[m].rightWidth = -1;
355 peak.
setMZ(PeakCandidates[peak_it].mz);
356 peak.
setIntensity(PeakCandidates[peak_it].integrated_intensity);
357 output.push_back(peak);
360 output.
getFloatDataArrays()[0].push_back(PeakCandidates[peak_it].integrated_intensity);
365 OPENMS_LOG_DEBUG <<
"Found seeds: " << PeakCandidates.size() <<
" / Found peaks: " << output.size() << std::endl;
380 bool ms1_only = param_.getValue(
"ms1_only").toBool();
381 bool clear_meta_data = param_.getValue(
"clear_meta_data").toBool();
384 startProgress(0, input.
size(),
"picking peaks");
385 for (
Size scan_idx = 0; scan_idx != input.
size(); ++scan_idx)
387 if (ms1_only && (input[scan_idx].getMSLevel() != 1))
389 output[scan_idx] = input[scan_idx];
393 pick(input[scan_idx], output[scan_idx]);
394 if (clear_meta_data) {output[scan_idx].getFloatDataArrays().
clear();}
396 setProgress(progress++);
#define OPENMS_LOG_DEBUG
Macro for general debugging information.
Definition: LogStream.h:454
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:66
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:36
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:46
void resize(Size n)
Resize to n spectra.
Definition: MSExperiment.h:127
Size size() const
The number of spectra.
Definition: MSExperiment.h:121
void clear(bool clear_meta_data)
Clears all data and meta data.
The representation of a 1D spectrum.
Definition: MSSpectrum.h:44
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:44
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:28
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: Peak1D.h:84
void setMZ(CoordinateType mz)
Mutable access to m/z.
Definition: Peak1D.h:93
This class implements a fast peak-picking algorithm best suited for high resolution MS data (FT-ICR-M...
Definition: PeakPickerHiRes.h:58
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:74
void pickExperiment(const PeakMap &input, PeakMap &output)
Definition: PeakPickerIterative.h:369
int nr_iterations_
Definition: PeakPickerIterative.h:81
double sn_win_len_
Definition: PeakPickerIterative.h:82
PeakPickerIterative()
Constructor.
Definition: PeakPickerIterative.h:88
~PeakPickerIterative() override
Destructor.
Definition: PeakPickerIterative.h:127
double spacing_difference_
Definition: PeakPickerIterative.h:79
bool check_width_internally_
Definition: PeakPickerIterative.h:83
double signal_to_noise_
Definition: PeakPickerIterative.h:77
int sn_bin_count_
Definition: PeakPickerIterative.h:80
double peak_width_
Definition: PeakPickerIterative.h:78
void updateMembers_() override
This method is used to update extra member variables at the end of the setParameters() method.
Definition: PeakPickerIterative.h:114
void pick(const MSSpectrum &input, MSSpectrum &output)
Definition: PeakPickerIterative.h:274
void pickRecenterPeaks_(const MSSpectrum &input, std::vector< PeakCandidate > &PeakCandidates, SignalToNoiseEstimatorMedian< MSSpectrum > &snt) const
Definition: PeakPickerIterative.h:142
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:27
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:75
virtual double getSignalToNoise(const Size index) const
Definition: SignalToNoiseEstimator.h:83
void setType(SpectrumType type)
sets the spectrum type
@ CENTROID
centroid data or stick data
Definition: SpectrumSettings.h:47
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:101
const double k
Definition: Constants.h:132
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22
double leftWidth
Definition: PeakPickerIterative.h:31
bool sort_peaks_by_intensity(const PeakCandidate &a, const PeakCandidate &b)
Definition: PeakPickerIterative.h:37
double peak_apex_intensity
Definition: PeakPickerIterative.h:28
int index
Definition: PeakPickerIterative.h:27
double integrated_intensity
Definition: PeakPickerIterative.h:30
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:33
double rightWidth
Definition: PeakPickerIterative.h:32
A small structure to hold peak candidates.
Definition: PeakPickerIterative.h:26