Loading...
Searching...
No Matches
pappso::FilterResampleKeepPointInPolygon Class Reference

`#include <filterresample.h>`

Inheritance diagram for pappso::FilterResampleKeepPointInPolygon:

## Public Member Functions

| FilterResampleKeepPointInPolygon ()
| FilterResampleKeepPointInPolygon (const SelectionPolygon &selection_polygon, DataKind data_kind)
| FilterResampleKeepPointInPolygon (const SelectionPolygonSpecVector &selection_polygon_specs)
| FilterResampleKeepPointInPolygon (const FilterResampleKeepPointInPolygon &other)
virtual | ~FilterResampleKeepPointInPolygon ()
void | newSelectionPolygonSpec (const SelectionPolygonSpec &selection_polygon_spec)
FilterResampleKeepPointInPolygon & | operator= (const FilterResampleKeepPointInPolygon &other)
Trace & | filter (Trace &trace) const override
Trace & | filter (Trace &trace, double dt_value, double rt_value) const
virtual Trace & | filter (Trace &data_points) const=0
Public Member Functions inherited from pappso::FilterInterface
virtual | ~FilterInterface ()

## Private Attributes

std::vector< SelectionPolygonSpec > | m_selectionPolygonSpecs
double | m_lowestMz = std::numeric_limits<double>::max()
double | m_greatestMz = std::numeric_limits<double>::min()

## Detailed Description

Definition at line 105 of file filterresample.h.

## Constructor & Destructor Documentation

## FilterResampleKeepPointInPolygon() [1/4]

pappso::FilterResampleKeepPointInPolygon::FilterResampleKeepPointInPolygon | ( |  | ) |

Definition at line 244 of file filterresample.cpp.

{
}

## FilterResampleKeepPointInPolygon() [2/4]

pappso::FilterResampleKeepPointInPolygon::FilterResampleKeepPointInPolygon | ( | const SelectionPolygon & | selection_polygon,
|  | DataKind | data_kind
| ) |  |

Definition at line 249 of file filterresample.cpp.

{
// It is assumed that the selection polygon always has x:MZ and y:DT|RT
// depending on the spec data kind.
m_selectionPolygonSpecs.push_back(
SelectionPolygonSpec(selection_polygon, data_kind));
m_lowestMz =
m_selectionPolygonSpecs.front().selectionPolygon.getBottomMostPoint().y();
m_greatestMz =
m_selectionPolygonSpecs.front().selectionPolygon.getTopMostPoint().y();
}
pappso::FilterResampleKeepPointInPolygon::m_lowestMz
double m_lowestMz
Definition filterresample.h:134
pappso::FilterResampleKeepPointInPolygon::m_selectionPolygonSpecs
std::vector< SelectionPolygonSpec > m_selectionPolygonSpecs
Definition filterresample.h:133
pappso::FilterResampleKeepPointInPolygon::m_greatestMz
double m_greatestMz
Definition filterresample.h:135

References m_greatestMz, m_lowestMz, and m_selectionPolygonSpecs.

## FilterResampleKeepPointInPolygon() [3/4]

pappso::FilterResampleKeepPointInPolygon::FilterResampleKeepPointInPolygon | ( | const SelectionPolygonSpecVector & | selection_polygon_specs | ) |

Definition at line 265 of file filterresample.cpp.

{
// qDebug();
m_selectionPolygonSpecs.assign(selection_polygon_specs.begin(),
selection_polygon_specs.end());
for(auto &&item : m_selectionPolygonSpecs)
{
m_lowestMz =
std::min(m_lowestMz, item.selectionPolygon.getBottomMostPoint().y());
m_greatestMz =
std::max(m_greatestMz, item.selectionPolygon.getTopMostPoint().y());
}
}

References m_greatestMz, m_lowestMz, and m_selectionPolygonSpecs.

## FilterResampleKeepPointInPolygon() [4/4]

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

Definition at line 284 of file filterresample.cpp.

{
// qDebug();
m_selectionPolygonSpecs.assign(other.m_selectionPolygonSpecs.begin(),
other.m_selectionPolygonSpecs.end());
for(auto &&item : m_selectionPolygonSpecs)
{
m_lowestMz =
std::min(m_lowestMz, item.selectionPolygon.getBottomMostPoint().y());
m_greatestMz =
std::max(m_greatestMz, item.selectionPolygon.getTopMostPoint().y());
}
}

References m_greatestMz, m_lowestMz, and m_selectionPolygonSpecs.

## ~FilterResampleKeepPointInPolygon()

virtual pappso::FilterResampleKeepPointInPolygon::~FilterResampleKeepPointInPolygon | ( |  | ) |

inline virtual

Definition at line 119 of file filterresample.h.

{};

## Member Function Documentation

## filter() [1/3]

virtual Trace & pappso::FilterInterface::filter | ( | Trace & | data_points | ) | const

virtual

Implements pappso::FilterInterface.

## filter() [2/3]

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

override virtual

Implements pappso::FilterInterface.

Definition at line 340 of file filterresample.cpp.

{
qFatal("Programming error.");
return trace;
}

## filter() [3/3]

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

Definition at line 348 of file filterresample.cpp.

{
// Each time a new selection polygon spec is added, the lowest and greatest
// m/z values are computed. We use these values to remove from the spectrum
// all the points that are outside of that lowest-gratest range.
// Find the iterator to the most front of the DataPoint vector (mass
// spectrum).
// Note that the m_lowestMz and m_greatestMz are set during construction of
// this FilterResampleKeepPointInPolygon filter using the
// selection polygon specs.
// qDebug() << "The lowest and greatest m/z values:" << m_lowestMz << "and"
//<< m_greatestMz;
// Start by filtering away all the data points outside of the
// [m_lowestMz--m_greatestMz] range.
FilterResampleKeepXRange the_filter(m_lowestMz, m_greatestMz);
trace = the_filter.filter(trace);
// Now iterate in all the data points remaining in the trace and for each
// point craft a "virtual" point using the dt|rt value and the m/z value of
// the data point (data_point.x).
auto begin_it = trace.begin();
auto end_it = trace.end();
// qDebug() << "Iterating in the m/z range:" << begin_it->x << "-"
//<< std::prev(end_it)->x;
// Start at the end of the range. The iter is outside of the requested range,
// in fact, as shown using iter-- below.
auto iter = end_it;
while(iter > begin_it)
{
// Immediately go to the last data point of the desired iteration range of
// the trace that we need to filter. Remember that end() is not pointing
// to any vector item, but past the last one.
iter--;
// qDebug() << "Iterating in trace data point with m/z value:" << iter->x;
// Now that we have the m/z value, we can check it, in combination with
// the value in the selection polygon spec (to make a point) against the
// various selection polygon specs in our member vector.
double checked_value;
for(auto &&spec : m_selectionPolygonSpecs)
{
// qDebug() << "Iterating in selection polygon spec:" <<
// spec.toString();
if(spec.dataKind == DataKind::dt)
{
if(dt_value == -1)
qFatal("Programming error.");
checked_value = dt_value;
// qDebug() << "The data kind: dt.";
}
else if(spec.dataKind == DataKind::rt)
{
checked_value = rt_value;
// qDebug() << "The data kind: rt.";
}
else
qFatal("Programming error.");
// First version doing the whole computation on the basis of the
// selection polygon's all faces.
//
if(!spec.selectionPolygon.contains(QPointF(checked_value, iter->x)))
iter = trace.erase(iter);
#if 0
//This code does not work because depending on the orientation of the
//skewed selection polygon (left bottom to right top or left top to
//right bottom or or Or depending on the axes of the
//bi-dimensional colormap, requiring transposition or not), the
//notion of "left line" and of "right line" changes.
// Second version checking that point is right of left vertical line
// of polygon and left of right vertical line.
// double res = sideofline(XX;YY;xA;yA;xB;yB) =
// (xB-xA) * (YY-yA) - (yB-yA) * (XX-xA)
// If res == 0, the point is on the line
// If rest < 0, the point is on the right of the line
// If rest > 0, the point is on the left of the line
// Left vertical line of the polygon
// Bottom point
double xA_left =
spec.selectionPolygon.getPoint(PointSpecs::BOTTOM_LEFT_POINT).x();
double yA_left =
spec.selectionPolygon.getPoint(PointSpecs::BOTTOM_LEFT_POINT).y();
// Top point
double xB_left =
spec.selectionPolygon.getPoint(PointSpecs::TOP_LEFT_POINT).x();
double yB_left =
spec.selectionPolygon.getPoint(PointSpecs::TOP_LEFT_POINT).y();
qDebug() << "The left line goes: (" << xA_left << "," << yA_left
<< ")->(" << xB_left << "," << yB_left << ")";
if((xB_left - xA_left) * (iter->x - yA_left) -
(yB_left - yA_left) * (checked_value - xA_left) >
0)
{
// The point is left of the left line. We can remove the point
// from the mass spectrum.
qDebug() << qSetRealNumberPrecision(10)
<< "Filtered out point (left of left line):"
<< checked_value << "-" << iter->x;
iter = trace.erase(iter);
// No need to go on with the analysis, just go to the next (that
// is, previous, since we iterate backwards) data point.
continue;
}
else
{
qDebug() << qSetRealNumberPrecision(10)
<< "Kept point (right of left line):" << checked_value
<< "-" << iter->x;
}
// Right vertical line of the polygon
// Bottom point
double xA_right =
spec.selectionPolygon.getPoint(PointSpecs::BOTTOM_RIGHT_POINT).x();
double yA_right =
spec.selectionPolygon.getPoint(PointSpecs::BOTTOM_RIGHT_POINT).y();
// Top point
double xB_right =
spec.selectionPolygon.getPoint(PointSpecs::TOP_RIGHT_POINT).x();
double yB_right =
spec.selectionPolygon.getPoint(PointSpecs::TOP_RIGHT_POINT).y();
qDebug() << "The right line goes: (" << xA_right << "," << yA_right
<< ")->(" << xB_right << "," << yB_right << ")";
if((xB_right - xA_right) * (iter->x - yA_right) -
(yB_right - yA_right) * (checked_value - xA_right) <
0)
{
qDebug() << qSetRealNumberPrecision(10)
<< "Filtered out point (right of right line):"
<< checked_value << "-" << iter->x;
// The point is right of the right line. We can remove the point
// from the mass spectrum.
iter = trace.erase(iter);
// Here, continue is implicit.
// No need to go on with the analysis, just go to the next (that
// is, previous, since we iterate backwards) data point.
// continue;
}
else
{
if(iter->x >= 449 && iter->x <= 450 && checked_value > 19.5 &&
checked_value < 20)
qDebug()
<< qSetRealNumberPrecision(10)
<< "SHOULD NOT Definitively kept point (left of right line):"
<< checked_value << "-" << iter->x;
else
qDebug()
<< qSetRealNumberPrecision(10)
<< "MIGHT Definitively kept point (left of right line):"
<< checked_value << "-" << iter->x;
}
#endif
}
// End of
// for(auto &&spec : m_selectionPolygonSpecs)
}
// End of
// while(iter > begin_it)
return trace;
}
pappso::PointSpecs::BOTTOM_RIGHT_POINT
@ BOTTOM_RIGHT_POINT
pappso::PointSpecs::TOP_LEFT_POINT
@ TOP_LEFT_POINT
pappso::PointSpecs::BOTTOM_LEFT_POINT
@ BOTTOM_LEFT_POINT
pappso::PointSpecs::TOP_RIGHT_POINT
@ TOP_RIGHT_POINT
pappso::DataKind::dt
@ dt
Drift time.
pappso::DataKind::rt
@ rt
Retention time.

References pappso::BOTTOM_LEFT_POINT, pappso::BOTTOM_RIGHT_POINT, pappso::dt, pappso::FilterResampleKeepXRange::filter(), m_greatestMz, m_lowestMz, m_selectionPolygonSpecs, pappso::rt, pappso::TOP_LEFT_POINT, and pappso::TOP_RIGHT_POINT.

## newSelectionPolygonSpec()

void pappso::FilterResampleKeepPointInPolygon::newSelectionPolygonSpec | ( | const SelectionPolygonSpec & | selection_polygon_spec | ) |

Definition at line 304 of file filterresample.cpp.

{
// It is assumed that the selection polygon always has x:MZ and y:DT|RT
// depending on the spec data kind.
m_selectionPolygonSpecs.push_back(selection_polygon_spec);
m_lowestMz = std::min(
m_lowestMz,
m_selectionPolygonSpecs.back().selectionPolygon.getBottomMostPoint().y());
m_greatestMz = std::max(
m_greatestMz,
m_selectionPolygonSpecs.back().selectionPolygon.getTopMostPoint().y());
}

References m_greatestMz, m_lowestMz, and m_selectionPolygonSpecs.

## operator=()

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

Definition at line 323 of file filterresample.cpp.

{
if(this == &other)
return *this;
m_selectionPolygonSpecs.assign(other.m_selectionPolygonSpecs.begin(),
other.m_selectionPolygonSpecs.end());
m_lowestMz = other.m_lowestMz;
m_greatestMz = other.m_greatestMz;
return *this;
}

References m_greatestMz, m_lowestMz, and m_selectionPolygonSpecs.

## Member Data Documentation

## m_greatestMz

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

private

Definition at line 135 of file filterresample.h.

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

## m_lowestMz

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

private

Definition at line 134 of file filterresample.h.

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

## m_selectionPolygonSpecs

std::vector<SelectionPolygonSpec> pappso::FilterResampleKeepPointInPolygon::m_selectionPolygonSpecs

private

Definition at line 133 of file filterresample.h.

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

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

- pappsomspp/processing/filters/filterresample.h
- pappsomspp/processing/filters/filterresample.cpp