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...
 
virtual void detect (const Trace &trace, TraceDetectionSinkInterface &sink, bool remove_peak_base) const =0
 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 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 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 106 of file tracedetectionzivy.cpp.

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

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 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

◆ getMinMaxHalfEdgeWindows()

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

◆ getSmoothingHalfEdgeWindows()

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

◆ 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 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: