Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
TwoDOptimization.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2017.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Timo Sachsenberg $
32 // $Authors: $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_TRANSFORMATIONS_RAW2PEAK_TWODOPTIMIZATION_H
36 #define OPENMS_TRANSFORMATIONS_RAW2PEAK_TWODOPTIMIZATION_H
37 
38 //#define DEBUG_2D
39 #undef DEBUG_2D
40 
41 #ifdef DEBUG_2D
42 #include <iostream>
43 #include <fstream>
44 #endif
45 
46 #include <vector>
47 #include <utility>
48 #include <cmath>
49 #include <set>
50 
61 
62 #include <Eigen/Core>
63 #include <unsupported/Eigen/NonLinearOptimization>
64 
65 #ifndef OPENMS_SYSTEM_STOPWATCH_H
66 #endif
67 
68 #include <boost/math/special_functions/acosh.hpp>
71 
72 namespace OpenMS
73 {
74 
89  class OPENMS_DLLAPI TwoDOptimization :
90  public DefaultParamHandler
91  {
92 public:
93 
96 
99 
101  virtual ~TwoDOptimization(){}
102 
104  TwoDOptimization& operator=(const TwoDOptimization& opt);
105 
106 
108  inline double getMZTolerance() const {return tolerance_mz_; }
110  inline void setMZTolerance(double tolerance_mz)
111  {
112  tolerance_mz_ = tolerance_mz;
113  param_.setValue("2d:tolerance_mz", tolerance_mz);
114  }
115 
117  inline double getMaxPeakDistance() const {return max_peak_distance_; }
119  inline void setMaxPeakDistance(double max_peak_distance)
120  {
121  max_peak_distance_ = max_peak_distance;
122  param_.setValue("2d:max_peak_distance", max_peak_distance);
123  }
124 
126  inline UInt getMaxIterations() const {return max_iteration_; }
128  inline void setMaxIterations(UInt max_iteration)
129  {
130  max_iteration_ = max_iteration;
131  param_.setValue("iterations", max_iteration);
132  }
133 
135  inline const OptimizationFunctions::PenaltyFactorsIntensity& getPenalties() const {return penalties_; }
138  {
139  penalties_ = penalties;
140  param_.setValue("penalties:position", penalties.pos);
141  param_.setValue("penalties:height", penalties.height);
142  param_.setValue("penalties:left_width", penalties.lWidth);
143  param_.setValue("penalties:right_width", penalties.rWidth);
144  }
145 
162  template <typename InputSpectrumIterator>
163  void optimize(InputSpectrumIterator first,
164  InputSpectrumIterator last,
165  PeakMap& ms_exp, bool real2D = true);
166 
167 
168 protected:
170  struct Data
171  {
172  std::vector<std::pair<SignedSize, SignedSize> > signal2D;
173  std::multimap<double, IsotopeCluster>::iterator iso_map_iter;
175  std::map<Int, std::vector<PeakIndex> > matching_peaks;
179  std::vector<double> positions;
180  std::vector<double> signal;
181  };
182 
183  class OPENMS_DLLAPI TwoDOptFunctor
184  {
185  public:
186  int inputs() const { return m_inputs; }
187  int values() const { return m_values; }
188 
189  TwoDOptFunctor(unsigned dimensions, unsigned num_data_points, const TwoDOptimization::Data* data)
190  : m_inputs(dimensions), m_values(num_data_points), m_data(data) {}
191 
192  int operator()(const Eigen::VectorXd &x, Eigen::VectorXd &fvec);
193  // compute Jacobian matrix for the different parameters
194  int df(const Eigen::VectorXd &x, Eigen::MatrixXd &J);
195 
196  private:
197  const int m_inputs, m_values;
199  };
200 
201 
203  std::multimap<double, IsotopeCluster> iso_map_;
204 
206  std::multimap<double, IsotopeCluster>::const_iterator curr_region_;
207 
210 
213 
215  // std::map<Int, std::vector<PeakMap::SpectrumType::Iterator > > matching_peaks_;
216  std::map<Int, std::vector<PeakIndex> > matching_peaks_;
217 
218 
221 
223  bool real_2D_;
224 
225 
228 
229 
234  std::vector<double>::iterator searchInScan_(std::vector<double>::iterator scan_begin,
235  std::vector<double>::iterator scan_end,
236  double current_mz);
237 
239  template <typename InputSpectrumIterator>
240  void optimizeRegions_(InputSpectrumIterator& first,
241  InputSpectrumIterator& last,
242  PeakMap& ms_exp);
243 
245  template <typename InputSpectrumIterator>
246  void optimizeRegionsScanwise_(InputSpectrumIterator& first,
247  InputSpectrumIterator& last,
248  PeakMap& ms_exp);
249 
250 
252  template <typename InputSpectrumIterator>
253  void getRegionEndpoints_(PeakMap& exp,
254  InputSpectrumIterator& first,
255  InputSpectrumIterator& last,
256  Size iso_map_idx,
257  double noise_level,
259 
261  void findMatchingPeaks_(std::multimap<double, IsotopeCluster>::iterator& it,
262  PeakMap& ms_exp);
263 
265 
267  void updateMembers_();
268  };
269 
270 
271  template <typename InputSpectrumIterator>
272  void TwoDOptimization::optimize(InputSpectrumIterator first, InputSpectrumIterator last, PeakMap& ms_exp, bool real2D)
273  {
274  //#define DEBUG_2D
275  //check if the input maps have the same number of spectra
276  if ((UInt)distance(first, last) != ms_exp.size())
277  {
278  throw Exception::IllegalArgument(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Error in Two2Optimization: Raw and peak map do not have the same number of spectra");
279  }
280  //do nothing if there are no scans
281  if (ms_exp.empty())
282  {
283  return;
284  }
285  //check if required meta data arrays are present (for each scan)
286  for (Size i = 0; i < ms_exp.size(); ++i)
287  {
288  //check if enough meta data arrays are present
289  if (ms_exp[i].getFloatDataArrays().size() < 6)
290  {
291  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  }
293  bool area = ms_exp[i].getFloatDataArrays()[1].getName() == "maximumIntensity";
294  bool wleft = ms_exp[i].getFloatDataArrays()[3].getName() == "leftWidth";
295  bool wright = ms_exp[i].getFloatDataArrays()[4].getName() == "rightWidth";
296  bool shape = ms_exp[i].getFloatDataArrays()[5].getName() == "peakShape";
297 
298  if (!area || !wleft || !wright || !shape)
299  {
300  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)");
301  }
302  }
303  real_2D_ = real2D;
304  typedef MSSpectrum SpectrumType;
305 
306  typename PeakMap::Iterator ms_exp_it = ms_exp.begin();
307  typename PeakMap::Iterator ms_exp_it_end = ms_exp.end();
308  if (ms_exp.empty())
309  {
310  return;
311  }
312  // stores the monoisotopic peaks of isotopic clusters
313  std::vector<double> iso_last_scan;
314  std::vector<double> iso_curr_scan;
315  std::vector<std::multimap<double, IsotopeCluster>::iterator> clusters_last_scan;
316  std::vector<std::multimap<double, IsotopeCluster>::iterator> clusters_curr_scan;
317  std::multimap<double, IsotopeCluster>::iterator cluster_iter;
318  double current_rt = ms_exp_it->getRT(), last_rt = 0;
319 
320  // retrieve values for accepted peaks distances
321  max_peak_distance_ = param_.getValue("2d:max_peak_distance");
322  double tolerance_mz = param_.getValue("2d:tolerance_mz");
323 
324  UInt current_charge = 0; // charge state of the current isotopic cluster
325  double mz_in_hash = 0; // used as reference to the current isotopic peak
326 
327  // sweep through scans
328  for (UInt curr_scan = 0; ms_exp_it + curr_scan != ms_exp_it_end; ++curr_scan)
329  {
330  Size nr_peaks_in_scan = (ms_exp_it + curr_scan)->size();
331  if (nr_peaks_in_scan == 0)
332  continue;
333 
334  //last_rt = current_rt;
335  current_rt = (ms_exp_it + curr_scan)->getRT();
336  typename PeakMap::SpectrumType::Iterator peak_it = (ms_exp_it + curr_scan)->begin();
337 
338  // copy cluster information of least scan
339  iso_last_scan = iso_curr_scan;
340  iso_curr_scan.clear();
341  clusters_last_scan = clusters_curr_scan;
342  clusters_curr_scan.clear();
343 
344 #ifdef DEBUG_2D
345  std::cout << "Next scan with rt: " << current_rt << std::endl;
346  std::cout << "Next scan, rt = " << current_rt << " last_rt: " << last_rt << std::endl;
347  std::cout << "---------------------------------------------------------------------------" << std::endl;
348 #endif
349  MSSpectrum s;
350  s.setRT(current_rt);
351  // check if there were scans in between
352  if (last_rt == 0 || // are we in the first scan
353  ((lower_bound(first, last, s, typename SpectrumType::RTLess()) - 1)->getRT() == last_rt))
354  {
355 
356 
357  for (UInt curr_peak = 0; curr_peak < (ms_exp_it + curr_scan)->size() - 1; ++curr_peak)
358  {
359 
360  // store the m/z of the current peak
361  double curr_mz = (peak_it + curr_peak)->getMZ();
362  double dist2nextpeak = (peak_it + curr_peak + 1)->getMZ() - curr_mz;
363 
364  if (dist2nextpeak <= max_peak_distance_) // one single peak without neighbors isn't optimized
365  {
366 #ifdef DEBUG_2D
367  std::cout << "Isotopic pattern found ! " << std::endl;
368  std::cout << "We are at: " << (peak_it + curr_peak)->getMZ() << " " << curr_mz << std::endl;
369 #endif
370  if (!iso_last_scan.empty()) // Did we find any isotopic cluster in the last scan?
371  {
372  std::sort(iso_last_scan.begin(), iso_last_scan.end());
373  // there were some isotopic clusters in the last scan...
374  std::vector<double>::iterator it =
375  searchInScan_(iso_last_scan.begin(), iso_last_scan.end(), curr_mz);
376 
377  double delta_mz = fabs(*it - curr_mz);
378  //std::cout << delta_mz << " "<< tolerance_mz << std::endl;
379  if (delta_mz > tolerance_mz) // check if first peak of last cluster is close enough
380  {
381  mz_in_hash = curr_mz; // update current hash key
382 
383  // create new isotopic cluster
384 // #ifdef DEBUG_2D
385 // std::cout << "Last peak cluster too far, creating new cluster at "<<curr_mz << std::endl;
386 // #endif
387  IsotopeCluster new_cluster;
388  new_cluster.peaks.charge = current_charge;
389  new_cluster.scans.push_back(curr_scan);
390  cluster_iter = iso_map_.insert(std::pair<double, IsotopeCluster>(mz_in_hash, new_cluster));
391 
392  }
393  else
394  {
395 // //#ifdef DEBUG_2D
396 // std::cout << "Found neighbouring peak with distance (m/z) " << delta_mz << std::endl;
397 // //#endif
398  cluster_iter = clusters_last_scan[distance(iso_last_scan.begin(), it)];
399 
400  // check whether this scan is already contained
401  if (find(cluster_iter->second.scans.begin(), cluster_iter->second.scans.end(), curr_scan)
402  == cluster_iter->second.scans.end())
403  {
404  cluster_iter->second.scans.push_back(curr_scan);
405  }
406 
407 // //#ifdef DEBUG_2D
408 // std::cout << "Cluster with " << cluster_iter->second.peaks.size()
409 // << " peaks retrieved." << std::endl;
410 // //#endif
411  }
412 
413  }
414  else // last scan did not contain any isotopic cluster
415  {
416 // //#ifdef DEBUG_2D
417 // std::cout << "Last scan was empty => creating new cluster." << std::endl;
418 // std::cout << "Creating new cluster at m/z: " << curr_mz << std::endl;
419 // //#endif
420 
421  mz_in_hash = curr_mz; // update current hash key
422 
423  // create new isotopic cluster
424  IsotopeCluster new_cluster;
425  new_cluster.peaks.charge = current_charge;
426  new_cluster.scans.push_back(curr_scan);
427  cluster_iter = iso_map_.insert(std::pair<double, IsotopeCluster>(mz_in_hash, new_cluster));
428 
429  }
430 
431 // //#ifdef DEBUG_2D
432 // std::cout << "Storing found peak in current isotopic cluster" << std::endl;
433 // //#endif
434 
435 
436 
437  cluster_iter->second.peaks.insert(std::pair<UInt, UInt>(curr_scan, curr_peak));
438 
439  iso_curr_scan.push_back(mz_in_hash);
440  clusters_curr_scan.push_back(cluster_iter);
441  ++curr_peak;
442 
443  cluster_iter->second.peaks.insert(std::pair<UInt, UInt>(curr_scan, curr_peak));
444  iso_curr_scan.push_back((peak_it + curr_peak)->getMZ());
445  clusters_curr_scan.push_back(cluster_iter);
446 
447  // check distance to next peak
448  if ((curr_peak + 1) >= nr_peaks_in_scan)
449  break;
450  dist2nextpeak = (peak_it + curr_peak + 1)->getMZ() - (peak_it + curr_peak)->getMZ();
451 
452 
453  // loop until end of isotopic pattern in this scan
454  while (dist2nextpeak <= max_peak_distance_
455  && curr_peak < (nr_peaks_in_scan - 1))
456  {
457  cluster_iter->second.peaks.insert(std::pair<UInt, UInt>(curr_scan, curr_peak + 1)); // save peak in cluster
458  iso_curr_scan.push_back((peak_it + curr_peak + 1)->getMZ());
459  clusters_curr_scan.push_back(cluster_iter);
460  // std::cout << "new entered: "<<(peak_it+curr_peak+1)->getMZ()<<" im while"<<std::endl;
461  ++curr_peak;
462  if (curr_peak >= nr_peaks_in_scan - 1)
463  break;
464  dist2nextpeak = (peak_it + curr_peak + 1)->getMZ() - (peak_it + curr_peak)->getMZ(); // get distance to next peak
465 
466 
467  } // end while(...)
468 
469 
470 
471  } // end of if (dist2nextpeak <= max_peak_distance_)
472  else
473  {
474  if (!iso_last_scan.empty()) // Did we find any isotopic cluster in the last scan?
475  {
476  std::sort(iso_last_scan.begin(), iso_last_scan.end());
477  // there were some isotopic clusters in the last scan...
478  std::vector<double>::iterator it =
479  searchInScan_(iso_last_scan.begin(), iso_last_scan.end(), curr_mz);
480 
481  double delta_mz = fabs(*it - curr_mz);
482  // std::cout << delta_mz << " "<< tolerance_mz << std::endl;
483  if (delta_mz > tolerance_mz) // check if first peak of last cluster is close enough
484  {
485  mz_in_hash = curr_mz; // update current hash key
486 
487  // create new isotopic cluster
488 // //#ifdef DEBUG_2D
489 // std::cout << "Last peak cluster too far, creating new cluster at "<<curr_mz << std::endl;
490 // //#endif
491  IsotopeCluster new_cluster;
492  new_cluster.peaks.charge = current_charge;
493  new_cluster.scans.push_back(curr_scan);
494  cluster_iter = iso_map_.insert(std::pair<double, IsotopeCluster>(mz_in_hash, new_cluster));
495 
496  }
497  else
498  {
499 // //#ifdef DEBUG_2D
500 // std::cout << "Found neighbouring peak with distance (m/z) " << delta_mz << std::endl;
501 // //#endif
502  cluster_iter = clusters_last_scan[distance(iso_last_scan.begin(), it)];
503 
504  // check whether this scan is already contained
505  if (find(cluster_iter->second.scans.begin(), cluster_iter->second.scans.end(), curr_scan)
506  == cluster_iter->second.scans.end())
507  {
508  cluster_iter->second.scans.push_back(curr_scan);
509  }
510 
511 // //#ifdef DEBUG_2D
512 // std::cout << "Cluster with " << cluster_iter->second.peaks.size()
513 // << " peaks retrieved." << std::endl;
514 // //#endif
515  }
516 
517  }
518  else // last scan did not contain any isotopic cluster
519  {
520 // //#ifdef DEBUG_2D
521 // std::cout << "Last scan was empty => creating new cluster." << std::endl;
522 // std::cout << "Creating new cluster at m/z: " << curr_mz << std::endl;
523 // //#endif
524 
525  mz_in_hash = curr_mz; // update current hash key
526 
527  // create new isotopic cluster
528  IsotopeCluster new_cluster;
529  new_cluster.peaks.charge = current_charge;
530  new_cluster.scans.push_back(curr_scan);
531  cluster_iter = iso_map_.insert(std::pair<double, IsotopeCluster>(mz_in_hash, new_cluster));
532 
533  }
534 
535 // //#ifdef DEBUG_2D
536 // std::cout << "Storing found peak in current isotopic cluster" << std::endl;
537 // //#endif
538 
539 
540 
541  cluster_iter->second.peaks.insert(std::pair<UInt, UInt>(curr_scan, curr_peak));
542 
543  iso_curr_scan.push_back(mz_in_hash);
544  clusters_curr_scan.push_back(cluster_iter);
545 
546 
547  }
548 
549  current_charge = 0; // reset charge
550  } // end for (...)
551  }
552  last_rt = current_rt;
553  }
554  curr_region_ = iso_map_.begin();
555 #ifdef DEBUG_2D
556  std::cout << iso_map_.size() << " isotopic clusters were found ! " << std::endl;
557 #endif
558 
559  if (real_2D_)
560  optimizeRegions_(first, last, ms_exp);
561  else
562  optimizeRegionsScanwise_(first, last, ms_exp);
563  //#undef DEBUG_2D
564  }
565 
566 
567 
568  template <typename InputSpectrumIterator>
569  void TwoDOptimization::optimizeRegions_(InputSpectrumIterator& first,
570  InputSpectrumIterator& last,
571  PeakMap& ms_exp)
572  {
573  Int counter = 0;
574  // go through the clusters
575  for (std::multimap<double, IsotopeCluster>::iterator it = iso_map_.begin();
576  it != iso_map_.end();
577  ++it)
578  {
579 #ifdef DEBUG_2D
580  std::cout << "element: " << counter << std::endl;
581  std::cout << "mz: " << it->first << std::endl << "rts: ";
582 // for(Size i=0;i<it->second.scans.size();++i) std::cout << it->second.scans[i] << "\n";
583  std::cout << std::endl << "peaks: ";
584  IsotopeCluster::IndexSet::const_iterator iter = it->second.peaks.begin();
585  for (; iter != it->second.peaks.end(); ++iter)
586  std::cout << ms_exp[iter->first].getRT() << " " << (ms_exp[iter->first][iter->second]).getMZ() << std::endl;
587 
588 //for(Size i=0;i<it->second.peaks.size();++i) std::cout << ms_exp[it->first].getRT() << " "<<(ms_exp[it->first][it->second]).getMZ()<<std::endl;
589  std::cout << std::endl << std::endl;
590 
591 #endif
592 
593  // prepare for optimization:
594  // determine the matching peaks
595  matching_peaks_.clear();
596  findMatchingPeaks_(it, ms_exp);
597  TwoDOptimization::Data twoD_data;
598  twoD_data.penalties = penalties_;
599  twoD_data.matching_peaks = matching_peaks_;
600  // and the endpoints of each isotope pattern in the cluster
601  getRegionEndpoints_(ms_exp, first, last, counter, 400, twoD_data);
602 
603  // peaks have to be stored globally
604  twoD_data.iso_map_iter = it;
605 
606  twoD_data.picked_peaks = ms_exp;
607  twoD_data.raw_data_first = first;
608 
609  Size nr_diff_peaks = matching_peaks_.size();
610  twoD_data.total_nr_peaks = it->second.peaks.size();
611 
612  Size nr_parameters = nr_diff_peaks * 3 + twoD_data.total_nr_peaks;
613 
614  // initialize and set parameters for optimization
615  Eigen::VectorXd x_init (nr_parameters);
616  x_init.setZero();
617 
618  std::map<Int, std::vector<PeakIndex> >::iterator m_peaks_it = twoD_data.matching_peaks.begin();
619  Int peak_counter = 0;
620  Int diff_peak_counter = 0;
621  // go through the matching peaks
622  for (; m_peaks_it != twoD_data.matching_peaks.end(); ++m_peaks_it)
623  {
624  double av_mz = 0, av_lw = 0, av_rw = 0, avr_height = 0, height;
625  std::vector<PeakIndex>::iterator iter_iter = (m_peaks_it)->second.begin();
626  for (; iter_iter != m_peaks_it->second.end(); ++iter_iter)
627  {
628  height = ms_exp[(iter_iter)->spectrum].getFloatDataArrays()[1][(iter_iter)->peak]; //(iter_iter)->getPeak(ms_exp).getIntensity();
629  avr_height += height;
630  av_mz += (iter_iter)->getPeak(ms_exp).getMZ() * height;
631  av_lw += ms_exp[(iter_iter)->spectrum].getFloatDataArrays()[3][(iter_iter)->peak] * height; //left width
632  av_rw += ms_exp[(iter_iter)->spectrum].getFloatDataArrays()[4][(iter_iter)->peak] * height; //right width
633  x_init(peak_counter) = height;
634  ++peak_counter;
635  }
636  x_init(twoD_data.total_nr_peaks + 3 * diff_peak_counter) = av_mz / avr_height;
637  x_init(twoD_data.total_nr_peaks + 3 * diff_peak_counter + 1) = av_lw / avr_height;
638  x_init(twoD_data.total_nr_peaks + 3 * diff_peak_counter + 2) = av_rw / avr_height;
639  ++diff_peak_counter;
640  }
641 
642 #ifdef DEBUG_2D
643  std::cout << "----------------------------\n\nstart_value: " << std::endl;
644  for (Size k = 0; k < start_value->size; ++k)
645  {
646  std::cout << x_init(k) << std::endl;
647  }
648 #endif
649  Int num_positions = 0;
650  for (Size i = 0; i < twoD_data.signal2D.size(); i += 2)
651  {
652  num_positions += (twoD_data.signal2D[i + 1].second - twoD_data.signal2D[i].second + 1);
653 #ifdef DEBUG_2D
654  std::cout << twoD_data.signal2D[i + 1].second << " - " << twoD_data.signal2D[i].second << " +1 " << std::endl;
655 #endif
656 
657  }
658 #ifdef DEBUG_2D
659  std::cout << "num_positions : " << num_positions << std::endl;
660 #endif
661 
662  TwoDOptFunctor functor (nr_parameters, std::max(num_positions + 1, (Int)(nr_parameters)), &twoD_data);
663  Eigen::LevenbergMarquardt<TwoDOptFunctor> lmSolver (functor);
664  Eigen::LevenbergMarquardtSpace::Status status = lmSolver.minimize(x_init);
665 
666  //the states are poorly documented. after checking the source, we believe that
667  //all states except NotStarted, Running and ImproperInputParameters are good
668  //termination states.
669  if (status <= Eigen::LevenbergMarquardtSpace::ImproperInputParameters)
670  {
671  throw Exception::UnableToFit(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "UnableToFit-TwoDOptimization:", "Could not fit the data: Error " + String(status));
672  }
673 
674  Int peak_idx = 0;
675  std::map<Int, std::vector<PeakIndex> >::iterator itv
676  = twoD_data.matching_peaks.begin();
677  for (; itv != twoD_data.matching_peaks.end(); ++itv)
678  {
679  Int i = distance(twoD_data.matching_peaks.begin(), itv);
680  for (Size j = 0; j < itv->second.size(); ++j)
681  {
682 
683 #ifdef DEBUG_2D
684  std::cout << "pos: " << itv->second[j].getPeak(ms_exp).getMZ() << "\nint: " << itv->second[j].getSpectrum(ms_exp).getFloatDataArrays()[1][itv->second[j].peak] //itv->second[j].getPeak(ms_exp).getIntensity()
685  << "\nlw: " << itv->second[j].getSpectrum(ms_exp).getFloatDataArrays()[3][itv->second[j].peak]
686  << "\nrw: " << itv->second[j].getSpectrum(ms_exp).getFloatDataArrays()[4][itv->second[j].peak] << "\n";
687 
688 #endif
689  double mz = x_init(twoD_data.total_nr_peaks + 3 * i);
690  ms_exp[itv->second[j].spectrum][itv->second[j].peak].setMZ(mz);
691  double height = x_init(peak_idx);
692  ms_exp[itv->second[j].spectrum].getFloatDataArrays()[1][itv->second[j].peak] = height;
693  double left_width = x_init(twoD_data.total_nr_peaks + 3 * i + 1);
694  ms_exp[itv->second[j].spectrum].getFloatDataArrays()[3][itv->second[j].peak] = left_width;
695  double right_width = x_init(twoD_data.total_nr_peaks + 3 * i + 2);
696 
697  ms_exp[itv->second[j].spectrum].getFloatDataArrays()[4][itv->second[j].peak] = right_width;
698  // calculate area
699  if ((PeakShape::Type)(Int)ms_exp[itv->second[j].spectrum].getFloatDataArrays()[5][itv->second[j].peak] == PeakShape::LORENTZ_PEAK)
700  {
701  double x_left_endpoint = mz - 1 / left_width* sqrt(height / 1 - 1);
702  double x_right_endpoint = mz + 1 / right_width* sqrt(height / 1 - 1);
703  double area_left = -height / left_width* atan(left_width * (x_left_endpoint - mz));
704  double area_right = -height / right_width* atan(right_width * (mz - x_right_endpoint));
705  ms_exp[itv->second[j].spectrum][itv->second[j].peak].setIntensity(area_left + area_right);
706  }
707  else // it's a sech peak
708  {
709  double x_left_endpoint = mz - 1 / left_width* boost::math::acosh(sqrt(height / 0.001));
710  double x_right_endpoint = mz + 1 / right_width* boost::math::acosh(sqrt(height / 0.001));
711  double area_left = -height / left_width * (sinh(left_width * (mz - x_left_endpoint)) / cosh(left_width * (mz - x_left_endpoint)));
712  double area_right = -height / right_width * (sinh(right_width * (mz - x_right_endpoint)) / cosh(right_width * (mz - x_right_endpoint)));
713  ms_exp[itv->second[j].spectrum][itv->second[j].peak].setIntensity(area_left + area_right);
714  }
715 
716 
717 #ifdef DEBUG_2D
718  std::cout << "pos: " << itv->second[j].getPeak(ms_exp).getMZ() << "\nint: " << itv->second[j].getSpectrum(ms_exp).getFloatDataArrays()[1][itv->second[j].peak] //itv->second[j].getPeak(ms_exp).getIntensity()
719  << "\nlw: " << itv->second[j].getSpectrum(ms_exp).getFloatDataArrays()[3][itv->second[j].peak]
720  << "\nrw: " << itv->second[j].getSpectrum(ms_exp).getFloatDataArrays()[4][itv->second[j].peak] << "\n";
721 #endif
722 
723  ++peak_idx;
724 
725 
726  }
727  }
728 
729  ++counter;
730  } // end for
731  //#undef DEBUG_2D
732  }
733 
734  template <typename InputSpectrumIterator>
735  void TwoDOptimization::optimizeRegionsScanwise_(InputSpectrumIterator& first,
736  InputSpectrumIterator& last,
737  PeakMap& ms_exp)
738  {
739  Int counter = 0;
741  d.picked_peaks = ms_exp;
742  d.raw_data_first = first;
743 
744  //std::cout << "richtig hier" << std::endl;
746 
747 
748  DataValue dv = param_.getValue("penalties:position");
749  if (dv.isEmpty() || dv.toString() == "")
750  penalties.pos = 0.;
751  else
752  penalties.pos = (float)dv;
753 
754  dv = param_.getValue("penalties:left_width");
755  if (dv.isEmpty() || dv.toString() == "")
756  penalties.lWidth = 1.;
757  else
758  penalties.lWidth = (float)dv;
759 
760  dv = param_.getValue("penalties:right_width");
761  if (dv.isEmpty() || dv.toString() == "")
762  penalties.rWidth = 1.;
763  else
764  penalties.rWidth = (float)dv;
765 #ifdef DEBUG_2D
766  std::cout << penalties.pos << " "
767  << penalties.rWidth << " "
768  << penalties.lWidth << std::endl;
769 #endif
770 // PeakMap::const_iterator help = first;
771 // // std::cout << "\n\n\n\n---------------------------------------------------------------";
772 // while(help!=last)
773 // {
774 // // std::cout<<help->getRT()<<std::endl;
775 // ++help;
776 // }
777  // std::cout << "---------------------------------------------------------------\n\n\n\n";
778 
779  UInt max_iteration;
780  dv = param_.getValue("iterations");
781  if (dv.isEmpty() || dv.toString() == "")
782  max_iteration = 15;
783  else
784  max_iteration = (UInt)dv;
785 
786  std::vector<PeakShape> peak_shapes;
787 
788 
789  // go through the clusters
790  for (std::multimap<double, IsotopeCluster>::iterator it = iso_map_.begin();
791  it != iso_map_.end();
792  ++it)
793  {
794  d.iso_map_iter = it;
795 #ifdef DEBUG_2D
796  std::cerr << "element: " << counter << std::endl;
797  std::cerr << "mz: " << it->first << std::endl << "rts: ";
798  for (Size i = 0; i < it->second.scans.size(); ++i)
799  std::cerr << it->second.scans[i] << "\n";
800  std::cerr << std::endl << "peaks: ";
801  IsotopeCluster::IndexSet::const_iterator iter = it->second.peaks.begin();
802  for (; iter != it->second.peaks.end(); ++iter)
803  std::cerr << ms_exp[iter->first].getRT() << " " << (ms_exp[iter->first][iter->second]).getMZ() << std::endl;
804  //for(Size i=0;i<it->second.peaks_.size();++i) std::cout << ms_exp[it->first].getRT() << " "<<(ms_exp[it->first][it->second]).getMZ()<<std::endl;
805  std::cerr << std::endl << std::endl;
806 
807 #endif
808  // prepare for optimization:
809  // determine the matching peaks
810  // and the endpoints of each isotope pattern in the cluster
811 
812  getRegionEndpoints_(ms_exp, first, last, counter, 400, d);
813  OptimizePick::Data data;
814 
815 
816  Size idx = 0;
817  for (Size i = 0; i < d.signal2D.size() / 2; ++i)
818  {
819  data.positions.clear();
820  data.signal.clear();
821 
823  (d.raw_data_first + d.signal2D[2 * i].first)->begin() + d.signal2D[2 * i].second;
824  Int size = distance(ms_it, (d.raw_data_first + d.signal2D[2 * i].first)->begin() + d.signal2D[2 * i + 1].second);
825  data.positions.reserve(size);
826  data.signal.reserve(size);
827 
828  while (ms_it != (d.raw_data_first + d.signal2D[2 * i].first)->begin() + d.signal2D[2 * i + 1].second)
829  {
830  data.positions.push_back(ms_it->getMZ());
831  data.signal.push_back(ms_it->getIntensity());
832  ++ms_it;
833  }
834 
835 
837  pair.first = d.iso_map_iter->second.peaks.begin()->first + idx;
838 
839  IsotopeCluster::IndexSet::const_iterator set_iter = lower_bound(d.iso_map_iter->second.peaks.begin(),
840  d.iso_map_iter->second.peaks.end(),
842 
843 
844  // find the last entry with this rt-value
845  ++pair.first;
846  IsotopeCluster::IndexSet::const_iterator set_iter2 = lower_bound(d.iso_map_iter->second.peaks.begin(),
847  d.iso_map_iter->second.peaks.end(),
849 
850  while (set_iter != set_iter2)
851  {
852  const Size peak_index = set_iter->second;
853  const MSSpectrum& spec = ms_exp[set_iter->first];
854  PeakShape shape(spec.getFloatDataArrays()[1][peak_index], //intensity
855  spec[peak_index].getMZ(),
856  spec.getFloatDataArrays()[3][peak_index], //left width
857  spec.getFloatDataArrays()[4][peak_index], //right width
858  spec[peak_index].getIntensity(), //area is stored in peak intensity
859  PeakShape::Type(Int(spec.getFloatDataArrays()[5][peak_index]))); //shape
860  peak_shapes.push_back(shape);
861  ++set_iter;
862  }
863 #ifdef DEBUG_2D
864  std::cout << "rt "
865  << (d.raw_data_first + d.signal2D[2 * i].first)->getRT()
866  << "\n";
867 #endif
868  OptimizePick opt(penalties, max_iteration);
869 #ifdef DEBUG_2D
870  std::cout << "vorher\n";
871 
872  for (Size p = 0; p < peak_shapes.size(); ++p)
873  {
874  std::cout << peak_shapes[p].mz_position << "\t" << peak_shapes[p].height
875  << "\t" << peak_shapes[p].left_width << "\t" << peak_shapes[p].right_width << std::endl;
876  }
877 #endif
878  opt.optimize(peak_shapes, data);
879 #ifdef DEBUG_2D
880  std::cout << "nachher\n";
881  for (Size p = 0; p < peak_shapes.size(); ++p)
882  {
883  std::cout << peak_shapes[p].mz_position << "\t" << peak_shapes[p].height
884  << "\t" << peak_shapes[p].left_width << "\t" << peak_shapes[p].right_width << std::endl;
885  }
886 #endif
887  std::sort(peak_shapes.begin(), peak_shapes.end(), PeakShape::PositionLess());
888  pair.first = d.iso_map_iter->second.peaks.begin()->first + idx;
889 
890  set_iter = lower_bound(d.iso_map_iter->second.peaks.begin(),
891  d.iso_map_iter->second.peaks.end(),
893  Size p = 0;
894  while (p < peak_shapes.size())
895  {
896  MSSpectrum& spec = ms_exp[set_iter->first];
897  spec[set_iter->second].setMZ(peak_shapes[p].mz_position);
898  spec.getFloatDataArrays()[3][set_iter->second] = peak_shapes[p].left_width;
899  spec.getFloatDataArrays()[4][set_iter->second] = peak_shapes[p].right_width;
900  spec.getFloatDataArrays()[1][set_iter->second] = peak_shapes[p].height; // maximum intensity
901  // calculate area
902  if (peak_shapes[p].type == PeakShape::LORENTZ_PEAK)
903  {
904  PeakShape& ps = peak_shapes[p];
905  double x_left_endpoint = ps.mz_position - 1 / ps.left_width* sqrt(ps.height / 1 - 1);
906  double x_right_endpoint = ps.mz_position + 1 / ps.right_width* sqrt(ps.height / 1 - 1);
907  double area_left = -ps.height / ps.left_width* atan(ps.left_width * (x_left_endpoint - ps.mz_position));
908  double area_right = -ps.height / ps.right_width* atan(ps.right_width * (ps.mz_position - x_right_endpoint));
909  spec[set_iter->second].setIntensity(area_left + area_right); // area is stored as peak intensity
910  }
911  else //It's a Sech - Peak
912  {
913  PeakShape& ps = peak_shapes[p];
914  double x_left_endpoint = ps.mz_position - 1 / ps.left_width* boost::math::acosh(sqrt(ps.height / 0.001));
915  double x_right_endpoint = ps.mz_position + 1 / ps.right_width* boost::math::acosh(sqrt(ps.height / 0.001));
916  double area_left = ps.height / ps.left_width * (sinh(ps.left_width * (ps.mz_position - x_left_endpoint)) / cosh(ps.left_width * (ps.mz_position - x_left_endpoint)));
917  double area_right = -ps.height / ps.right_width * (sinh(ps.right_width * (ps.mz_position - x_right_endpoint)) / cosh(ps.right_width * (ps.mz_position - x_right_endpoint)));
918  spec[set_iter->second].setIntensity(area_left + area_right); // area is stored as peak intensity
919  }
920  ++set_iter;
921  ++p;
922  }
923  ++idx;
924  peak_shapes.clear();
925  }
926 
927  ++counter;
928  }
929  }
930 
931  template <typename InputSpectrumIterator>
933  InputSpectrumIterator& first,
934  InputSpectrumIterator& last,
935  Size iso_map_idx,
936  double noise_level,
938  {
939  d.signal2D.clear();
940  typedef typename InputSpectrumIterator::value_type InputExperimentType;
941  typedef typename InputExperimentType::value_type InputPeakType;
942  typedef std::multimap<double, IsotopeCluster> MapType;
943 
944  double rt, first_peak_mz, last_peak_mz;
945 
946  typename PeakMap::SpectrumType spec;
947  InputPeakType peak;
948 
949  MapType::iterator iso_map_iter = iso_map_.begin();
950  for (Size i = 0; i < iso_map_idx; ++i)
951  ++iso_map_iter;
952 
953 #ifdef DEBUG2D
954  std::cout << "rt begin: " << exp[iso_map_iter->second.scans[0]].getRT()
955  << "\trt end: " << exp[iso_map_iter->second.scans[iso_map_iter->second.scans.size() - 1]].getRT()
956  << " \t" << iso_map_iter->second.scans.size() << " scans"
957  << std::endl;
958 #endif
959 
960  // get left and right endpoint for all scans in the current cluster
961  for (Size i = 0; i < iso_map_iter->second.scans.size(); ++i)
962  {
963  typename PeakMap::iterator exp_it;
964 
965  // first the right scan through binary search
966  rt = exp[iso_map_iter->second.scans[i]].getRT();
967  spec.setRT(rt);
968  InputSpectrumIterator iter = lower_bound(first, last, spec, MSSpectrum::RTLess());
969  // if(iter->getRT() != rt) --iter;
970  exp_it = exp.RTBegin(rt);
971 #ifdef DEBUG2D
972  std::cout << exp_it->getRT() << " vs " << iter->getRT() << std::endl;
973 #endif
974  // now the right mz
976  pair.first = iso_map_iter->second.peaks.begin()->first + i;
977  // get iterator in peaks-set that points to the first peak in the current scan
978  IsotopeCluster::IndexSet::const_iterator set_iter = lower_bound(iso_map_iter->second.peaks.begin(),
979  iso_map_iter->second.peaks.end(),
981 
982  // consider a bit more of the signal to the left
983  first_peak_mz = (exp_it->begin() + set_iter->second)->getMZ() - 1;
984 
985  // find the last entry with this rt-value
986  ++pair.first;
987  IsotopeCluster::IndexSet::const_iterator set_iter2 = lower_bound(iso_map_iter->second.peaks.begin(),
988  iso_map_iter->second.peaks.end(),
990 
991  if (i == iso_map_iter->second.scans.size() - 1)
992  {
993  set_iter2 = iso_map_iter->second.peaks.end();
994  --set_iter2;
995  }
996  else if (set_iter2 != iso_map_iter->second.peaks.begin())
997  --set_iter2;
998 
999  last_peak_mz = (exp_it->begin() + set_iter2->second)->getMZ() + 1;
1000 
1001  //std::cout << rt<<": first peak mz "<<first_peak_mz << "\tlast peak mz "<<last_peak_mz <<std::endl;
1002  peak.setPosition(first_peak_mz);
1003  typename PeakMap::SpectrumType::const_iterator raw_data_iter
1004  = lower_bound(iter->begin(), iter->end(), peak, typename InputPeakType::PositionLess());
1005  if (raw_data_iter != iter->begin())
1006  {
1007  --raw_data_iter;
1008  }
1009  double intensity = raw_data_iter->getIntensity();
1010  // while the intensity is falling go to the left
1011  while (raw_data_iter != iter->begin() && (raw_data_iter - 1)->getIntensity() < intensity &&
1012  (raw_data_iter - 1)->getIntensity() > noise_level)
1013  {
1014  --raw_data_iter;
1015  intensity = raw_data_iter->getIntensity();
1016  }
1017  ++raw_data_iter;
1018  IsotopeCluster::IndexPair left, right;
1019  left.first = distance(first, iter);
1020  left.second = raw_data_iter - iter->begin();
1021 #ifdef DEBUG2D
1022  std::cout << "left: " << iter->getRT() << "\t" << raw_data_iter->getMZ() << std::endl;
1023 #endif
1024  // consider a bit more of the signal to the right
1025  peak.setPosition(last_peak_mz + 1);
1026  raw_data_iter
1027  = upper_bound(iter->begin(), iter->end(), peak, typename InputPeakType::PositionLess());
1028  if (raw_data_iter == iter->end())
1029  --raw_data_iter;
1030  intensity = raw_data_iter->getIntensity();
1031  // while the intensity is falling go to the right
1032  while (raw_data_iter + 1 != iter->end() && (raw_data_iter + 1)->getIntensity() < intensity)
1033  {
1034  ++raw_data_iter;
1035  intensity = raw_data_iter->getIntensity();
1036  if ((raw_data_iter + 1 != iter->end()) && (raw_data_iter + 1)->getIntensity() > noise_level)
1037  break;
1038  }
1039  right.first = left.first;
1040  right.second = raw_data_iter - iter->begin();
1041 #ifdef DEBUG2D
1042  std::cout << "right: " << iter->getRT() << "\t" << raw_data_iter->getMZ() << std::endl;
1043 #endif
1044  // region endpoints are stored in global vector
1045  d.signal2D.push_back(left);
1046  d.signal2D.push_back(right);
1047  }
1048 #ifdef DEBUG2D
1049  //std::cout << "fertig"<< std::endl;
1050  std::cout << first_peak_mz << "\t" << last_peak_mz << std::endl;
1051 #endif
1052  }
1053 
1054 }
1055 
1056 #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:197
const double k
ConstIterator RTBegin(CoordinateType rt) const
Fast search for spectrum range begin.
Definition: MSExperiment.h:423
double left_width
Left width parameter.
Definition: PeakShape.h:122
Definition: OptimizePick.h:100
void setMaxPeakDistance(double max_peak_distance)
Mutable access to the maximal peak distance in a cluster.
Definition: TwoDOptimization.h:119
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:216
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:116
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:932
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:110
Comparator for the retention time.
Definition: MSSpectrum.h:75
unsigned int UInt
Unsigned integer type.
Definition: Types.h:95
Helper struct (contains the size of an area and a raw data container)
Definition: TwoDOptimization.h:170
Iterator begin()
Definition: MSExperiment.h:162
Base::const_iterator const_iterator
Definition: MSExperiment.h:130
virtual ~TwoDOptimization()
Destructor.
Definition: TwoDOptimization.h:101
void optimizeRegionsScanwise_(InputSpectrumIterator &first, InputSpectrumIterator &last, PeakMap &ms_exp)
Definition: TwoDOptimization.h:735
Size size() const
Definition: MSExperiment.h:132
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
std::multimap< double, IsotopeCluster >::iterator iso_map_iter
Definition: TwoDOptimization.h:173
double lWidth
Penalty factor for the peak shape&#39;s left width parameter.
Definition: OptimizePick.h:83
int inputs() const
Definition: TwoDOptimization.h:186
int values() const
Definition: TwoDOptimization.h:187
const FloatDataArrays & getFloatDataArrays() const
Returns a const reference to the float meta data arrays.
const TwoDOptimization::Data * m_data
Definition: TwoDOptimization.h:198
Class to hold strings, numeric values, lists of strings and lists of numeric values.
Definition: DataValue.h:57
double getMZTolerance() const
Non-mutable access to the matching epsilon.
Definition: TwoDOptimization.h:108
OptimizationFunctions::PenaltyFactorsIntensity penalties
Definition: TwoDOptimization.h:178
Iterator end()
Definition: MSExperiment.h:172
Base::iterator iterator
Definition: MSExperiment.h:129
The representation of a 1D spectrum.
Definition: MSSpectrum.h:67
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:137
PeakMap::ConstIterator raw_data_first
Definition: TwoDOptimization.h:177
A method or algorithm argument contains illegal values.
Definition: Exception.h:649
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:272
ChargedIndexSet peaks
peaks in this cluster
Definition: IsotopeCluster.h:72
double max_peak_distance_
upper bound for distance between two peaks belonging to the same region
Definition: TwoDOptimization.h:209
TwoDOptFunctor(unsigned dimensions, unsigned num_data_points, const TwoDOptimization::Data *data)
Definition: TwoDOptimization.h:189
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:223
PeakMap picked_peaks
Definition: TwoDOptimization.h:176
PeakMap MapType
Definition: PeakPickerIterative.cpp:84
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:212
Size total_nr_peaks
Definition: TwoDOptimization.h:174
std::multimap< double, IsotopeCluster >::const_iterator curr_region_
Pointer to the current region.
Definition: TwoDOptimization.h:206
OptimizationFunctions::PenaltyFactorsIntensity penalties_
Penalty factors for some parameters in the optimization.
Definition: TwoDOptimization.h:227
const OptimizationFunctions::PenaltyFactorsIntensity & getPenalties() const
Non-mutable access to the minimal number of adjacent scans.
Definition: TwoDOptimization.h:135
std::vector< std::pair< SignedSize, SignedSize > > signal2D
Definition: TwoDOptimization.h:172
bool empty() const
Definition: MSExperiment.h:142
void setRT(double rt)
Sets the absolute retention time (in seconds)
double pos
Penalty factor for the peak shape&#39;s position.
Definition: OptimizePick.h:81
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:82
std::vector< SpectrumType >::const_iterator ConstIterator
Non-mutable iterator.
Definition: MSExperiment.h:118
Exception used if an error occurred while fitting a model to a given dataset.
Definition: Exception.h:677
void optimizeRegions_(InputSpectrumIterator &first, InputSpectrumIterator &last, PeakMap &ms_exp)
Definition: TwoDOptimization.h:569
std::vector< double > positions
Definition: TwoDOptimization.h:179
double rWidth
Penalty factor for the peak shape&#39;s right width parameter.
Definition: OptimizePick.h:85
std::vector< Size > scans
the scans of this cluster
Definition: IsotopeCluster.h:75
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:128
void clear(bool clear_meta_data)
Clears all data and meta data.
Definition: MSExperiment.h:929
std::vector< double > signal
Definition: TwoDOptimization.h:180
void setMaxIterations(UInt max_iteration)
Mutable access to the maximal number of iterations.
Definition: TwoDOptimization.h:128
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
double getMaxPeakDistance() const
Non-mutable access to the maximal peak distance in a cluster.
Definition: TwoDOptimization.h:117
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:203
UInt max_iteration_
Convergence Parameter: Maximal number of iterations.
Definition: TwoDOptimization.h:220
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:92
std::vector< double > signal
Definition: OptimizePick.h:104
std::map< Int, std::vector< PeakIndex > > matching_peaks
Definition: TwoDOptimization.h:175
Class for comparison of std::pair using first ONLY e.g. for use with std::sort.
Definition: ComparatorUtils.h:326
Definition: PeakShape.h:71
int Int
Signed integer type.
Definition: Types.h:103
double mz_position
Centroid position.
Definition: PeakShape.h:120
double height
Definition: OptimizePeakDeconvolution.h:77
Definition: TwoDOptimization.h:183
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:89
MSSpectrum SpectrumType
Definition: MzDataHandler.h:62
Class for the penalty factors used during the optimization.
Definition: OptimizePeakDeconvolution.h:58
UInt getMaxIterations() const
Non-mutable access to the maximal number of iterations.
Definition: TwoDOptimization.h:126

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:22:04 using doxygen 1.8.13