libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
pappso::FilterResampleKeepPointInPolygon Class Reference

#include <filterresample.h>

Inheritance diagram for pappso::FilterResampleKeepPointInPolygon:
pappso::FilterInterface

Public Member Functions

 FilterResampleKeepPointInPolygon ()
 FilterResampleKeepPointInPolygon (IntegrationScopeBaseSPtr integration_scope_sp, Enums::DataKind data_kind)
 FilterResampleKeepPointInPolygon (const IntegrationScopeSpecVector &integration_scope_specs)
 FilterResampleKeepPointInPolygon (const FilterResampleKeepPointInPolygon &other)
virtual ~FilterResampleKeepPointInPolygon ()
void newSelectionPolygonSpec (const IntegrationScopeSpec &integration_scope_spec)
FilterResampleKeepPointInPolygonoperator= (const FilterResampleKeepPointInPolygon &other)
Tracefilter (Trace &trace) const override
Tracefilter (Trace &trace, double dt_value, double rt_value) const
Public Member Functions inherited from pappso::FilterInterface
virtual ~FilterInterface ()

Private Attributes

IntegrationScopeSpecVector m_integrationScopeSpecs
double m_lowestMz = std::numeric_limits<double>::max()
double m_greatestMz = std::numeric_limits<double>::min()

Detailed Description

Definition at line 107 of file filterresample.h.

Constructor & Destructor Documentation

◆ FilterResampleKeepPointInPolygon() [1/4]

pappso::FilterResampleKeepPointInPolygon::FilterResampleKeepPointInPolygon ( )

Definition at line 233 of file filterresample.cpp.

234{
235}

Referenced by FilterResampleKeepPointInPolygon(), and operator=().

◆ FilterResampleKeepPointInPolygon() [2/4]

pappso::FilterResampleKeepPointInPolygon::FilterResampleKeepPointInPolygon ( IntegrationScopeBaseSPtr integration_scope_sp,
Enums::DataKind data_kind )

Definition at line 238 of file filterresample.cpp.

240{
241 m_integrationScopeSpecs.push_back(IntegrationScopeSpec(integration_scope_sp, data_kind));
242
243 QPointF point;
244 if(!m_integrationScopeSpecs.front().integrationScopeSPtr->getPoint(point))
245 qFatal("Failed to get point.");
246 m_lowestMz = point.y();
247
248 double height;
249 if(!m_integrationScopeSpecs.front().integrationScopeSPtr->getHeight(height))
250 qFatal("Failed to get height.");
251 m_greatestMz = m_lowestMz + height;
252}
IntegrationScopeSpecVector m_integrationScopeSpecs

References m_greatestMz, m_integrationScopeSpecs, and m_lowestMz.

◆ FilterResampleKeepPointInPolygon() [3/4]

pappso::FilterResampleKeepPointInPolygon::FilterResampleKeepPointInPolygon ( const IntegrationScopeSpecVector & integration_scope_specs)

Definition at line 255 of file filterresample.cpp.

257{
258 // qDebug();
259
260 m_integrationScopeSpecs.assign(integration_scope_specs.begin(), integration_scope_specs.end());
261
262 for(auto &&item : m_integrationScopeSpecs)
263 {
264 if(item.integrationScopeSPtr->isRectangle())
265 {
266 // qDebug() << "item is Rectangle.";
267
268 QPointF point;
269 if(!item.integrationScopeSPtr->getPoint(point))
270 qFatal("Failed to get point.");
271 m_lowestMz = std::min(m_lowestMz, point.y());
272
273 double height;
274 if(!item.integrationScopeSPtr->getHeight(height))
275 qFatal("Failed to get height.");
276 m_greatestMz = std::max(m_greatestMz, m_lowestMz + height);
277 }
278 else
279 {
280 if(!item.integrationScopeSPtr->isRhomboid())
281 qFatal(
282 "If integration scope is not Rectangle, then it must be "
283 "Rhomboid.");
284
285 // qDebug() << "item is Rhomboid.";
286
287 QPointF point;
288
289 // Because the mz scale is on the coordinate, we ask for
290 // bottom-most and top-most points of the rhomboid polygon.
291
292 if(!item.integrationScopeSPtr->getBottomMostPoint(point))
293 qFatal("Failed to get point.");
294 m_lowestMz = std::min(m_lowestMz, point.y());
295
296 if(!item.integrationScopeSPtr->getTopMostPoint(point))
297 qFatal("Failed to get point.");
298 m_greatestMz = std::max(m_greatestMz, point.y());
299 }
300 }
301}

References m_greatestMz, m_integrationScopeSpecs, and m_lowestMz.

◆ FilterResampleKeepPointInPolygon() [4/4]

pappso::FilterResampleKeepPointInPolygon::FilterResampleKeepPointInPolygon ( const FilterResampleKeepPointInPolygon & other)

Definition at line 304 of file filterresample.cpp.

306{
307 // qDebug();
308
309 m_integrationScopeSpecs.assign(other.m_integrationScopeSpecs.begin(),
310 other.m_integrationScopeSpecs.end());
311
312 for(auto &&item : m_integrationScopeSpecs)
313 {
314 QPointF point;
315 if(!item.integrationScopeSPtr->getPoint(point))
316 qFatal("Failed to get point.");
317 m_lowestMz = std::min(m_lowestMz, point.y());
318
319 double height;
320 if(!item.integrationScopeSPtr->getHeight(height))
321 qFatal("Failed to get height.");
322 m_greatestMz = std::max(m_greatestMz, m_lowestMz + height);
323 }
324}

References FilterResampleKeepPointInPolygon(), m_greatestMz, m_integrationScopeSpecs, and m_lowestMz.

◆ ~FilterResampleKeepPointInPolygon()

virtual pappso::FilterResampleKeepPointInPolygon::~FilterResampleKeepPointInPolygon ( )
inlinevirtual

Definition at line 121 of file filterresample.h.

121{};

Member Function Documentation

◆ filter() [1/2]

Trace & pappso::FilterResampleKeepPointInPolygon::filter ( Trace & trace) const
overridevirtual

Implements pappso::FilterInterface.

Definition at line 363 of file filterresample.cpp.

364{
365 qFatal("Programming error.");
366 return trace;
367}

◆ filter() [2/2]

Trace & pappso::FilterResampleKeepPointInPolygon::filter ( Trace & trace,
double dt_value,
double rt_value ) const

Definition at line 371 of file filterresample.cpp.

372{
373 // Each time a new integration scope spec is added, the lowest and greatest
374 // m/z values are computed. We use these values to remove from the spectrum
375 // all the points that are outside of that lowest-gratest range.
376
377 // Find the iterator to the most front of the DataPoint vector (mass
378 // spectrum).
379
380 // Note that the m_lowestMz and m_greatestMz are set during construction of
381 // this FilterResampleKeepPointInPolygon filter using the
382 // integration scope specs.
383
384 // qDebug() << "The lowest and greatest m/z values:" << m_lowestMz << "and"
385 //<< m_greatestMz;
386
387 // Start by filtering away all the data points outside of the
388 // [m_lowestMz--m_greatestMz] range.
389
390 FilterResampleKeepXRange the_filter(m_lowestMz, m_greatestMz);
391
392 trace = the_filter.filter(trace);
393
394 // Now iterate in all the data points remaining in the trace and for each
395 // point craft a "virtual" point using the dt|rt value and the m/z value of
396 // the data point (data_point.x).
397
398 auto begin_it = trace.begin();
399 auto end_it = trace.end();
400
401 // qDebug() << "Iterating in the m/z range:" << begin_it->x << "-"
402 //<< std::prev(end_it)->x;
403
404 // Start at the end of the range. The iter is outside of the requested range,
405 // in fact, as shown using iter-- below.
406 auto iter = end_it;
407
408 while(iter > begin_it)
409 {
410 // Immediately go to the last data point of the desired iteration range of
411 // the trace that we need to filter. Remember that end() is not pointing
412 // to any vector item, but past the last one.
413 iter--;
414
415 // qDebug() << "Iterating in trace data point with m/z value:" << iter->x;
416
417 // Now that we have the m/z value, we can check it, in combination with
418 // the value in the selection polygon spec (to make a point) against the
419 // various selection polygon specs in our member vector.
420
421 double checked_value;
422
423 for(auto &&spec : m_integrationScopeSpecs)
424 {
425 // qDebug() << "Iterating in selection polygon spec:" <<
426 // spec.toString();
427
428 if(spec.dataKind == Enums::DataKind::dt)
429 {
430 if(dt_value == -1)
431 qFatal("Programming error.");
432
433 checked_value = dt_value;
434
435 // qDebug() << "The data kind: dt.";
436 }
437 else if(spec.dataKind == Enums::DataKind::rt)
438 {
439 checked_value = rt_value;
440
441 // qDebug() << "The data kind: rt.";
442 }
443 else
444 qFatal("Programming error.");
445
446 // First version doing the whole computation on the basis of the
447 // selection polygon's all faces.
448 //
449 if(!spec.integrationScopeSPtr->contains(QPointF(checked_value, iter->x)))
450 iter = trace.erase(iter);
451 }
452 // End of
453 // for(auto &&spec : m_selectionPolygonSpecs)
454 }
455 // End of
456 // while(iter > begin_it)
457
458 return trace;
459}
@ dt
Drift time.
Definition types.h:252
@ rt
Retention time.
Definition types.h:251

References pappso::Enums::dt, pappso::FilterResampleKeepXRange::filter(), m_greatestMz, m_integrationScopeSpecs, m_lowestMz, and pappso::Enums::rt.

◆ newSelectionPolygonSpec()

void pappso::FilterResampleKeepPointInPolygon::newSelectionPolygonSpec ( const IntegrationScopeSpec & integration_scope_spec)

Definition at line 328 of file filterresample.cpp.

330{
331
332 m_integrationScopeSpecs.push_back(integration_scope_spec);
333
334 QPointF point;
335 if(!m_integrationScopeSpecs.back().integrationScopeSPtr->getPoint(point))
336 qFatal("Failed to get point.");
337 m_lowestMz = std::min(m_lowestMz, point.y());
338
339 double height;
340 if(!m_integrationScopeSpecs.back().integrationScopeSPtr->getHeight(height))
341 qFatal("Failed to get height.");
342 m_greatestMz = std::max(m_greatestMz, m_lowestMz + height);
343}

References m_greatestMz, m_integrationScopeSpecs, and m_lowestMz.

◆ operator=()

FilterResampleKeepPointInPolygon & pappso::FilterResampleKeepPointInPolygon::operator= ( const FilterResampleKeepPointInPolygon & other)

Definition at line 347 of file filterresample.cpp.

348{
349 if(this == &other)
350 return *this;
351
352 m_integrationScopeSpecs.assign(other.m_integrationScopeSpecs.begin(),
353 other.m_integrationScopeSpecs.end());
354
355 m_lowestMz = other.m_lowestMz;
356 m_greatestMz = other.m_greatestMz;
357
358 return *this;
359}

References FilterResampleKeepPointInPolygon(), m_greatestMz, m_integrationScopeSpecs, and m_lowestMz.

Member Data Documentation

◆ m_greatestMz

double pappso::FilterResampleKeepPointInPolygon::m_greatestMz = std::numeric_limits<double>::min()
private

◆ m_integrationScopeSpecs

IntegrationScopeSpecVector pappso::FilterResampleKeepPointInPolygon::m_integrationScopeSpecs
private

◆ m_lowestMz

double pappso::FilterResampleKeepPointInPolygon::m_lowestMz = std::numeric_limits<double>::max()
private

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