62 #include <unsupported/Eigen/NonLinearOptimization>
64 #ifndef OPENMS_SYSTEM_STOPWATCH_H
67 #include <boost/math/special_functions/acosh.hpp>
111 tolerance_mz_ = tolerance_mz;
112 param_.setValue(
"2d:tolerance_mz", tolerance_mz);
120 max_peak_distance_ = max_peak_distance;
121 param_.setValue(
"2d:max_peak_distance", max_peak_distance);
129 max_iteration_ = max_iteration;
130 param_.setValue(
"iterations", max_iteration);
138 penalties_ = penalties;
139 param_.setValue(
"penalties:position", penalties.
pos);
140 param_.setValue(
"penalties:height", penalties.
height);
141 param_.setValue(
"penalties:left_width", penalties.
lWidth);
142 param_.setValue(
"penalties:right_width", penalties.
rWidth);
161 template <
typename InputSpectrumIterator>
162 void optimize(InputSpectrumIterator first,
163 InputSpectrumIterator last,
164 PeakMap& ms_exp,
bool real2D =
true);
171 std::vector<std::pair<SignedSize, SignedSize> >
signal2D;
189 : m_inputs(dimensions), m_values(num_data_points), m_data(data) {}
191 int operator()(
const Eigen::VectorXd &x, Eigen::VectorXd &fvec);
193 int df(
const Eigen::VectorXd &x, Eigen::MatrixXd &J);
233 std::vector<double>::iterator
searchInScan_(std::vector<double>::iterator scan_begin,
234 std::vector<double>::iterator scan_end,
238 template <
typename InputSpectrumIterator>
239 void optimizeRegions_(InputSpectrumIterator& first,
240 InputSpectrumIterator& last,
244 template <
typename InputSpectrumIterator>
245 void optimizeRegionsScanwise_(InputSpectrumIterator& first,
246 InputSpectrumIterator& last,
251 template <
typename InputSpectrumIterator>
252 void getRegionEndpoints_(
PeakMap& exp,
253 InputSpectrumIterator& first,
254 InputSpectrumIterator& last,
270 template <
typename InputSpectrumIterator>
275 if ((
UInt)distance(first, last) != ms_exp.
size())
277 throw Exception::IllegalArgument(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
"Error in Two2Optimization: Raw and peak map do not have the same number of spectra");
285 for (
Size i = 0; i < ms_exp.
size(); ++i)
288 if (ms_exp[i].getFloatDataArrays().size() < 6)
290 throw Exception::IllegalArgument(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
"Error in Two2Optimization: Not enough meta data arrays present (1:area, 5:shape, 3:left width, 4:right width)");
292 bool area = ms_exp[i].getFloatDataArrays()[1].getName() ==
"maximumIntensity";
293 bool wleft = ms_exp[i].getFloatDataArrays()[3].getName() ==
"leftWidth";
294 bool wright = ms_exp[i].getFloatDataArrays()[4].getName() ==
"rightWidth";
295 bool shape = ms_exp[i].getFloatDataArrays()[5].getName() ==
"peakShape";
297 if (!area || !wleft || !wright || !shape)
299 throw Exception::IllegalArgument(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
"Error in Two2Optimization: One or several meta data arrays missing (1:intensity, 5:shape, 3:left width, 4:right width)");
312 std::vector<double> iso_last_scan;
313 std::vector<double> iso_curr_scan;
314 std::vector<std::multimap<double, IsotopeCluster>::iterator> clusters_last_scan;
315 std::vector<std::multimap<double, IsotopeCluster>::iterator> clusters_curr_scan;
316 std::multimap<double, IsotopeCluster>::iterator cluster_iter;
317 double current_rt = ms_exp_it->getRT(), last_rt = 0;
323 UInt current_charge = 0;
324 double mz_in_hash = 0;
327 for (
UInt curr_scan = 0; ms_exp_it + curr_scan != ms_exp_it_end; ++curr_scan)
329 Size nr_peaks_in_scan = (ms_exp_it + curr_scan)->size();
330 if (nr_peaks_in_scan == 0)
334 current_rt = (ms_exp_it + curr_scan)->getRT();
338 iso_last_scan = iso_curr_scan;
339 iso_curr_scan.clear();
340 clusters_last_scan = clusters_curr_scan;
341 clusters_curr_scan.clear();
344 std::cout <<
"Next scan with rt: " << current_rt << std::endl;
345 std::cout <<
"Next scan, rt = " << current_rt <<
" last_rt: " << last_rt << std::endl;
346 std::cout <<
"---------------------------------------------------------------------------" << std::endl;
356 for (
UInt curr_peak = 0; curr_peak < (ms_exp_it + curr_scan)->size() - 1; ++curr_peak)
360 double curr_mz = (peak_it + curr_peak)->getMZ();
361 double dist2nextpeak = (peak_it + curr_peak + 1)->getMZ() - curr_mz;
366 std::cout <<
"Isotopic pattern found ! " << std::endl;
367 std::cout <<
"We are at: " << (peak_it + curr_peak)->getMZ() <<
" " << curr_mz << std::endl;
369 if (!iso_last_scan.empty())
371 std::sort(iso_last_scan.begin(), iso_last_scan.end());
373 std::vector<double>::iterator it =
374 searchInScan_(iso_last_scan.begin(), iso_last_scan.end(), curr_mz);
376 double delta_mz = fabs(*it - curr_mz);
378 if (delta_mz > tolerance_mz)
380 mz_in_hash = curr_mz;
388 new_cluster.
scans.push_back(curr_scan);
389 cluster_iter =
iso_map_.insert(std::pair<double, IsotopeCluster>(mz_in_hash, new_cluster));
397 cluster_iter = clusters_last_scan[distance(iso_last_scan.begin(), it)];
400 if (
find(cluster_iter->second.scans.begin(), cluster_iter->second.scans.end(), curr_scan)
401 == cluster_iter->second.scans.end())
403 cluster_iter->second.scans.push_back(curr_scan);
420 mz_in_hash = curr_mz;
425 new_cluster.
scans.push_back(curr_scan);
426 cluster_iter =
iso_map_.insert(std::pair<double, IsotopeCluster>(mz_in_hash, new_cluster));
436 cluster_iter->second.peaks.insert(std::pair<UInt, UInt>(curr_scan, curr_peak));
438 iso_curr_scan.push_back(mz_in_hash);
439 clusters_curr_scan.push_back(cluster_iter);
442 cluster_iter->second.peaks.insert(std::pair<UInt, UInt>(curr_scan, curr_peak));
443 iso_curr_scan.push_back((peak_it + curr_peak)->getMZ());
444 clusters_curr_scan.push_back(cluster_iter);
447 if ((curr_peak + 1) >= nr_peaks_in_scan)
449 dist2nextpeak = (peak_it + curr_peak + 1)->getMZ() - (peak_it + curr_peak)->getMZ();
454 && curr_peak < (nr_peaks_in_scan - 1))
456 cluster_iter->second.peaks.insert(std::pair<UInt, UInt>(curr_scan, curr_peak + 1));
457 iso_curr_scan.push_back((peak_it + curr_peak + 1)->getMZ());
458 clusters_curr_scan.push_back(cluster_iter);
461 if (curr_peak >= nr_peaks_in_scan - 1)
463 dist2nextpeak = (peak_it + curr_peak + 1)->getMZ() - (peak_it + curr_peak)->getMZ();
473 if (!iso_last_scan.empty())
475 std::sort(iso_last_scan.begin(), iso_last_scan.end());
477 std::vector<double>::iterator it =
478 searchInScan_(iso_last_scan.begin(), iso_last_scan.end(), curr_mz);
480 double delta_mz = fabs(*it - curr_mz);
482 if (delta_mz > tolerance_mz)
484 mz_in_hash = curr_mz;
492 new_cluster.
scans.push_back(curr_scan);
493 cluster_iter =
iso_map_.insert(std::pair<double, IsotopeCluster>(mz_in_hash, new_cluster));
501 cluster_iter = clusters_last_scan[distance(iso_last_scan.begin(), it)];
504 if (
find(cluster_iter->second.scans.begin(), cluster_iter->second.scans.end(), curr_scan)
505 == cluster_iter->second.scans.end())
507 cluster_iter->second.scans.push_back(curr_scan);
524 mz_in_hash = curr_mz;
529 new_cluster.
scans.push_back(curr_scan);
530 cluster_iter =
iso_map_.insert(std::pair<double, IsotopeCluster>(mz_in_hash, new_cluster));
540 cluster_iter->second.peaks.insert(std::pair<UInt, UInt>(curr_scan, curr_peak));
542 iso_curr_scan.push_back(mz_in_hash);
543 clusters_curr_scan.push_back(cluster_iter);
551 last_rt = current_rt;
555 std::cout <<
iso_map_.size() <<
" isotopic clusters were found ! " << std::endl;
567 template <
typename InputSpectrumIterator>
569 InputSpectrumIterator& last,
574 for (std::multimap<double, IsotopeCluster>::iterator it =
iso_map_.begin();
579 std::cout <<
"element: " << counter << std::endl;
580 std::cout <<
"mz: " << it->first << std::endl <<
"rts: ";
582 std::cout << std::endl <<
"peaks: ";
583 IsotopeCluster::IndexSet::const_iterator iter = it->second.peaks.begin();
584 for (; iter != it->second.peaks.end(); ++iter)
585 std::cout << ms_exp[iter->first].getRT() <<
" " << (ms_exp[iter->first][iter->second]).getMZ() << std::endl;
588 std::cout << std::endl << std::endl;
614 Eigen::VectorXd x_init (nr_parameters);
617 std::map<Int, std::vector<PeakIndex> >::iterator m_peaks_it = twoD_data.
matching_peaks.begin();
618 Int peak_counter = 0;
619 Int diff_peak_counter = 0;
621 for (; m_peaks_it != twoD_data.
matching_peaks.end(); ++m_peaks_it)
623 double av_mz = 0, av_lw = 0, av_rw = 0, avr_height = 0, height;
624 std::vector<PeakIndex>::iterator iter_iter = (m_peaks_it)->second.begin();
625 for (; iter_iter != m_peaks_it->second.end(); ++iter_iter)
627 height = ms_exp[(iter_iter)->spectrum].getFloatDataArrays()[1][(iter_iter)->peak];
628 avr_height += height;
629 av_mz += (iter_iter)->getPeak(ms_exp).getMZ() * height;
630 av_lw += ms_exp[(iter_iter)->spectrum].getFloatDataArrays()[3][(iter_iter)->peak] * height;
631 av_rw += ms_exp[(iter_iter)->spectrum].getFloatDataArrays()[4][(iter_iter)->peak] * height;
632 x_init(peak_counter) = height;
635 x_init(twoD_data.
total_nr_peaks + 3 * diff_peak_counter) = av_mz / avr_height;
636 x_init(twoD_data.
total_nr_peaks + 3 * diff_peak_counter + 1) = av_lw / avr_height;
637 x_init(twoD_data.
total_nr_peaks + 3 * diff_peak_counter + 2) = av_rw / avr_height;
642 std::cout <<
"----------------------------\n\nstart_value: " << std::endl;
643 for (
Size k = 0;
k < start_value->size; ++
k)
645 std::cout << x_init(
k) << std::endl;
648 Int num_positions = 0;
651 num_positions += (twoD_data.
signal2D[i + 1].second - twoD_data.
signal2D[i].second + 1);
653 std::cout << twoD_data.
signal2D[i + 1].second <<
" - " << twoD_data.
signal2D[i].second <<
" +1 " << std::endl;
658 std::cout <<
"num_positions : " << num_positions << std::endl;
661 TwoDOptFunctor functor (nr_parameters, std::max(num_positions + 1, (
Int)(nr_parameters)), &twoD_data);
662 Eigen::LevenbergMarquardt<TwoDOptFunctor> lmSolver (functor);
663 Eigen::LevenbergMarquardtSpace::Status status = lmSolver.minimize(x_init);
668 if (status <= Eigen::LevenbergMarquardtSpace::ImproperInputParameters)
670 throw Exception::UnableToFit(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
"UnableToFit-TwoDOptimization:",
"Could not fit the data: Error " +
String(status));
674 std::map<Int, std::vector<PeakIndex> >::iterator itv
679 for (
Size j = 0; j < itv->second.size(); ++j)
683 std::cout <<
"pos: " << itv->second[j].getPeak(ms_exp).getMZ() <<
"\nint: " << itv->second[j].getSpectrum(ms_exp).getFloatDataArrays()[1][itv->second[j].peak]
684 <<
"\nlw: " << itv->second[j].getSpectrum(ms_exp).getFloatDataArrays()[3][itv->second[j].peak]
685 <<
"\nrw: " << itv->second[j].getSpectrum(ms_exp).getFloatDataArrays()[4][itv->second[j].peak] <<
"\n";
689 ms_exp[itv->second[j].spectrum][itv->second[j].peak].setMZ(mz);
690 double height = x_init(peak_idx);
691 ms_exp[itv->second[j].spectrum].getFloatDataArrays()[1][itv->second[j].peak] = height;
693 ms_exp[itv->second[j].spectrum].getFloatDataArrays()[3][itv->second[j].peak] = left_width;
694 double right_width = x_init(twoD_data.
total_nr_peaks + 3 * i + 2);
696 ms_exp[itv->second[j].spectrum].getFloatDataArrays()[4][itv->second[j].peak] = right_width;
700 double x_left_endpoint = mz - 1 / left_width* sqrt(height / 1 - 1);
701 double x_right_endpoint = mz + 1 / right_width* sqrt(height / 1 - 1);
702 double area_left = -height / left_width* atan(left_width * (x_left_endpoint - mz));
703 double area_right = -height / right_width* atan(right_width * (mz - x_right_endpoint));
704 ms_exp[itv->second[j].spectrum][itv->second[j].peak].setIntensity(area_left + area_right);
708 double x_left_endpoint = mz - 1 / left_width* boost::math::acosh(sqrt(height / 0.001));
709 double x_right_endpoint = mz + 1 / right_width* boost::math::acosh(sqrt(height / 0.001));
710 double area_left = -height / left_width * (sinh(left_width * (mz - x_left_endpoint)) / cosh(left_width * (mz - x_left_endpoint)));
711 double area_right = -height / right_width * (sinh(right_width * (mz - x_right_endpoint)) / cosh(right_width * (mz - x_right_endpoint)));
712 ms_exp[itv->second[j].spectrum][itv->second[j].peak].setIntensity(area_left + area_right);
717 std::cout <<
"pos: " << itv->second[j].getPeak(ms_exp).getMZ() <<
"\nint: " << itv->second[j].
getSpectrum(ms_exp).
getFloatDataArrays()[1][itv->second[j].peak]
718 <<
"\nlw: " << itv->second[j].getSpectrum(ms_exp).getFloatDataArrays()[3][itv->second[j].peak]
719 <<
"\nrw: " << itv->second[j].getSpectrum(ms_exp).getFloatDataArrays()[4][itv->second[j].peak] <<
"\n";
733 template <
typename InputSpectrumIterator>
735 InputSpectrumIterator& last,
746 if (pv.isEmpty() || pv.toString() ==
"")
749 penalties.
pos = (float)pv;
752 if (pv.isEmpty() || pv.toString() ==
"")
755 penalties.
lWidth = (
float)pv;
758 if (pv.isEmpty() || pv.toString() ==
"")
761 penalties.
rWidth = (
float)pv;
763 std::cout << penalties.
pos <<
" "
764 << penalties.
rWidth <<
" "
765 << penalties.
lWidth << std::endl;
778 if (pv.isEmpty() || pv.toString() ==
"")
781 max_iteration = (
UInt)pv;
783 std::vector<PeakShape> peak_shapes;
787 for (std::multimap<double, IsotopeCluster>::iterator it =
iso_map_.begin();
793 std::cerr <<
"element: " << counter << std::endl;
794 std::cerr <<
"mz: " << it->first << std::endl <<
"rts: ";
795 for (
Size i = 0; i < it->second.scans.size(); ++i)
796 std::cerr << it->second.scans[i] <<
"\n";
797 std::cerr << std::endl <<
"peaks: ";
798 IsotopeCluster::IndexSet::const_iterator iter = it->second.peaks.begin();
799 for (; iter != it->second.peaks.end(); ++iter)
800 std::cerr << ms_exp[iter->first].getRT() <<
" " << (ms_exp[iter->first][iter->second]).getMZ() << std::endl;
802 std::cerr << std::endl << std::endl;
823 data.
signal.reserve(size);
827 data.
positions.push_back(ms_it->getMZ());
828 data.
signal.push_back(ms_it->getIntensity());
834 pair.first = d.
iso_map_iter->second.peaks.begin()->first + idx;
836 IsotopeCluster::IndexSet::const_iterator set_iter = lower_bound(d.
iso_map_iter->second.peaks.begin(),
843 IsotopeCluster::IndexSet::const_iterator set_iter2 = lower_bound(d.
iso_map_iter->second.peaks.begin(),
847 while (set_iter != set_iter2)
849 const Size peak_index = set_iter->second;
850 const MSSpectrum& spec = ms_exp[set_iter->first];
852 spec[peak_index].getMZ(),
855 spec[peak_index].getIntensity(),
857 peak_shapes.push_back(shape);
867 std::cout <<
"vorher\n";
869 for (
Size p = 0; p < peak_shapes.size(); ++p)
871 std::cout << peak_shapes[p].mz_position <<
"\t" << peak_shapes[p].height
872 <<
"\t" << peak_shapes[p].left_width <<
"\t" << peak_shapes[p].right_width << std::endl;
877 std::cout <<
"nachher\n";
878 for (
Size p = 0; p < peak_shapes.size(); ++p)
880 std::cout << peak_shapes[p].mz_position <<
"\t" << peak_shapes[p].height
881 <<
"\t" << peak_shapes[p].left_width <<
"\t" << peak_shapes[p].right_width << std::endl;
885 pair.first = d.
iso_map_iter->second.peaks.begin()->first + idx;
887 set_iter = lower_bound(d.
iso_map_iter->second.peaks.begin(),
891 while (p < peak_shapes.size())
894 spec[set_iter->second].setMZ(peak_shapes[p].mz_position);
906 spec[set_iter->second].setIntensity(area_left + area_right);
915 spec[set_iter->second].setIntensity(area_left + area_right);
928 template <
typename InputSpectrumIterator>
930 InputSpectrumIterator& first,
931 InputSpectrumIterator& last,
937 typedef typename InputSpectrumIterator::value_type InputExperimentType;
938 typedef typename InputExperimentType::value_type InputPeakType;
939 typedef std::multimap<double, IsotopeCluster>
MapType;
941 double rt, first_peak_mz, last_peak_mz;
947 for (
Size i = 0; i < iso_map_idx; ++i)
951 std::cout <<
"rt begin: " << exp[iso_map_iter->second.scans[0]].getRT()
952 <<
"\trt end: " << exp[iso_map_iter->second.scans[iso_map_iter->second.scans.size() - 1]].getRT()
953 <<
" \t" << iso_map_iter->second.scans.
size() <<
" scans"
958 for (
Size i = 0; i < iso_map_iter->second.scans.size(); ++i)
963 rt = exp[iso_map_iter->second.scans[i]].getRT();
969 std::cout << exp_it->getRT() <<
" vs " << iter->getRT() << std::endl;
973 pair.first = iso_map_iter->second.peaks.begin()->first + i;
975 IsotopeCluster::IndexSet::const_iterator set_iter = lower_bound(iso_map_iter->second.peaks.begin(),
976 iso_map_iter->second.peaks.end(),
980 first_peak_mz = (exp_it->begin() + set_iter->second)->getMZ() - 1;
984 IsotopeCluster::IndexSet::const_iterator set_iter2 = lower_bound(iso_map_iter->second.peaks.begin(),
985 iso_map_iter->second.peaks.end(),
988 if (i == iso_map_iter->second.scans.size() - 1)
990 set_iter2 = iso_map_iter->second.peaks.end();
993 else if (set_iter2 != iso_map_iter->second.peaks.begin())
996 last_peak_mz = (exp_it->begin() + set_iter2->second)->getMZ() + 1;
999 peak.setPosition(first_peak_mz);
1001 = lower_bound(iter->begin(), iter->end(), peak,
typename InputPeakType::PositionLess());
1002 if (raw_data_iter != iter->begin())
1006 double intensity = raw_data_iter->getIntensity();
1008 while (raw_data_iter != iter->begin() && (raw_data_iter - 1)->getIntensity() < intensity &&
1009 (raw_data_iter - 1)->getIntensity() > noise_level)
1012 intensity = raw_data_iter->getIntensity();
1016 left.first = distance(first, iter);
1017 left.second = raw_data_iter - iter->begin();
1019 std::cout <<
"left: " << iter->getRT() <<
"\t" << raw_data_iter->getMZ() << std::endl;
1022 peak.setPosition(last_peak_mz + 1);
1024 = upper_bound(iter->begin(), iter->end(), peak,
typename InputPeakType::PositionLess());
1025 if (raw_data_iter == iter->end())
1027 intensity = raw_data_iter->getIntensity();
1029 while (raw_data_iter + 1 != iter->end() && (raw_data_iter + 1)->getIntensity() < intensity)
1032 intensity = raw_data_iter->getIntensity();
1033 if ((raw_data_iter + 1 != iter->end()) && (raw_data_iter + 1)->getIntensity() > noise_level)
1036 right.first = left.first;
1037 right.second = raw_data_iter - iter->begin();
1039 std::cout <<
"right: " << iter->getRT() <<
"\t" << raw_data_iter->getMZ() << std::endl;
1046 std::cout << first_peak_mz <<
"\t" << last_peak_mz << std::endl;
PeakMap MapType
Definition: PeakPickerIterative.cpp:84
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:93
Param param_
Container for current parameters.
Definition: DefaultParamHandler.h:162
A method or algorithm argument contains illegal values.
Definition: Exception.h:656
Exception used if an error occurred while fitting a model to a given dataset.
Definition: Exception.h:684
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:80
Base::iterator iterator
Definition: MSExperiment.h:124
Iterator begin()
Definition: MSExperiment.h:157
std::vector< SpectrumType >::iterator Iterator
Mutable iterator.
Definition: MSExperiment.h:111
ConstIterator RTBegin(CoordinateType rt) const
Fast search for spectrum range begin.
MSSpectrum & getSpectrum(Size id)
returns a single spectrum
bool empty() const
Definition: MSExperiment.h:137
Iterator end()
Definition: MSExperiment.h:167
Size size() const
Definition: MSExperiment.h:127
Base::const_iterator const_iterator
Definition: MSExperiment.h:125
std::vector< SpectrumType >::const_iterator ConstIterator
Non-mutable iterator.
Definition: MSExperiment.h:113
The representation of a 1D spectrum.
Definition: MSSpectrum.h:71
const FloatDataArrays & getFloatDataArrays() const
Returns a const reference to the float meta data arrays.
void clear(bool clear_meta_data)
Clears all data and meta data.
void setRT(double rt)
Sets the absolute retention time (in seconds)
This class provides the non-linear optimization of the peak parameters.
Definition: OptimizePick.h:96
std::vector< double > positions
Positions and intensity values of the profile data.
Definition: OptimizePick.h:102
void optimize(std::vector< PeakShape > &peaks, Data &data)
Start the optimization of the peak shapes peaks. The original peak shapes will be substituted by the ...
std::vector< double > signal
Definition: OptimizePick.h:103
Definition: OptimizePick.h:100
Class to hold strings, numeric values, vectors of strings and vectors of numeric values using the stl...
Definition: ParamValue.h:53
const ParamValue & getValue(const std::string &key) const
Returns a value of a parameter.
Comparison of mz_positions.
Definition: PeakShape.h:141
Internal representation of a peak shape (used by the PeakPickerCWT)
Definition: PeakShape.h:51
Type
Peak shape type (asymmetric Lorentzian or asymmetric hyperbolic secans squared).
Definition: PeakShape.h:69
@ LORENTZ_PEAK
Definition: PeakShape.h:70
double height
Maximum intensity of the peak shape.
Definition: PeakShape.h:117
double right_width
Right width parameter.
Definition: PeakShape.h:123
double left_width
Left width parameter.
Definition: PeakShape.h:121
double mz_position
Centroid position.
Definition: PeakShape.h:119
A more convenient string class.
Definition: String.h:61
Definition: TwoDOptimization.h:183
int values() const
Definition: TwoDOptimization.h:186
int df(const Eigen::VectorXd &x, Eigen::MatrixXd &J)
const int m_inputs
Definition: TwoDOptimization.h:196
int operator()(const Eigen::VectorXd &x, Eigen::VectorXd &fvec)
const TwoDOptimization::Data * m_data
Definition: TwoDOptimization.h:197
TwoDOptFunctor(unsigned dimensions, unsigned num_data_points, const TwoDOptimization::Data *data)
Definition: TwoDOptimization.h:188
int inputs() const
Definition: TwoDOptimization.h:185
This class provides the two-dimensional optimization of the picked peak parameters.
Definition: TwoDOptimization.h:90
double getMZTolerance() const
Non-mutable access to the matching epsilon.
Definition: TwoDOptimization.h:107
std::multimap< double, IsotopeCluster >::iterator iso_map_iter
Definition: TwoDOptimization.h:172
std::vector< std::pair< SignedSize, SignedSize > > signal2D
Definition: TwoDOptimization.h:171
OptimizationFunctions::PenaltyFactorsIntensity penalties_
Penalty factors for some parameters in the optimization.
Definition: TwoDOptimization.h:226
void setPenalties(OptimizationFunctions::PenaltyFactorsIntensity &penalties)
Mutable access to the minimal number of adjacent scans.
Definition: TwoDOptimization.h:136
PeakMap::ConstIterator raw_data_first
Definition: TwoDOptimization.h:176
std::map< Int, std::vector< PeakIndex > > matching_peaks
Definition: TwoDOptimization.h:174
PeakMap picked_peaks
Definition: TwoDOptimization.h:175
OptimizationFunctions::PenaltyFactorsIntensity penalties
Definition: TwoDOptimization.h:177
void findMatchingPeaks_(std::multimap< double, IsotopeCluster >::iterator &it, PeakMap &ms_exp)
Identify matching peak in a peak cluster.
std::map< Int, std::vector< PeakIndex > > matching_peaks_
Indices of peaks in the adjacent scans matching peaks in the scan with no. ref_scan.
Definition: TwoDOptimization.h:215
TwoDOptimization()
Constructor.
bool real_2D_
Optimization considering all scans of a cluster or optimization of each scan separately.
Definition: TwoDOptimization.h:222
std::vector< double > positions
Definition: TwoDOptimization.h:178
double max_peak_distance_
upper bound for distance between two peaks belonging to the same region
Definition: TwoDOptimization.h:208
double tolerance_mz_
threshold for the difference in the peak position of two matching peaks
Definition: TwoDOptimization.h:211
UInt max_iteration_
Convergence Parameter: Maximal number of iterations.
Definition: TwoDOptimization.h:219
void optimizeRegionsScanwise_(InputSpectrumIterator &first, InputSpectrumIterator &last, PeakMap &ms_exp)
Definition: TwoDOptimization.h:734
double getMaxPeakDistance() const
Non-mutable access to the maximal peak distance in a cluster.
Definition: TwoDOptimization.h:116
UInt getMaxIterations() const
Non-mutable access to the maximal number of iterations.
Definition: TwoDOptimization.h:125
Size total_nr_peaks
Definition: TwoDOptimization.h:173
std::vector< double >::iterator searchInScan_(std::vector< double >::iterator scan_begin, std::vector< double >::iterator scan_end, double current_mz)
std::multimap< double, IsotopeCluster > iso_map_
stores the retention time of each isotopic cluster
Definition: TwoDOptimization.h:202
void setMaxPeakDistance(double max_peak_distance)
Mutable access to the maximal peak distance in a cluster.
Definition: TwoDOptimization.h:118
TwoDOptimization(const TwoDOptimization &opt)
Copy constructor.
TwoDOptimization & operator=(const TwoDOptimization &opt)
Assignment operator.
void updateMembers_() override
update members method from DefaultParamHandler to update the members
std::multimap< double, IsotopeCluster >::const_iterator curr_region_
Pointer to the current region.
Definition: TwoDOptimization.h:205
void setMZTolerance(double tolerance_mz)
Mutable access to the matching epsilon.
Definition: TwoDOptimization.h:109
const OptimizationFunctions::PenaltyFactorsIntensity & getPenalties() const
Non-mutable access to the minimal number of adjacent scans.
Definition: TwoDOptimization.h:134
void optimize(InputSpectrumIterator first, InputSpectrumIterator last, PeakMap &ms_exp, bool real2D=true)
Find two dimensional peak clusters and optimize their peak parameters.
Definition: TwoDOptimization.h:271
void setMaxIterations(UInt max_iteration)
Mutable access to the maximal number of iterations.
Definition: TwoDOptimization.h:127
void optimizeRegions_(InputSpectrumIterator &first, InputSpectrumIterator &last, PeakMap &ms_exp)
Definition: TwoDOptimization.h:568
void getRegionEndpoints_(PeakMap &exp, InputSpectrumIterator &first, InputSpectrumIterator &last, Size iso_map_idx, double noise_level, TwoDOptimization::Data &d)
Get the indices of the first and last raw data point of this region.
Definition: TwoDOptimization.h:929
~TwoDOptimization() override
Destructor.
Definition: TwoDOptimization.h:100
std::vector< double > signal
Definition: TwoDOptimization.h:179
Helper struct (contains the size of an area and a raw data container)
Definition: TwoDOptimization.h:170
int Int
Signed integer type.
Definition: Types.h:102
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
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
MSSpectrum SpectrumType
Definition: MzDataHandler.h:60
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
bool find(TFinder &finder, const Pattern< TNeedle, FuzzyAC > &me, PatternAuxData< TNeedle > &dh)
Definition: AhoCorasickAmbiguous.h:886
Int charge
charge estimate (convention: zero means "no charge estimate")
Definition: IsotopeCluster.h:61
Stores information about an isotopic cluster (i.e. potential peptide charge variants)
Definition: IsotopeCluster.h:45
std::pair< Size, Size > IndexPair
An index e.g. in an MSExperiment.
Definition: IsotopeCluster.h:47
std::vector< Size > scans
the scans of this cluster
Definition: IsotopeCluster.h:74
ChargedIndexSet peaks
peaks in this cluster
Definition: IsotopeCluster.h:71
Comparator for the retention time.
Definition: MSSpectrum.h:76
Class for the penalty factors used during the optimization.
Definition: OptimizePeakDeconvolution.h:59
double height
Definition: OptimizePeakDeconvolution.h:76
Class for the penalty factors used during the optimization.
Definition: OptimizePick.h:63
double rWidth
Penalty factor for the peak shape's right width parameter.
Definition: OptimizePick.h:84
double pos
Penalty factor for the peak shape's position.
Definition: OptimizePick.h:80
double lWidth
Penalty factor for the peak shape's left width parameter.
Definition: OptimizePick.h:82
Class for comparison of std::pair using first ONLY e.g. for use with std::sort.
Definition: ComparatorUtils.h:321