libpappsomspp
Library for mass spectrometry
pappso::TraceDetectionZivy Class Reference

#include <tracedetectionzivy.h>

Inheritance diagram for pappso::TraceDetectionZivy:
pappso::TraceDetectionInterface

Public Member Functions

 TraceDetectionZivy (unsigned int smoothing_half_window_length, unsigned int minmax_half_window_length, unsigned int maxmin_half_window_length, pappso_double detection_threshold_on_minmax, pappso_double detection_threshold_on_maxmin)
 
virtual ~TraceDetectionZivy ()
 
void setFilterMorphoMean (const FilterMorphoMean &smooth)
 
void setFilterMorphoMinMax (const FilterMorphoMinMax &m_minMax)
 
void setFilterMorphoMaxMin (const FilterMorphoMaxMin &maxMin)
 
void setDetectionThresholdOnMinmax (double detectionThresholdOnMinMax)
 
void setDetectionThresholdOnMaxmin (double detectionThresholdOnMaxMin)
 
unsigned int getSmoothingHalfEdgeWindows () const
 
unsigned int getMaxMinHalfEdgeWindows () const
 
unsigned int getMinMaxHalfEdgeWindows () const
 
pappso_double getDetectionThresholdOnMinmax () const
 
pappso_double getDetectionThresholdOnMaxmin () const
 
void detect (const Trace &xic, TraceDetectionSinkInterface &sink) const override
 

Private Attributes

FilterMorphoMean m_smooth
 
FilterMorphoMinMax m_minMax
 
FilterMorphoMaxMin m_maxMin
 
pappso_double m_detectionThresholdOnMinMax
 
pappso_double m_detectionThresholdOnMaxMin
 

Detailed Description

Definition at line 36 of file tracedetectionzivy.h.

Constructor & Destructor Documentation

◆ TraceDetectionZivy()

pappso::TraceDetectionZivy::TraceDetectionZivy ( unsigned int  smoothing_half_window_length,
unsigned int  minmax_half_window_length,
unsigned int  maxmin_half_window_length,
pappso_double  detection_threshold_on_minmax,
pappso_double  detection_threshold_on_maxmin 
)

Definition at line 32 of file tracedetectionzivy.cpp.

38  : m_smooth(smoothing_half_window_length),
39  m_minMax(minmax_half_window_length),
40  m_maxMin(maxmin_half_window_length)
41 {
42  m_detectionThresholdOnMaxMin = detection_threshold_on_maxmin;
43  m_detectionThresholdOnMinMax = detection_threshold_on_minmax;
44 }
pappso_double m_detectionThresholdOnMaxMin
pappso_double m_detectionThresholdOnMinMax

References m_detectionThresholdOnMaxMin, and m_detectionThresholdOnMinMax.

◆ ~TraceDetectionZivy()

pappso::TraceDetectionZivy::~TraceDetectionZivy ( )
virtual

Definition at line 45 of file tracedetectionzivy.cpp.

46 {
47 }

Member Function Documentation

◆ detect()

void pappso::TraceDetectionZivy::detect ( const Trace xic,
TraceDetectionSinkInterface sink 
) const
overridevirtual

Implements pappso::TraceDetectionInterface.

Definition at line 106 of file tracedetectionzivy.cpp.

108 {
109 
110  // detect peak positions on close curve : a peak is an intensity value
111  // strictly greater than the two surrounding values. In case of
112  // equality (very rare, can happen with some old old spectrometers) we
113  // take the last equal point to be the peak
114  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
115  Trace xic_minmax(xic); //"close" courbe du haut
117  {
118  m_smooth.filter(xic_minmax);
119  }
120 
121  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
122  Trace xic_maxmin(xic_minmax); //"open" courbe du bas
123 
124  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
125  try
126  {
127  m_minMax.filter(xic_minmax);
128  m_maxMin.filter(xic_maxmin);
129  }
130  catch(const ExceptionOutOfRange &e)
131  {
132  throw ExceptionNotPossible(
133  QObject::tr("The original XIC is too small to detect peaks (%1) :\n%2")
134  .arg(xic.size())
135  .arg(e.qwhat()));
136  }
137  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
138  std::vector<DataPoint>::const_iterator previous_rt = xic_minmax.begin();
139  std::vector<DataPoint>::const_iterator current_rt = (previous_rt + 1);
140  std::vector<DataPoint>::const_iterator last_rt = (xic_minmax.end() - 1);
141 
142  std::vector<DataPoint>::const_iterator current_rt_on_maxmin =
143  (xic_maxmin.begin() + 1);
144 
145  std::vector<DataPoint>::const_iterator xic_position = xic.begin();
146  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
147  while(current_rt != last_rt)
148  // for (unsigned int i = 1, count = 0; i < xic_minmax.size() - 1; )
149  {
150  // conditions to have a peak
151  if((previous_rt->y < current_rt->y) &&
152  (current_rt->y > m_detectionThresholdOnMinMax) &&
153  (current_rt_on_maxmin->y > m_detectionThresholdOnMaxMin))
154  {
155  // here we test the last condition to have a peak
156 
157  // no peak case
158  if(current_rt->y < (current_rt + 1)->y)
159  {
160  //++i;
161  previous_rt = current_rt;
162  current_rt++;
163  current_rt_on_maxmin++;
164  }
165  // there is a peak here ! case
166  else if(current_rt->y > (current_rt + 1)->y)
167  {
168  // peak.setMaxXicElement(*current_rt);
169 
170  // find left boundary
171  std::vector<DataPoint>::const_iterator it_left =
172  moveLowerYLeftDataPoint(xic_minmax, current_rt);
173  // walk back
174  it_left = moveLowerYRigthDataPoint(xic_minmax, it_left);
175  // peak.setLeftBoundary(*it_left);
176 
177  // find right boundary
178  std::vector<DataPoint>::const_iterator it_right =
179  moveLowerYRigthDataPoint(xic_minmax, current_rt);
180  // walk back
181  it_right = moveLowerYLeftDataPoint(xic_minmax, it_right);
182  // peak.setRightBoundary(*it_right);
183 
184  // integrate peak surface :
185  auto it =
186  findFirstEqualOrGreaterX(xic_position, xic.end(), it_left->x);
187  xic_position =
188  findFirstEqualOrGreaterX(it, xic.end(), it_right->x) + 1;
189  // peak.setArea(areaTrace(it, xic_position));
190 
191  // find the maximum :
192  // peak.setMaxXicElement(*maxYDataPoint(it, xic_position));
193 
194  // areaTrace()
195  TracePeak peak(it, xic_position);
196  sink.setTracePeak(peak);
197  // }
198  //++i;
199  previous_rt = current_rt;
200  current_rt++;
201  current_rt_on_maxmin++;
202  }
203  // equality case, skipping equal points
204  else
205  {
206  // while (v_minmax[i] == v_minmax[i + 1]) {
207  //++i;
208  current_rt++;
209  current_rt_on_maxmin++;
210 
211  //++count;
212  }
213  }
214  // no chance to have a peak at all, continue looping
215  else
216  {
217  //++i;
218  previous_rt = current_rt;
219  current_rt++;
220  current_rt_on_maxmin++;
221  }
222  } // end loop for peaks
223  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
224 }
Trace & filter(Trace &data_points) const override
std::size_t getMeanHalfEdgeWindows() const
Trace & filter(Trace &data_points) const override
virtual Trace & filter(Trace &data_points) const override
std::vector< DataPoint >::iterator findFirstEqualOrGreaterX(std::vector< DataPoint >::iterator begin, std::vector< DataPoint >::iterator end, const double &value)
find the first element in which X is equal or greater than the value searched important : it implies ...
Definition: trace.cpp:32
std::vector< DataPoint >::const_iterator moveLowerYLeftDataPoint(const Trace &trace, std::vector< DataPoint >::const_iterator begin)
Move left to the lower value.
Definition: trace.cpp:182
std::vector< DataPoint >::const_iterator moveLowerYRigthDataPoint(const Trace &trace, std::vector< DataPoint >::const_iterator begin)
Move right to the lower value.
Definition: trace.cpp:164

References pappso::FilterMorphoWindowBase::filter(), pappso::FilterMorphoMinMax::filter(), pappso::FilterMorphoMaxMin::filter(), pappso::findFirstEqualOrGreaterX(), pappso::FilterMorphoMean::getMeanHalfEdgeWindows(), m_detectionThresholdOnMaxMin, m_detectionThresholdOnMinMax, m_maxMin, m_minMax, m_smooth, pappso::moveLowerYLeftDataPoint(), pappso::moveLowerYRigthDataPoint(), pappso::PappsoException::qwhat(), and pappso::TraceDetectionSinkInterface::setTracePeak().

◆ getDetectionThresholdOnMaxmin()

pappso_double pappso::TraceDetectionZivy::getDetectionThresholdOnMaxmin ( ) const

Definition at line 99 of file tracedetectionzivy.cpp.

100 {
102 };

References m_detectionThresholdOnMaxMin.

◆ getDetectionThresholdOnMinmax()

pappso_double pappso::TraceDetectionZivy::getDetectionThresholdOnMinmax ( ) const

Definition at line 94 of file tracedetectionzivy.cpp.

95 {
97 };

References m_detectionThresholdOnMinMax.

◆ getMaxMinHalfEdgeWindows()

unsigned int pappso::TraceDetectionZivy::getMaxMinHalfEdgeWindows ( ) const

Definition at line 83 of file tracedetectionzivy.cpp.

84 {
86 };
std::size_t getMaxMinHalfEdgeWindows() const

References pappso::FilterMorphoMaxMin::getMaxMinHalfEdgeWindows(), and m_maxMin.

◆ getMinMaxHalfEdgeWindows()

unsigned int pappso::TraceDetectionZivy::getMinMaxHalfEdgeWindows ( ) const

Definition at line 89 of file tracedetectionzivy.cpp.

90 {
92 };
std::size_t getMinMaxHalfEdgeWindows() const

References pappso::FilterMorphoMinMax::getMinMaxHalfEdgeWindows(), and m_minMax.

◆ getSmoothingHalfEdgeWindows()

unsigned int pappso::TraceDetectionZivy::getSmoothingHalfEdgeWindows ( ) const

Definition at line 78 of file tracedetectionzivy.cpp.

79 {
81 };

References pappso::FilterMorphoMean::getMeanHalfEdgeWindows(), and m_smooth.

◆ setDetectionThresholdOnMaxmin()

void pappso::TraceDetectionZivy::setDetectionThresholdOnMaxmin ( double  detectionThresholdOnMaxMin)

Definition at line 72 of file tracedetectionzivy.cpp.

74 {
75  m_detectionThresholdOnMaxMin = detectionThresholdOnMaxMin;
76 }

References m_detectionThresholdOnMaxMin.

◆ setDetectionThresholdOnMinmax()

void pappso::TraceDetectionZivy::setDetectionThresholdOnMinmax ( double  detectionThresholdOnMinMax)

Definition at line 66 of file tracedetectionzivy.cpp.

68 {
69  m_detectionThresholdOnMinMax = detectionThresholdOnMinMax;
70 }

References m_detectionThresholdOnMinMax.

◆ setFilterMorphoMaxMin()

void pappso::TraceDetectionZivy::setFilterMorphoMaxMin ( const FilterMorphoMaxMin maxMin)

Definition at line 60 of file tracedetectionzivy.cpp.

61 {
62  m_maxMin = maxMin;
63 }

References m_maxMin.

◆ setFilterMorphoMean()

void pappso::TraceDetectionZivy::setFilterMorphoMean ( const FilterMorphoMean smooth)

Definition at line 50 of file tracedetectionzivy.cpp.

51 {
52  m_smooth = smooth;
53 }

References m_smooth.

◆ setFilterMorphoMinMax()

void pappso::TraceDetectionZivy::setFilterMorphoMinMax ( const FilterMorphoMinMax m_minMax)

Definition at line 55 of file tracedetectionzivy.cpp.

56 {
57  m_minMax = minMax;
58 }

References m_minMax.

Member Data Documentation

◆ m_detectionThresholdOnMaxMin

pappso_double pappso::TraceDetectionZivy::m_detectionThresholdOnMaxMin
private

◆ m_detectionThresholdOnMinMax

pappso_double pappso::TraceDetectionZivy::m_detectionThresholdOnMinMax
private

◆ m_maxMin

FilterMorphoMaxMin pappso::TraceDetectionZivy::m_maxMin
private

Definition at line 41 of file tracedetectionzivy.h.

Referenced by detect(), getMaxMinHalfEdgeWindows(), and setFilterMorphoMaxMin().

◆ m_minMax

FilterMorphoMinMax pappso::TraceDetectionZivy::m_minMax
private

Definition at line 40 of file tracedetectionzivy.h.

Referenced by detect(), getMinMaxHalfEdgeWindows(), and setFilterMorphoMinMax().

◆ m_smooth

FilterMorphoMean pappso::TraceDetectionZivy::m_smooth
private

Definition at line 39 of file tracedetectionzivy.h.

Referenced by detect(), getSmoothingHalfEdgeWindows(), and setFilterMorphoMean().


The documentation for this class was generated from the following files: