35 #ifndef OPENMS_TRANSFORMATIONS_RAW2PEAK_TWODOPTIMIZATION_H
36 #define OPENMS_TRANSFORMATIONS_RAW2PEAK_TWODOPTIMIZATION_H
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,
typename OutputPeakType>
162 void optimize(InputSpectrumIterator first,
163 InputSpectrumIterator last,
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,
typename OutputPeakType>
239 void optimizeRegions_(InputSpectrumIterator& first,
240 InputSpectrumIterator& last,
244 template <
typename InputSpectrumIterator,
typename OutputPeakType>
245 void optimizeRegionsScanwise_(InputSpectrumIterator& first,
246 InputSpectrumIterator& last,
251 template <
typename InputSpectrumIterator,
typename OutputPeakType>
253 InputSpectrumIterator& first,
254 InputSpectrumIterator& last,
260 void findMatchingPeaks_(std::multimap<double, IsotopeCluster>::iterator& it,
266 void updateMembers_();
270 template <
typename InputSpectrumIterator,
typename OutputPeakType>
275 if ((
UInt)distance(first, last) != ms_exp.
size())
277 throw Exception::IllegalArgument(__FILE__, __LINE__, __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__, __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__, __PRETTY_FUNCTION__,
"Error in Two2Optimization: One or several meta data arrays missing (1:intensity, 5:shape, 3:left width, 4:right width)");
303 typedef typename InputSpectrumIterator::value_type InputSpectrumType;
304 typedef typename InputSpectrumType::value_type
PeakType;
314 std::vector<double> iso_last_scan;
315 std::vector<double> iso_curr_scan;
316 std::vector<std::multimap<double, IsotopeCluster>::iterator> clusters_last_scan;
317 std::vector<std::multimap<double, IsotopeCluster>::iterator> clusters_curr_scan;
318 std::multimap<double, IsotopeCluster>::iterator cluster_iter;
319 double current_rt = ms_exp_it->getRT(), last_rt = 0;
325 UInt current_charge = 0;
326 double mz_in_hash = 0;
329 for (
UInt curr_scan = 0; ms_exp_it + curr_scan != ms_exp_it_end; ++curr_scan)
331 Size nr_peaks_in_scan = (ms_exp_it + curr_scan)->size();
332 if (nr_peaks_in_scan == 0)
336 current_rt = (ms_exp_it + curr_scan)->getRT();
340 iso_last_scan = iso_curr_scan;
341 iso_curr_scan.clear();
342 clusters_last_scan = clusters_curr_scan;
343 clusters_curr_scan.clear();
346 std::cout <<
"Next scan with rt: " << current_rt << std::endl;
347 std::cout <<
"Next scan, rt = " << current_rt <<
" last_rt: " << last_rt << std::endl;
348 std::cout <<
"---------------------------------------------------------------------------" << std::endl;
354 ((lower_bound(first, last, s,
typename SpectrumType::RTLess()) - 1)->getRT() == last_rt))
358 for (
UInt curr_peak = 0; curr_peak < (ms_exp_it + curr_scan)->size() - 1; ++curr_peak)
362 double curr_mz = (peak_it + curr_peak)->getMZ();
363 double dist2nextpeak = (peak_it + curr_peak + 1)->getMZ() - curr_mz;
368 std::cout <<
"Isotopic pattern found ! " << std::endl;
369 std::cout <<
"We are at: " << (peak_it + curr_peak)->getMZ() <<
" " << curr_mz << std::endl;
371 if (!iso_last_scan.empty())
373 std::sort(iso_last_scan.begin(), iso_last_scan.end());
375 std::vector<double>::iterator it =
376 searchInScan_(iso_last_scan.begin(), iso_last_scan.end(), curr_mz);
378 double delta_mz = fabs(*it - curr_mz);
380 if (delta_mz > tolerance_mz)
382 mz_in_hash = curr_mz;
390 new_cluster.
scans.push_back(curr_scan);
391 cluster_iter =
iso_map_.insert(std::pair<double, IsotopeCluster>(mz_in_hash, new_cluster));
399 cluster_iter = clusters_last_scan[distance(iso_last_scan.begin(), it)];
402 if (find(cluster_iter->second.scans.begin(), cluster_iter->second.scans.end(), curr_scan)
403 == cluster_iter->second.scans.end())
405 cluster_iter->second.scans.push_back(curr_scan);
422 mz_in_hash = curr_mz;
427 new_cluster.
scans.push_back(curr_scan);
428 cluster_iter =
iso_map_.insert(std::pair<double, IsotopeCluster>(mz_in_hash, new_cluster));
438 cluster_iter->second.peaks.insert(std::pair<UInt, UInt>(curr_scan, curr_peak));
440 iso_curr_scan.push_back(mz_in_hash);
441 clusters_curr_scan.push_back(cluster_iter);
444 cluster_iter->second.peaks.insert(std::pair<UInt, UInt>(curr_scan, curr_peak));
445 iso_curr_scan.push_back((peak_it + curr_peak)->getMZ());
446 clusters_curr_scan.push_back(cluster_iter);
449 if ((curr_peak + 1) >= nr_peaks_in_scan)
451 dist2nextpeak = (peak_it + curr_peak + 1)->getMZ() - (peak_it + curr_peak)->getMZ();
456 && curr_peak < (nr_peaks_in_scan - 1))
458 cluster_iter->second.peaks.insert(std::pair<UInt, UInt>(curr_scan, curr_peak + 1));
459 iso_curr_scan.push_back((peak_it + curr_peak + 1)->getMZ());
460 clusters_curr_scan.push_back(cluster_iter);
463 if (curr_peak >= nr_peaks_in_scan - 1)
465 dist2nextpeak = (peak_it + curr_peak + 1)->getMZ() - (peak_it + curr_peak)->getMZ();
475 if (!iso_last_scan.empty())
477 std::sort(iso_last_scan.begin(), iso_last_scan.end());
479 std::vector<double>::iterator it =
480 searchInScan_(iso_last_scan.begin(), iso_last_scan.end(), curr_mz);
482 double delta_mz = fabs(*it - curr_mz);
484 if (delta_mz > tolerance_mz)
486 mz_in_hash = curr_mz;
494 new_cluster.
scans.push_back(curr_scan);
495 cluster_iter =
iso_map_.insert(std::pair<double, IsotopeCluster>(mz_in_hash, new_cluster));
503 cluster_iter = clusters_last_scan[distance(iso_last_scan.begin(), it)];
506 if (find(cluster_iter->second.scans.begin(), cluster_iter->second.scans.end(), curr_scan)
507 == cluster_iter->second.scans.end())
509 cluster_iter->second.scans.push_back(curr_scan);
526 mz_in_hash = curr_mz;
531 new_cluster.
scans.push_back(curr_scan);
532 cluster_iter =
iso_map_.insert(std::pair<double, IsotopeCluster>(mz_in_hash, new_cluster));
542 cluster_iter->second.peaks.insert(std::pair<UInt, UInt>(curr_scan, curr_peak));
544 iso_curr_scan.push_back(mz_in_hash);
545 clusters_curr_scan.push_back(cluster_iter);
553 last_rt = current_rt;
557 std::cout <<
iso_map_.size() <<
" isotopic clusters were found ! " << std::endl;
569 template <
typename InputSpectrumIterator,
typename OutputPeakType>
571 InputSpectrumIterator& last,
576 for (std::multimap<double, IsotopeCluster>::iterator it =
iso_map_.begin();
581 std::cout <<
"element: " << counter << std::endl;
582 std::cout <<
"mz: " << it->first << std::endl <<
"rts: ";
584 std::cout << std::endl <<
"peaks: ";
585 IsotopeCluster::IndexSet::const_iterator iter = it->second.peaks.begin();
586 for (; iter != it->second.peaks.end(); ++iter)
587 std::cout << ms_exp[iter->first].getRT() <<
" " << (ms_exp[iter->first][iter->second]).getMZ() << std::endl;
590 std::cout << std::endl << std::endl;
616 Eigen::VectorXd x_init (nr_parameters);
619 std::map<Int, std::vector<PeakIndex> >::iterator m_peaks_it = twoD_data.
matching_peaks.begin();
620 Int peak_counter = 0;
621 Int diff_peak_counter = 0;
623 for (; m_peaks_it != twoD_data.
matching_peaks.end(); ++m_peaks_it)
625 double av_mz = 0, av_lw = 0, av_rw = 0, avr_height = 0, height;
626 std::vector<PeakIndex>::iterator iter_iter = (m_peaks_it)->second.begin();
627 for (; iter_iter != m_peaks_it->second.end(); ++iter_iter)
629 height = ms_exp[(iter_iter)->spectrum].getFloatDataArrays()[1][(iter_iter)->peak];
630 avr_height += height;
631 av_mz += (iter_iter)->getPeak(ms_exp).getMZ() * height;
632 av_lw += ms_exp[(iter_iter)->spectrum].getFloatDataArrays()[3][(iter_iter)->peak] * height;
633 av_rw += ms_exp[(iter_iter)->spectrum].getFloatDataArrays()[4][(iter_iter)->peak] * height;
634 x_init(peak_counter) = height;
637 x_init(twoD_data.
total_nr_peaks + 3 * diff_peak_counter) = av_mz / avr_height;
638 x_init(twoD_data.
total_nr_peaks + 3 * diff_peak_counter + 1) = av_lw / avr_height;
639 x_init(twoD_data.
total_nr_peaks + 3 * diff_peak_counter + 2) = av_rw / avr_height;
644 std::cout <<
"----------------------------\n\nstart_value: " << std::endl;
645 for (
Size k = 0;
k < start_value->size; ++
k)
647 std::cout << x_init(
k) << std::endl;
650 Int num_positions = 0;
653 num_positions += (twoD_data.
signal2D[i + 1].second - twoD_data.
signal2D[i].second + 1);
655 std::cout << twoD_data.
signal2D[i + 1].second <<
" - " << twoD_data.
signal2D[i].second <<
" +1 " << std::endl;
660 std::cout <<
"num_positions : " << num_positions << std::endl;
663 TwoDOptFunctor functor (nr_parameters, std::max(num_positions + 1, (
Int)(nr_parameters)), &twoD_data);
664 Eigen::LevenbergMarquardt<TwoDOptFunctor> lmSolver (functor);
665 Eigen::LevenbergMarquardtSpace::Status status = lmSolver.minimize(x_init);
670 if (status <= Eigen::LevenbergMarquardtSpace::ImproperInputParameters)
672 throw Exception::UnableToFit(__FILE__, __LINE__, __PRETTY_FUNCTION__,
"UnableToFit-TwoDOptimization:",
"Could not fit the data: Error " +
String(status));
676 std::map<Int, std::vector<PeakIndex> >::iterator itv
681 for (
Size j = 0; j < itv->second.size(); ++j)
685 std::cout <<
"pos: " << itv->second[j].getPeak(ms_exp).getMZ() <<
"\nint: " << itv->second[j].getSpectrum(ms_exp).getFloatDataArrays()[1][itv->second[j].peak]
686 <<
"\nlw: " << itv->second[j].getSpectrum(ms_exp).getFloatDataArrays()[3][itv->second[j].peak]
687 <<
"\nrw: " << itv->second[j].getSpectrum(ms_exp).getFloatDataArrays()[4][itv->second[j].peak] <<
"\n";
691 ms_exp[itv->second[j].spectrum][itv->second[j].peak].setMZ(mz);
692 double height = x_init(peak_idx);
693 ms_exp[itv->second[j].spectrum].getFloatDataArrays()[1][itv->second[j].peak] = height;
695 ms_exp[itv->second[j].spectrum].getFloatDataArrays()[3][itv->second[j].peak] = left_width;
696 double right_width = x_init(twoD_data.
total_nr_peaks + 3 * i + 2);
698 ms_exp[itv->second[j].spectrum].getFloatDataArrays()[4][itv->second[j].peak] = right_width;
702 double x_left_endpoint = mz - 1 / left_width* sqrt(height / 1 - 1);
703 double x_rigth_endpoint = mz + 1 / right_width* sqrt(height / 1 - 1);
704 double area_left = -height / left_width* atan(left_width * (x_left_endpoint - mz));
705 double area_right = -height / right_width* atan(right_width * (mz - x_rigth_endpoint));
706 ms_exp[itv->second[j].spectrum][itv->second[j].peak].setIntensity(area_left + area_right);
710 double x_left_endpoint = mz - 1 / left_width* boost::math::acosh(sqrt(height / 0.001));
711 double x_rigth_endpoint = mz + 1 / right_width* boost::math::acosh(sqrt(height / 0.001));
712 double area_left = -height / left_width * (sinh(left_width * (mz - x_left_endpoint)) / cosh(left_width * (mz - x_left_endpoint)));
713 double area_right = -height / right_width * (sinh(right_width * (mz - x_rigth_endpoint)) / cosh(right_width * (mz - x_rigth_endpoint)));
714 ms_exp[itv->second[j].spectrum][itv->second[j].peak].setIntensity(area_left + area_right);
719 std::cout <<
"pos: " << itv->second[j].getPeak(ms_exp).getMZ() <<
"\nint: " << itv->second[j].getSpectrum(ms_exp).getFloatDataArrays()[1][itv->second[j].peak]
720 <<
"\nlw: " << itv->second[j].getSpectrum(ms_exp).getFloatDataArrays()[3][itv->second[j].peak]
721 <<
"\nrw: " << itv->second[j].getSpectrum(ms_exp).getFloatDataArrays()[4][itv->second[j].peak] <<
"\n";
735 template <
typename InputSpectrumIterator,
typename OutputPeakType>
737 InputSpectrumIterator& last,
750 if (dv.isEmpty() || dv.toString() ==
"")
753 penalties.
pos = (
float)dv;
756 if (dv.isEmpty() || dv.toString() ==
"")
759 penalties.
lWidth = (
float)dv;
762 if (dv.isEmpty() || dv.toString() ==
"")
765 penalties.
rWidth = (
float)dv;
767 std::cout << penalties.
pos <<
" "
768 << penalties.
rWidth <<
" "
769 << penalties.
lWidth << std::endl;
782 if (dv.isEmpty() || dv.toString() ==
"")
785 max_iteration = (
UInt)dv;
787 std::vector<PeakShape> peak_shapes;
791 for (std::multimap<double, IsotopeCluster>::iterator it =
iso_map_.begin();
797 std::cerr <<
"element: " << counter << std::endl;
798 std::cerr <<
"mz: " << it->first << std::endl <<
"rts: ";
799 for (
Size i = 0; i < it->second.scans.size(); ++i)
800 std::cerr << it->second.scans[i] <<
"\n";
801 std::cerr << std::endl <<
"peaks: ";
802 IsotopeCluster::IndexSet::const_iterator iter = it->second.peaks.begin();
803 for (; iter != it->second.peaks.end(); ++iter)
804 std::cerr << ms_exp[iter->first].getRT() <<
" " << (ms_exp[iter->first][iter->second]).getMZ() << std::endl;
806 std::cerr << std::endl << std::endl;
827 data.
signal.reserve(size);
831 data.
positions.push_back(ms_it->getMZ());
832 data.
signal.push_back(ms_it->getIntensity());
838 pair.first = d.
iso_map_iter->second.peaks.begin()->first + idx;
840 IsotopeCluster::IndexSet::const_iterator set_iter = lower_bound(d.
iso_map_iter->second.peaks.begin(),
847 IsotopeCluster::IndexSet::const_iterator set_iter2 = lower_bound(d.
iso_map_iter->second.peaks.begin(),
851 while (set_iter != set_iter2)
853 const Size peak_index = set_iter->second;
856 spec[peak_index].getMZ(),
859 spec[peak_index].getIntensity(),
861 peak_shapes.push_back(shape);
871 std::cout <<
"vorher\n";
873 for (
Size p = 0; p < peak_shapes.size(); ++p)
875 std::cout << peak_shapes[p].mz_position <<
"\t" << peak_shapes[p].height
876 <<
"\t" << peak_shapes[p].left_width <<
"\t" << peak_shapes[p].right_width << std::endl;
881 std::cout <<
"nachher\n";
882 for (
Size p = 0; p < peak_shapes.size(); ++p)
884 std::cout << peak_shapes[p].mz_position <<
"\t" << peak_shapes[p].height
885 <<
"\t" << peak_shapes[p].left_width <<
"\t" << peak_shapes[p].right_width << std::endl;
889 pair.first = d.
iso_map_iter->second.peaks.begin()->first + idx;
891 set_iter = lower_bound(d.
iso_map_iter->second.peaks.begin(),
895 while (p < peak_shapes.size())
898 spec[set_iter->second].setMZ(peak_shapes[p].mz_position);
910 spec[set_iter->second].setIntensity(area_left + area_right);
919 spec[set_iter->second].setIntensity(area_left + area_right);
932 template <
typename InputSpectrumIterator,
typename OutputPeakType>
934 InputSpectrumIterator& first,
935 InputSpectrumIterator& last,
941 typedef typename InputSpectrumIterator::value_type InputExperimentType;
942 typedef typename InputExperimentType::value_type InputPeakType;
943 typedef std::multimap<double, IsotopeCluster>
MapType;
945 double rt, first_peak_mz, last_peak_mz;
952 for (
Size i = 0; i < iso_map_idx; ++i)
956 std::cout <<
"rt begin: " << exp[iso_map_iter->second.scans[0]].getRT()
957 <<
"\trt end: " << exp[iso_map_iter->second.scans[iso_map_iter->second.scans.size() - 1]].getRT()
958 <<
" \t" << iso_map_iter->second.scans.
size() <<
" scans"
963 for (
Size i = 0; i < iso_map_iter->second.scans.size(); ++i)
968 rt = exp[iso_map_iter->second.scans[i]].getRT();
974 std::cout << exp_it->getRT() <<
" vs " << iter->getRT() << std::endl;
978 pair.first = iso_map_iter->second.peaks.
begin()->first + i;
980 IsotopeCluster::IndexSet::const_iterator set_iter = lower_bound(iso_map_iter->second.peaks.begin(),
981 iso_map_iter->second.peaks.end(),
985 first_peak_mz = (exp_it->
begin() + set_iter->second)->getMZ() - 1;
989 IsotopeCluster::IndexSet::const_iterator set_iter2 = lower_bound(iso_map_iter->second.peaks.begin(),
990 iso_map_iter->second.peaks.end(),
993 if (i == iso_map_iter->second.scans.size() - 1)
995 set_iter2 = iso_map_iter->second.peaks.end();
998 else if (set_iter2 != iso_map_iter->second.peaks.begin())
1001 last_peak_mz = (exp_it->
begin() + set_iter2->second)->getMZ() + 1;
1004 peak.setPosition(first_peak_mz);
1006 = lower_bound(iter->begin(), iter->end(), peak,
typename InputPeakType::PositionLess());
1007 if (raw_data_iter != iter->
begin())
1011 double intensity = raw_data_iter->getIntensity();
1013 while (raw_data_iter != iter->
begin() && (raw_data_iter - 1)->getIntensity() < intensity &&
1014 (raw_data_iter - 1)->getIntensity() > noise_level)
1017 intensity = raw_data_iter->getIntensity();
1021 left.first = distance(first, iter);
1022 left.second = raw_data_iter - iter->
begin();
1024 std::cout <<
"left: " << iter->getRT() <<
"\t" << raw_data_iter->getMZ() << std::endl;
1027 peak.setPosition(last_peak_mz + 1);
1029 = upper_bound(iter->begin(), iter->end(), peak,
typename InputPeakType::PositionLess());
1030 if (raw_data_iter == iter->
end())
1032 intensity = raw_data_iter->getIntensity();
1034 while (raw_data_iter + 1 != iter->
end() && (raw_data_iter + 1)->getIntensity() < intensity)
1037 intensity = raw_data_iter->getIntensity();
1038 if ((raw_data_iter + 1 != iter->
end()) && (raw_data_iter + 1)->getIntensity() > noise_level)
1041 right.first = left.first;
1042 right.second = raw_data_iter - iter->
begin();
1044 std::cout <<
"right: " << iter->getRT() <<
"\t" << raw_data_iter->getMZ() << std::endl;
1052 std::cout << first_peak_mz <<
"\t" << last_peak_mz << std::endl;
1058 #endif //OPENMS_TRANSFORMATIONS_RAW2PEAK_TWODOPTIMIZATION_H
std::vector< double > positions
Positions and intensity values of the raw data.
Definition: OptimizePick.h:103
const int m_values
Definition: TwoDOptimization.h:196
double left_width
Left width parameter.
Definition: PeakShape.h:122
int inputs() const
Definition: TwoDOptimization.h:185
Definition: OptimizePick.h:100
void setMaxPeakDistance(double max_peak_distance)
Mutable access to the maximal peak distance in a cluster.
Definition: TwoDOptimization.h:118
A more convenient string class.
Definition: String.h:57
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
Size size() const
Definition: MSExperiment.h:117
std::pair< Size, Size > IndexPair
An index e.g. in an MSExperiment.
Definition: IsotopeCluster.h:48
std::vector< SpectrumType >::iterator Iterator
Mutable iterator.
Definition: MSExperiment.h:101
const OptimizationFunctions::PenaltyFactorsIntensity & getPenalties() const
Non-mutable access to the minimal number of adjacent scans.
Definition: TwoDOptimization.h:134
Param param_
Container for current parameters.
Definition: DefaultParamHandler.h:150
Type
Peak shape type (asymmetric Lorentzian or asymmetric hyperbolic secans squared).
Definition: PeakShape.h:69
Comparison of mz_positions.
Definition: PeakShape.h:141
void setMZTolerance(double tolerance_mz)
Mutable access to the matching epsilon.
Definition: TwoDOptimization.h:109
Comparator for the retention time.
Definition: MSSpectrum.h:92
unsigned int UInt
Unsigned integer type.
Definition: Types.h:88
double getMZTolerance() const
Non-mutable access to the matching epsilon.
Definition: TwoDOptimization.h:107
Peak2D PeakType
Definition: MassTrace.h:48
Helper struct (contains the size of an area and a raw data container)
Definition: TwoDOptimization.h:169
Iterator begin()
Definition: MSExperiment.h:147
virtual ~TwoDOptimization()
Destructor.
Definition: TwoDOptimization.h:100
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
std::multimap< double, IsotopeCluster >::iterator iso_map_iter
Definition: TwoDOptimization.h:172
ContainerType::iterator Iterator
Mutable iterator.
Definition: MSSpectrum.h:121
double lWidth
Penalty factor for the peak shape's left width parameter.
Definition: OptimizePick.h:83
const TwoDOptimization::Data * m_data
Definition: TwoDOptimization.h:197
void getRegionEndpoints_(MSExperiment< OutputPeakType > &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:933
Class to hold strings, numeric values, lists of strings and lists of numeric values.
Definition: DataValue.h:57
void optimizeRegions_(InputSpectrumIterator &first, InputSpectrumIterator &last, MSExperiment< OutputPeakType > &ms_exp)
Definition: TwoDOptimization.h:570
OptimizationFunctions::PenaltyFactorsIntensity penalties
Definition: TwoDOptimization.h:177
Iterator end()
Definition: MSExperiment.h:157
MSExperiment< Peak1D > MapType
Definition: PeakPickerIterative.cpp:87
ConstIterator RTBegin(CoordinateType rt) const
Fast search for spectrum range begin.
Definition: MSExperiment.h:374
Base::iterator iterator
Definition: MSExperiment.h:114
void findMatchingPeaks_(std::multimap< double, IsotopeCluster >::iterator &it, MSExperiment<> &ms_exp)
Identify matching peak in a peak cluster.
Internal representation of a peak shape (used by the PeakPickerCWT)
Definition: PeakShape.h:51
void setPenalties(OptimizationFunctions::PenaltyFactorsIntensity &penalties)
Mutable access to the minimal number of adjacent scans.
Definition: TwoDOptimization.h:136
A method or algorithm argument contains illegal values.
Definition: Exception.h:634
ChargedIndexSet peaks
peaks in this cluster
Definition: IsotopeCluster.h:72
const DataValue & getValue(const String &key) const
Returns a value of a parameter.
double max_peak_distance_
upper bound for distance between two peaks belonging to the same region
Definition: TwoDOptimization.h:208
TwoDOptFunctor(unsigned dimensions, unsigned num_data_points, const TwoDOptimization::Data *data)
Definition: TwoDOptimization.h:188
std::vector< double >::iterator searchInScan_(std::vector< double >::iterator scan_begin, std::vector< double >::iterator scan_end, double current_mz)
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 ...
bool real_2D_
Optimization considering all scans of a cluster or optimization of each scan separately.
Definition: TwoDOptimization.h:222
double height
Maximum intensity of the peak shape.
Definition: PeakShape.h:118
double tolerance_mz_
threshold for the difference in the peak position of two matching peaks
Definition: TwoDOptimization.h:211
Size total_nr_peaks
Definition: TwoDOptimization.h:173
std::multimap< double, IsotopeCluster >::const_iterator curr_region_
Pointer to the current region.
Definition: TwoDOptimization.h:205
OptimizationFunctions::PenaltyFactorsIntensity penalties_
Penalty factors for some parameters in the optimization.
Definition: TwoDOptimization.h:226
std::vector< std::pair< SignedSize, SignedSize > > signal2D
Definition: TwoDOptimization.h:171
void setRT(double rt)
Sets the absolute retention time (is seconds)
Definition: MSSpectrum.h:249
MSExperiment< Peak1D >::ConstIterator raw_data_first
Definition: TwoDOptimization.h:176
double pos
Penalty factor for the peak shape's position.
Definition: OptimizePick.h:81
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:69
MSExperiment picked_peaks
Definition: TwoDOptimization.h:175
Exception used if an error occurred while fitting a model to a given dataset.
Definition: Exception.h:662
std::vector< double > positions
Definition: TwoDOptimization.h:178
double rWidth
Penalty factor for the peak shape's right width parameter.
Definition: OptimizePick.h:85
std::vector< Size > scans
the scans of this cluster
Definition: IsotopeCluster.h:75
double getMaxPeakDistance() const
Non-mutable access to the maximal peak distance in a cluster.
Definition: TwoDOptimization.h:116
std::vector< double > signal
Definition: TwoDOptimization.h:179
bool empty() const
Definition: MSExperiment.h:127
void setMaxIterations(UInt max_iteration)
Mutable access to the maximal number of iterations.
Definition: TwoDOptimization.h:127
double right_width
Right width parameter.
Definition: PeakShape.h:124
Stores information about an isotopic cluster (i.e. potential peptide charge variants) ...
Definition: IsotopeCluster.h:45
Class for the penalty factors used during the optimization.
Definition: OptimizePick.h:63
Int charge
charge estimate (convention: zero means "no charge estimate")
Definition: IsotopeCluster.h:62
std::multimap< double, IsotopeCluster > iso_map_
stores the retention time of each isotopic cluster
Definition: TwoDOptimization.h:202
UInt max_iteration_
Convergence Parameter: Maximal number of iterations.
Definition: TwoDOptimization.h:219
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:92
std::vector< double > signal
Definition: OptimizePick.h:104
UInt getMaxIterations() const
Non-mutable access to the maximal number of iterations.
Definition: TwoDOptimization.h:125
std::map< Int, std::vector< PeakIndex > > matching_peaks
Definition: TwoDOptimization.h:174
Class for comparison of std::pair using first ONLY e.g. for use with std::sort.
Definition: ComparatorUtils.h:326
const FloatDataArrays & getFloatDataArrays() const
Returns a const reference to the float meta data arrays.
Definition: MSSpectrum.h:298
void optimizeRegionsScanwise_(InputSpectrumIterator &first, InputSpectrumIterator &last, MSExperiment< OutputPeakType > &ms_exp)
Definition: TwoDOptimization.h:736
Definition: PeakShape.h:71
int Int
Signed integer type.
Definition: Types.h:96
void optimize(InputSpectrumIterator first, InputSpectrumIterator last, MSExperiment< OutputPeakType > &ms_exp, bool real2D=true)
Find two dimensional peak clusters and optimize their peak parameters.
Definition: TwoDOptimization.h:271
double mz_position
Centroid position.
Definition: PeakShape.h:120
double height
Definition: OptimizePeakDeconvolution.h:77
Definition: TwoDOptimization.h:182
This class provides the non-linear optimization of the peak parameters.
Definition: OptimizePick.h:96
This class provides the two-dimensional optimization of the picked peak parameters.
Definition: TwoDOptimization.h:88
int values() const
Definition: TwoDOptimization.h:186
Class for the penalty factors used during the optimization.
Definition: OptimizePeakDeconvolution.h:58