libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
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, double detection_threshold_on_minmax, double detection_threshold_on_maxmin)
 
 TraceDetectionZivy (const TraceDetectionZivy &other)
 
virtual ~TraceDetectionZivy ()
 
void guessParametersFromMsRunReader (const MsRunReader &reader)
 
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
 
double getDetectionThresholdOnMinmax () const
 
double getDetectionThresholdOnMaxmin () const
 
void detect (const Trace &xic, TraceDetectionSinkInterface &sink, bool remove_peak_base) const override
 detect peaks on a trace
 

Private Attributes

FilterMorphoMean m_smooth
 
FilterMorphoMinMax m_minMax
 
FilterMorphoMaxMin m_maxMin
 
double m_detectionThresholdOnMinMax
 
double m_detectionThresholdOnMaxMin
 

Detailed Description

Definition at line 37 of file tracedetectionzivy.h.

Constructor & Destructor Documentation

◆ TraceDetectionZivy() [1/2]

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

Definition at line 35 of file tracedetectionzivy.cpp.

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

References m_detectionThresholdOnMaxMin, m_detectionThresholdOnMinMax, m_maxMin, m_minMax, and m_smooth.

Referenced by TraceDetectionZivy().

◆ TraceDetectionZivy() [2/2]

pappso::TraceDetectionZivy::TraceDetectionZivy ( const TraceDetectionZivy & other)

Definition at line 48 of file tracedetectionzivy.cpp.

49 : m_smooth(other.m_smooth), m_minMax(other.m_minMax), m_maxMin(other.m_maxMin)
50{
51 m_detectionThresholdOnMaxMin = other.m_detectionThresholdOnMaxMin;
52 m_detectionThresholdOnMinMax = other.m_detectionThresholdOnMinMax;
53}

References TraceDetectionZivy(), m_detectionThresholdOnMaxMin, m_detectionThresholdOnMinMax, m_maxMin, m_minMax, and m_smooth.

◆ ~TraceDetectionZivy()

pappso::TraceDetectionZivy::~TraceDetectionZivy ( )
virtual

Definition at line 54 of file tracedetectionzivy.cpp.

55{
56}

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

116{
117
118 // detect peak positions on close curve : a peak is an intensity value
119 // strictly greater than the two surrounding values. In case of
120 // equality (very rare, can happen with some old old spectrometers) we
121 // take the last equal point to be the peak
122 qDebug();
123 std::size_t size = xic.size();
124 if(size < 4)
125 {
126 qDebug() << QObject::tr("The original XIC is too small to detect peaks (%1)").arg(xic.size());
127 return;
128 }
129 if(size <= m_maxMin.getMaxMinHalfEdgeWindows())
130 return;
131 if(size <= m_minMax.getMinMaxHalfEdgeWindows())
132 return;
133
134 Trace xic_minmax(xic); //"close" courbe du haut
135 if(m_smooth.getHalfWindowSize() != 0)
136 {
137 qDebug() << "f";
138 m_smooth.filter(xic_minmax);
139 }
140
141 qDebug();
142 Trace xic_maxmin(xic_minmax); //"open" courbe du bas
143
144 qDebug();
145
146 try
147 {
148 qDebug() << "f1";
149 m_minMax.filter(xic_minmax);
150 qDebug() << "f2";
151 m_maxMin.filter(xic_maxmin);
152 }
153 catch(const ExceptionOutOfRange &e)
154 {
155 qDebug() << QObject::tr("The original XIC is too small to detect peaks (%1) :\n%2")
156 .arg(xic.size())
157 .arg(e.qwhat());
158 return;
159 }
160 qDebug() << "a";
161
162 std::vector<DataPoint>::const_iterator previous_rt = xic_minmax.begin();
163 std::vector<DataPoint>::const_iterator current_rt = (previous_rt + 1);
164 std::vector<DataPoint>::const_iterator last_rt = (xic_minmax.end() - 1);
165
166 std::vector<DataPoint>::const_iterator current_rt_on_maxmin = (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) && (current_rt->y > m_detectionThresholdOnMinMax) &&
175 (current_rt_on_maxmin->y > m_detectionThresholdOnMaxMin))
176 {
177 // here we test the last condition to have a peak
178
179 // no peak case
180 if(current_rt->y < (current_rt + 1)->y)
181 {
182 //++i;
183 previous_rt = current_rt;
184 current_rt++;
185 current_rt_on_maxmin++;
186 }
187 // there is a peak here ! case
188 else if(current_rt->y > (current_rt + 1)->y)
189 {
190 // peak.setMaxXicElement(*current_rt);
191
192 // find left boundary
193 std::vector<DataPoint>::const_iterator it_left =
194 moveLowerYLeftDataPoint(xic_minmax, current_rt);
195 // walk back
196 it_left = moveLowerYRigthDataPoint(xic_minmax, it_left);
197 // peak.setLeftBoundary(*it_left);
198
199 // find right boundary
200 std::vector<DataPoint>::const_iterator it_right =
201 moveLowerYRigthDataPoint(xic_minmax, current_rt);
202 // walk back
203 it_right = moveLowerYLeftDataPoint(xic_minmax, it_right);
204 // peak.setRightBoundary(*it_right);
205
206 // integrate peak surface :
207 auto it = findFirstEqualOrGreaterX(xic_position, xic.end(), it_left->x);
208 xic_position = 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}
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:70
std::vector< DataPoint >::const_iterator moveLowerYLeftDataPoint(const Trace &trace, std::vector< DataPoint >::const_iterator begin)
Move left to the lower value.
Definition trace.cpp:211
std::vector< DataPoint >::const_iterator moveLowerYRigthDataPoint(const Trace &trace, std::vector< DataPoint >::const_iterator begin)
Move right to the lower value.
Definition trace.cpp:194

References pappso::findFirstEqualOrGreaterX(), 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

◆ getDetectionThresholdOnMinmax()

pappso_double pappso::TraceDetectionZivy::getDetectionThresholdOnMinmax ( ) const

◆ getMaxMinHalfEdgeWindows()

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

Definition at line 90 of file tracedetectionzivy.cpp.

91{
92 return m_maxMin.getMaxMinHalfEdgeWindows();
93};

References m_maxMin.

Referenced by pappso::masschroq::QuantificationMethod::getJsonObject(), and pappso::masschroq::QuantificationMethod::getProjectParameters().

◆ getMinMaxHalfEdgeWindows()

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

Definition at line 96 of file tracedetectionzivy.cpp.

97{
98 return m_minMax.getMinMaxHalfEdgeWindows();
99};

References m_minMax.

Referenced by pappso::masschroq::QuantificationMethod::getJsonObject(), and pappso::masschroq::QuantificationMethod::getProjectParameters().

◆ getSmoothingHalfEdgeWindows()

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

Definition at line 85 of file tracedetectionzivy.cpp.

86{
87 return m_smooth.getHalfWindowSize();
88};

References m_smooth.

Referenced by pappso::masschroq::QuantificationMethod::getJsonObject(), and pappso::masschroq::QuantificationMethod::getProjectParameters().

◆ guessParametersFromMsRunReader()

void pappso::TraceDetectionZivy::guessParametersFromMsRunReader ( const MsRunReader & reader)

Definition at line 248 of file tracedetectionzivy.cpp.

249{
250 // reader.
251}

◆ setDetectionThresholdOnMaxmin()

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

Definition at line 80 of file tracedetectionzivy.cpp.

81{
82 m_detectionThresholdOnMaxMin = detectionThresholdOnMaxMin;
83}

References m_detectionThresholdOnMaxMin.

◆ setDetectionThresholdOnMinmax()

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

Definition at line 75 of file tracedetectionzivy.cpp.

76{
77 m_detectionThresholdOnMinMax = detectionThresholdOnMinMax;
78}

References m_detectionThresholdOnMinMax.

◆ setFilterMorphoMaxMin()

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

Definition at line 69 of file tracedetectionzivy.cpp.

70{
71 m_maxMin = maxMin;
72}

References m_maxMin.

◆ setFilterMorphoMean()

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

Definition at line 59 of file tracedetectionzivy.cpp.

60{
61 m_smooth = smooth;
62}

References m_smooth.

◆ setFilterMorphoMinMax()

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

Definition at line 64 of file tracedetectionzivy.cpp.

65{
66 m_minMax = minMax;
67}

References m_minMax.

Member Data Documentation

◆ m_detectionThresholdOnMaxMin

double pappso::TraceDetectionZivy::m_detectionThresholdOnMaxMin
private

◆ m_detectionThresholdOnMinMax

double pappso::TraceDetectionZivy::m_detectionThresholdOnMinMax
private

◆ m_maxMin

FilterMorphoMaxMin pappso::TraceDetectionZivy::m_maxMin
private

◆ m_minMax

FilterMorphoMinMax pappso::TraceDetectionZivy::m_minMax
private

◆ m_smooth

FilterMorphoMean pappso::TraceDetectionZivy::m_smooth
private

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