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, bool remove_peak_base) const override
 detect peaks on a trace More...
 

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 35 of file tracedetectionzivy.cpp.

41  : m_smooth(smoothing_half_window_length),
42  m_minMax(minmax_half_window_length),
43  m_maxMin(maxmin_half_window_length)
44 {
45  m_detectionThresholdOnMaxMin = detection_threshold_on_maxmin;
46  m_detectionThresholdOnMinMax = detection_threshold_on_minmax;
47 }
pappso_double m_detectionThresholdOnMaxMin
pappso_double m_detectionThresholdOnMinMax

References m_detectionThresholdOnMaxMin, and m_detectionThresholdOnMinMax.

◆ ~TraceDetectionZivy()

pappso::TraceDetectionZivy::~TraceDetectionZivy ( )
virtual

Definition at line 48 of file tracedetectionzivy.cpp.

49 {
50 }

Member Function Documentation

◆ detect()

void pappso::TraceDetectionZivy::detect ( const Trace trace,
TraceDetectionSinkInterface sink,
bool  remove_peak_base 
) const
overridevirtual

detect peaks on a trace

Parameters
tracethe trace to detect peaks on
sinkthe object to store peaks or stream it
remove_peak_baseif true, removes the area under the base of the peak

Implements pappso::TraceDetectionInterface.

Definition at line 109 of file tracedetectionzivy.cpp.

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

References pappso::FilterMorphoWindowBase::filter(), pappso::FilterMorphoMinMax::filter(), pappso::FilterMorphoMaxMin::filter(), pappso::findFirstEqualOrGreaterX(), pappso::FilterMorphoMaxMin::getMaxMinHalfEdgeWindows(), pappso::FilterMorphoMean::getMeanHalfEdgeWindows(), pappso::FilterMorphoMinMax::getMinMaxHalfEdgeWindows(), 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 102 of file tracedetectionzivy.cpp.

103 {
105 };

References m_detectionThresholdOnMaxMin.

◆ getDetectionThresholdOnMinmax()

pappso_double pappso::TraceDetectionZivy::getDetectionThresholdOnMinmax ( ) const

Definition at line 97 of file tracedetectionzivy.cpp.

98 {
100 };

References m_detectionThresholdOnMinMax.

◆ getMaxMinHalfEdgeWindows()

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

Definition at line 86 of file tracedetectionzivy.cpp.

87 {
89 };

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

◆ getMinMaxHalfEdgeWindows()

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

Definition at line 92 of file tracedetectionzivy.cpp.

93 {
95 };

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

◆ getSmoothingHalfEdgeWindows()

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

Definition at line 81 of file tracedetectionzivy.cpp.

82 {
84 };

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

◆ setDetectionThresholdOnMaxmin()

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

Definition at line 75 of file tracedetectionzivy.cpp.

77 {
78  m_detectionThresholdOnMaxMin = detectionThresholdOnMaxMin;
79 }

References m_detectionThresholdOnMaxMin.

◆ setDetectionThresholdOnMinmax()

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

Definition at line 69 of file tracedetectionzivy.cpp.

71 {
72  m_detectionThresholdOnMinMax = detectionThresholdOnMinMax;
73 }

References m_detectionThresholdOnMinMax.

◆ setFilterMorphoMaxMin()

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

Definition at line 63 of file tracedetectionzivy.cpp.

64 {
65  m_maxMin = maxMin;
66 }

References m_maxMin.

◆ setFilterMorphoMean()

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

Definition at line 53 of file tracedetectionzivy.cpp.

54 {
55  m_smooth = smooth;
56 }

References m_smooth.

◆ setFilterMorphoMinMax()

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

Definition at line 58 of file tracedetectionzivy.cpp.

59 {
60  m_minMax = minMax;
61 }

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 69 of file tracedetectionzivy.h.

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

◆ m_minMax

FilterMorphoMinMax pappso::TraceDetectionZivy::m_minMax
private

Definition at line 68 of file tracedetectionzivy.h.

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

◆ m_smooth

FilterMorphoMean pappso::TraceDetectionZivy::m_smooth
private

Definition at line 67 of file tracedetectionzivy.h.

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


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