pappso::FilterMorphoAntiSpike Class Reference

anti spike filter set to zero alone values inside the window More...

`#include <filtermorpho.h>`

Inheritance diagram for pappso::FilterMorphoAntiSpike:

## Public Member Functions

| FilterMorphoAntiSpike (std::size_t half_window_size)
| FilterMorphoAntiSpike (const QString &strBuildParams)
| FilterMorphoAntiSpike (const FilterMorphoAntiSpike &other)
virtual | ~FilterMorphoAntiSpike ()
FilterMorphoAntiSpike & | operator= (const FilterMorphoAntiSpike &other)
Trace & | filter (Trace &data_points) const override
std::size_t | getHalfWindowSize () const
void | buildFilterFromString (const QString &strBuildParams) override
| build this filter using a string More...
QString | toString () const override
QString | name () const override
Public Member Functions inherited from pappso::FilterNameInterface
virtual | ~FilterNameInterface ()
Public Member Functions inherited from pappso::FilterInterface
virtual | ~FilterInterface ()

## Private Attributes

std::size_t | m_halfWindowSize = 0

## Additional Inherited Members

## Detailed Description

anti spike filter set to zero alone values inside the window

Definition at line 157 of file filtermorpho.h.

## Constructor & Destructor Documentation

## FilterMorphoAntiSpike() [1/3]

FilterMorphoAntiSpike::FilterMorphoAntiSpike | ( | std::size_t | half_window_size | ) |

Definition at line 275 of file filtermorpho.cpp.

: m_halfWindowSize(half_window_size)
{
}
pappso::FilterMorphoAntiSpike::m_halfWindowSize
std::size_t m_halfWindowSize
Definition: filtermorpho.h:160

## FilterMorphoAntiSpike() [2/3]

pappso::FilterMorphoAntiSpike::FilterMorphoAntiSpike | ( | const QString & | strBuildParams | ) |

Parameters

  strBuildParams | string to build the filter "antiSpike|2"

Definition at line 285 of file filtermorpho.cpp.

{
buildFilterFromString(strBuildParams);
}
pappso::FilterMorphoAntiSpike::buildFilterFromString
void buildFilterFromString(const QString &strBuildParams) override
build this filter using a string
Definition: filtermorpho.cpp:292

## FilterMorphoAntiSpike() [3/3]

FilterMorphoAntiSpike::FilterMorphoAntiSpike | ( | const FilterMorphoAntiSpike & | other | ) |

Definition at line 280 of file filtermorpho.cpp.

: m_halfWindowSize(other.m_halfWindowSize)
{
}

## ~FilterMorphoAntiSpike()

virtual pappso::FilterMorphoAntiSpike::~FilterMorphoAntiSpike | ( |  | ) |

inline virtual

Definition at line 171 of file filtermorpho.h.

{};

## Member Function Documentation

## buildFilterFromString()

void pappso::FilterMorphoAntiSpike::buildFilterFromString | ( | const QString & | strBuildParams | ) |

override virtual

build this filter using a string

Parameters

  strBuildParams | a string coding the filter and its parameters "filterName|param1;param2;param3"

Implements pappso::FilterNameInterface.

Definition at line 292 of file filtermorpho.cpp.

{
//"antiSpike|2"
if(strBuildParams.startsWith("antiSpike|"))
{
QStringList params = strBuildParams.split("|").back().split(";");
m_halfWindowSize = params.at(0).toUInt();
}
else
{
throw pappso::ExceptionNotRecognized(
QString("building FilterMorphoAntiSpike from string %1 is not possible")
.arg(strBuildParams));
}
}
pappso::ExceptionNotRecognized
excetion to use when an item type is not recognized
Definition: exceptionnotrecognized.h:42

## filter()

Trace & FilterMorphoAntiSpike::filter | ( | Trace & | data_points | ) | const

override virtual

Implements pappso::FilterInterface.

Definition at line 339 of file filtermorpho.cpp.

{
// qDebug();
if(m_halfWindowSize == 0)
return data_points;
if(data_points.size() < m_halfWindowSize)
return data_points;
Trace old_trace(data_points);
auto it = old_trace.begin();
auto it_target = data_points.begin();
auto itw = old_trace.begin();
auto itend = old_trace.end() - m_halfWindowSize - 1;
// new_trace.reserve(data_points.size());
// qDebug();
while((it != old_trace.end()) &&
(std::distance(old_trace.begin(), it) < (int)m_halfWindowSize))
{
// no anti spike at the begining of the signal
it++;
it_target++;
}
// qDebug();
while((it != itend) && (it != old_trace.end()))
{
// qDebug();
auto itwend = it + m_halfWindowSize + 1;
itw = findDifferentYvalue(it - m_halfWindowSize, it + 1, 0);
if(itw == it)
{
// qDebug();
itw = findDifferentYvalue(it + 1, itwend, 0);
if(itw == itwend)
{
it_target->y = 0;
}
// qDebug();
}
// qDebug();
it++;
it_target++;
}
return data_points;
}
pappso::Trace
A simple container of DataPoint instances.
Definition: trace.h:148
pappso::findDifferentYvalue
std::vector< DataPoint >::iterator findDifferentYvalue(std::vector< DataPoint >::iterator begin, std::vector< DataPoint >::iterator end, const double &y_value)
find the first element in which Y is different of value
Definition: trace.cpp:88

References pappso::findDifferentYvalue(), and m_halfWindowSize.

## getHalfWindowSize()

std::size_t FilterMorphoAntiSpike::getHalfWindowSize | ( |  | ) | const

Definition at line 334 of file filtermorpho.cpp.

{
return m_halfWindowSize;
}

References m_halfWindowSize.

## name()

QString pappso::FilterMorphoAntiSpike::name | ( |  | ) | const

override virtual

Implements pappso::FilterNameInterface.

Definition at line 319 of file filtermorpho.cpp.

{
return "antiSpike";
}

## operator=()

FilterMorphoAntiSpike & FilterMorphoAntiSpike::operator= | ( | const FilterMorphoAntiSpike & | other | ) |

Definition at line 326 of file filtermorpho.cpp.

{
m_halfWindowSize = other.m_halfWindowSize;
return *this;
}

References m_halfWindowSize.

## toString()

QString pappso::FilterMorphoAntiSpike::toString | ( |  | ) | const

override virtual

Implements pappso::FilterNameInterface.

Definition at line 311 of file filtermorpho.cpp.

{
QString strCode = QString("antiSpike|%1").arg(m_halfWindowSize);
return strCode;
}

## Member Data Documentation

## m_halfWindowSize

std::size_t pappso::FilterMorphoAntiSpike::m_halfWindowSize = 0

private

Definition at line 160 of file filtermorpho.h.

Referenced by filter(), getHalfWindowSize(), and operator=().

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

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