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
 
- Protected Member Functions inherited from pappso::FilterNameInterface

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)

Definition at line 49 of file filterflooramplitudepercentage.cpp.

References m_percentage.

◆ FilterFloorAmplitudePercentage() [2/3]

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

Definition at line 80 of file filterflooramplitudepercentage.cpp.

82{
83 buildFilterFromString(parameters);
84}
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 56 of file filterflooramplitudepercentage.cpp.

58{
59 m_percentage = other.m_percentage;
60}

References m_percentage.

◆ ~FilterFloorAmplitudePercentage()

pappso::FilterFloorAmplitudePercentage::~FilterFloorAmplitudePercentage ( )
virtual

Definition at line 63 of file filterflooramplitudepercentage.cpp.

64{
65}

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 88 of file filterflooramplitudepercentage.cpp.

89{
90 // Typical string: "FloorAmplitudePercentage|15"
91 if(parameters.startsWith(QString("%1|").arg(name())))
92 {
93 QStringList params = parameters.split("|").back().split(";");
94
95 m_percentage = params.at(0).toDouble();
96 }
97 else
98 {
100 QString(
101 "Building of FilterFloorAmplitudePercentage from string %1 failed")
102 .arg(parameters));
103 }
104}
excetion to use when an item type is not recognized

References m_percentage, and name().

Referenced by FilterFloorAmplitudePercentage().

◆ filter()

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

Implements pappso::FilterInterface.

Definition at line 108 of file filterflooramplitudepercentage.cpp.

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

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

◆ getPercentage()

double pappso::FilterFloorAmplitudePercentage::getPercentage ( ) const

Definition at line 143 of file filterflooramplitudepercentage.cpp.

144{
145 return m_percentage;
146}

References m_percentage.

◆ name()

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

Implements pappso::FilterNameInterface.

Definition at line 159 of file filterflooramplitudepercentage.cpp.

160{
161 return "FloorAmplitudePercentage";
162}

Referenced by buildFilterFromString(), and toString().

◆ operator=()

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

Definition at line 68 of file filterflooramplitudepercentage.cpp.

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

References 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 151 of file filterflooramplitudepercentage.cpp.

152{
153 return QString("%1|%2").arg(name()).arg(
154 QString::number(m_percentage, 'f', 2));
155}

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: