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

Redefines the floor intensity of the Trace. More...

#include <filterflooramplitudepercentage.h>

Inheritance diagram for pappso::FilterFloorAmplitudePercentage:
pappso::FilterNameInterface pappso::FilterInterface

Public Member Functions

 FilterFloorAmplitudePercentage (double percentage)
 FilterFloorAmplitudePercentage (const QString &parameters)
 FilterFloorAmplitudePercentage (const FilterFloorAmplitudePercentage &other)
virtual ~FilterFloorAmplitudePercentage ()
FilterFloorAmplitudePercentageoperator= (const FilterFloorAmplitudePercentage &other)
Tracefilter (Trace &data_points) const override
double getPercentage () const
QString name () const override
QString toString () const override
 Return a string with the textual representation of the configuration data.
Public Member Functions inherited from pappso::FilterNameInterface
virtual ~FilterNameInterface ()
Public Member Functions inherited from pappso::FilterInterface
virtual ~FilterInterface ()

Protected Member Functions

void buildFilterFromString (const QString &strBuildParams) override
 build this filter using a string

Private Attributes

double m_percentage

Detailed Description

Redefines the floor intensity of the Trace.

The amplitude of the trace is computed (maxValue - minValue) Its fraction is calculated = amplitude * (percentage / 100) The threshold value is computed as (minValue + fraction)

When the values to be filtered are below that threshold they acquire that threshold value.

When the values to be filtered are above that threshold they remain unchanged.

This effectively re-floors the values to threshold.

Definition at line 71 of file filterflooramplitudepercentage.h.

Constructor & Destructor Documentation

◆ FilterFloorAmplitudePercentage() [1/3]

pappso::FilterFloorAmplitudePercentage::FilterFloorAmplitudePercentage ( double percentage)

◆ FilterFloorAmplitudePercentage() [2/3]

pappso::FilterFloorAmplitudePercentage::FilterFloorAmplitudePercentage ( const QString & parameters)

Definition at line 78 of file filterflooramplitudepercentage.cpp.

79{
80 buildFilterFromString(parameters);
81}
void buildFilterFromString(const QString &strBuildParams) override
build this filter using a string

References buildFilterFromString().

◆ FilterFloorAmplitudePercentage() [3/3]

pappso::FilterFloorAmplitudePercentage::FilterFloorAmplitudePercentage ( const FilterFloorAmplitudePercentage & other)

Definition at line 55 of file filterflooramplitudepercentage.cpp.

57{
58 m_percentage = other.m_percentage;
59}

References FilterFloorAmplitudePercentage(), and m_percentage.

◆ ~FilterFloorAmplitudePercentage()

pappso::FilterFloorAmplitudePercentage::~FilterFloorAmplitudePercentage ( )
virtual

Definition at line 62 of file filterflooramplitudepercentage.cpp.

63{
64}

Member Function Documentation

◆ buildFilterFromString()

void pappso::FilterFloorAmplitudePercentage::buildFilterFromString ( const QString & strBuildParams)
overrideprotectedvirtual

build this filter using a string

Parameters
strBuildParamsa string coding the filter and its parameters "filterName|param1;param2;param3"

Implements pappso::FilterNameInterface.

Definition at line 85 of file filterflooramplitudepercentage.cpp.

86{
87 // Typical string: "FloorAmplitudePercentage|15"
88 if(parameters.startsWith(QString("%1|").arg(name())))
89 {
90 QStringList params = parameters.split("|").back().split(";");
91
92 m_percentage = params.at(0).toDouble();
93 }
94 else
95 {
96 throw pappso::ExceptionNotRecognized(
97 QString("Building of FilterFloorAmplitudePercentage from string %1 failed")
98 .arg(parameters));
99 }
100}

References m_percentage, and name().

Referenced by FilterFloorAmplitudePercentage().

◆ filter()

Trace & pappso::FilterFloorAmplitudePercentage::filter ( Trace & data_points) const
overridevirtual

Implements pappso::FilterInterface.

Definition at line 104 of file filterflooramplitudepercentage.cpp.

105{
106
107 auto it_min = minYDataPoint(data_points.begin(), data_points.end());
108 auto it_max = maxYDataPoint(data_points.begin(), data_points.end());
109
110 if(it_min == data_points.end() || it_max == data_points.end())
111 return data_points;
112
113 double min = it_min->y;
114 double max = it_max->y;
115
116 double amplitude = max - min;
117
118 double amplitude_ratio = amplitude * m_percentage / 100;
119
120 double threshold = min + amplitude_ratio;
121
122 // Since we never remove points, we only change their y value, we can do the
123 // filtering inplace.
124
125 for(auto &&data_point : data_points)
126 {
127 // Change the value to be threshold (re-flooring in action).
128 if(data_point.y < threshold)
129 {
130 data_point.y = threshold;
131 }
132 }
133
134 return data_points;
135}
@ max
maximum of intensities
Definition types.h:280
std::vector< DataPoint >::const_iterator maxYDataPoint(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end)
Definition trace.cpp:169
std::vector< DataPoint >::const_iterator minYDataPoint(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end)
Definition trace.cpp:152

References m_percentage, pappso::maxYDataPoint(), and pappso::minYDataPoint().

◆ getPercentage()

double pappso::FilterFloorAmplitudePercentage::getPercentage ( ) const

Definition at line 139 of file filterflooramplitudepercentage.cpp.

140{
141 return m_percentage;
142}

References m_percentage.

◆ name()

QString pappso::FilterFloorAmplitudePercentage::name ( ) const
overridevirtual

Implements pappso::FilterNameInterface.

Definition at line 154 of file filterflooramplitudepercentage.cpp.

155{
156 return "FloorAmplitudePercentage";
157}

Referenced by buildFilterFromString(), and toString().

◆ operator=()

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

Definition at line 67 of file filterflooramplitudepercentage.cpp.

68{
69 if(&other == this)
70 return *this;
71
72 m_percentage = other.m_percentage;
73
74 return *this;
75}

References FilterFloorAmplitudePercentage(), and m_percentage.

◆ toString()

QString pappso::FilterFloorAmplitudePercentage::toString ( ) const
overridevirtual

Return a string with the textual representation of the configuration data.

Implements pappso::FilterNameInterface.

Definition at line 147 of file filterflooramplitudepercentage.cpp.

148{
149 return QString("%1|%2").arg(name()).arg(QString::number(m_percentage, 'f', 2));
150}

References m_percentage, and name().

Member Data Documentation

◆ m_percentage

double pappso::FilterFloorAmplitudePercentage::m_percentage
private

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