29 #include "../../trace/trace.h"
32 #include "../../massspectrum/massspectrum.h"
33 #include "../../exception/exceptionoutofrange.h"
34 #include "../../exception/exceptionnotrecognized.h"
45 : m_passY(other.m_passY)
61 Trace new_data_points;
62 for(
auto &&data_point : data_points)
66 new_data_points.push_back(data_point);
69 data_points = std::move(new_data_points);
77 : m_passY(other.m_passY)
93 Trace new_data_points;
94 for(
auto &&data_point : data_points)
98 new_data_points.push_back(data_point);
101 data_points = std::move(new_data_points);
107 : m_ratioPassY(ratio_pass_y)
113 : m_ratioPassY(other.m_ratioPassY)
129 auto it_max =
maxYDataPoint(data_points.begin(), data_points.end());
130 if(it_max == data_points.end())
133 Trace new_data_points;
134 for(
auto &&data_point : data_points)
136 if(data_point.y > pass)
138 new_data_points.push_back(data_point);
141 data_points = std::move(new_data_points);
147 : m_numberOfPoints(number_of_points)
153 : m_numberOfPoints(other.m_numberOfPoints)
177 std::sort(data_points.begin(),
181 data_points.erase(data_points.begin() +
m_numberOfPoints, data_points.end());
184 std::sort(data_points.begin(),
200 double window_range, std::size_t number_of_points_per_window)
201 : m_xWindowRange(window_range), m_numberOfPoints(number_of_points_per_window)
208 QObject::tr(
"window_range must be greater than 0.5"));
217 : m_xWindowRange(other.m_xWindowRange),
218 m_numberOfPoints(other.m_numberOfPoints)
238 std::vector<DataPoint> new_trace(data_points);
241 int window_number = 0;
242 int old_window_number = -1;
243 std::size_t number_of_peaks_in_window = 0;
244 auto itbegin = data_points.begin();
245 std::vector<DataPoint>::iterator it_min;
257 qDebug() <<
" data_point.x=" << data_point.x
258 <<
" data_point.y=" << data_point.y;
260 qDebug() << window_number;
261 if(window_number != old_window_number)
263 old_window_number = window_number;
264 number_of_peaks_in_window = 0;
265 itbegin = data_points.end();
270 data_points.push_back(data_point);
271 number_of_peaks_in_window++;
272 if(number_of_peaks_in_window == 1)
274 itbegin = data_points.begin() + (data_points.size() - 1);
282 if(it_min != data_points.end())
285 if(it_min->y < data_point.y)
288 *it_min = data_point;
331 for(
auto &&dataPoint : data_points)
333 dataPoint.y = std::floor(dataPoint.y);
355 for(
auto &&dataPoint : data_points)
357 dataPoint.y = std::round(dataPoint.y);
367 : m_dynamic(other.m_dynamic)
375 auto it_max =
maxYDataPoint(data_points.begin(), data_points.end());
376 if(it_max == data_points.end())
378 double maximum = it_max->y;
379 for(
auto &&dataPoint : data_points)
381 dataPoint.y = (dataPoint.y / maximum) *
m_dynamic;
403 std::size_t number_of_points)
404 : m_filterGreatestY(number_of_points)
410 : m_filterGreatestY(other.m_filterGreatestY)
436 : m_factor(other.m_factor)
454 for(
auto &&dataPoint : data_points)
456 dataPoint.y = dataPoint.y *
m_factor;
467 : m_valueToRemove(valueToRemove)
472 : m_valueToRemove(other.m_valueToRemove)
492 for(
auto &&dataPoint : data_points)
504 : m_quantile(quantile)
510 : m_quantile(other.m_quantile)
531 if(data_points.size() == 0)
533 double value_to_temove =
534 quantileYTrace(data_points.begin(), data_points.end(), m_quantile);
535 for(
auto &&dataPoint : data_points)
537 if(dataPoint.y < value_to_temove)
540 dataPoint.y = dataPoint.y - value_to_temove;
546 const QString &strBuildParams)
548 buildFilterFromString(strBuildParams);
554 const QString &strBuildParams)
558 if(strBuildParams.startsWith(
"passQuantileBasedRemoveY|"))
561 strBuildParams.split(
"|").back().split(
";", Qt::SkipEmptyParts);
563 QString value = params.at(0);
564 m_quantile = value.toDouble();
570 "building passQuantileBasedRemoveY from string %1 is not possible")
571 .arg(strBuildParams));
580 return "passQuantileBasedRemoveY";
587 QString strCode = QString(
"%1|%2").arg(name()).arg(m_quantile);
excetion to use when an item type is not recognized
apply std::floor (round to lowest integer) to all Y values
FilterFloorY & operator=(const FilterFloorY &other)
Trace & filter(Trace &data_points) const override
keep N datapoints form the greatest intensities to the lowest
Trace & filter(Trace &data_points) const override
FilterGreatestY(std::size_t number_of_points=0)
constructor with the number of datapoints to keep
FilterGreatestY & operator=(const FilterGreatestY &other)
std::size_t getNumberOfPoints() const
std::size_t m_numberOfPoints
keep N datapoints form the greatest intensities to the lowest within a mass range in dalton
Trace & filter(Trace &data_points) const override
std::size_t m_numberOfPoints
FilterGreatestYperWindow(double window_range, std::size_t number_of_points_per_window)
constructor with the number of datapoints to keep
FilterGreatestYperWindow & operator=(const FilterGreatestYperWindow &other)
std::size_t getNumberOfPoints() const
remove datapoints below a given intensity percentage (ratio) of the maximum intensity
FilterHighPassPercentage(double y_ratio)
Trace & filter(Trace &data_points) const override
FilterHighPassPercentage & operator=(const FilterHighPassPercentage &other)
remove datapoints below a given Y value (intensity)
Trace & filter(Trace &data_points) const override
FilterHighPass & operator=(const FilterHighPass &other)
FilterHighPass(double pass_y)
remove datapoints higher than a given Y value (intensity)
FilterLowPass(double pass_y)
Trace & filter(Trace &data_points) const override
FilterLowPass & operator=(const FilterLowPass &other)
removes a value found by quantile to all Y values
double getQuantileThreshold() const
FilterQuantileBasedRemoveY & operator=(const FilterQuantileBasedRemoveY &other)
FilterQuantileBasedRemoveY(double quantile_threshold)
void buildFilterFromString(const QString &strBuildParams) override
build this filter using a string
Trace & filter(Trace &data_points) const override
QString toString() const override
virtual QString name() const override
removes a value to all Y values
FilterRemoveY(double valueToRemove)
Trace & filter(Trace &data_points) const override
FilterRemoveY & operator=(const FilterRemoveY &other)
rescales Y values into a dynamic range if the dynamic range is set to 0, this filter is ignored
Trace & filter(Trace &data_points) const override
FilterRescaleY(double dynamic)
double getDynamicRange() const
FilterRescaleY & operator=(const FilterRescaleY &other)
apply std::round (round to nearest integer) to all Y values
Trace & filter(Trace &data_points) const override
FilterRoundY & operator=(const FilterRoundY &other)
rescales Y values given a tranformation factor
FilterScaleFactorY & operator=(const FilterScaleFactorY &other)
FilterScaleFactorY(double m_factor)
Trace & filter(Trace &data_points) const override
double getScaleFactorY() const
MassSpectrumFilterGreatestItensities(std::size_t number_of_points=0)
FilterGreatestY m_filterGreatestY
MassSpectrum & filter(MassSpectrum &spectrum) const override
MassSpectrumFilterGreatestItensities & operator=(const MassSpectrumFilterGreatestItensities &other)
Class to represent a mass spectrum.
A simple container of DataPoint instances.
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
std::vector< DataPoint >::const_iterator maxYDataPoint(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end)
std::vector< DataPoint >::const_iterator minYDataPoint(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end)
double quantileYTrace(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end, double quantile)
calculate the quantile of y value of a trace