libpappsomspp
Library for mass spectrometry
filterlowintensitysignalremoval.h
Go to the documentation of this file.
1/* BEGIN software license
2 *
3 * msXpertSuite - mass spectrometry software suite
4 * -----------------------------------------------
5 * Copyright(C) 2009,...,2021 Filippo Rusconi
6 *
7 * http://www.msxpertsuite.org
8 *
9 * This file is part of the msXpertSuite project.
10 *
11 * The msXpertSuite project is the successor of the massXpert project. This
12 * project now includes various independent modules:
13 *
14 * - massXpert, model polymer chemistries and simulate mass spectrometric data;
15 * - mineXpert, a powerful TIC chromatogram/mass spectrum viewer/miner;
16 *
17 * This program is free software: you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation, either version 3 of the License, or
20 * (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program. If not, see <http://www.gnu.org/licenses/>.
29 *
30 * END software license
31 */
32
33
34#pragma once
35
36
37#include <QObject>
38
39#include "../../trace/trace.h"
40#include "../../exportinmportconfig.h"
41#include "filternameinterface.h"
42
43
44namespace pappso
45{
46
47
48class FilterLowIntensitySignalRemoval;
49
50typedef std::shared_ptr<FilterLowIntensitySignalRemoval>
52typedef std::shared_ptr<const FilterLowIntensitySignalRemoval>
54
55
56/**
57 * @brief Redefines the floor intensity of the Trace
58 *
59 * The amplitude of the trace is computed (maxValue - minValue)
60 * Its fraction is calculated = amplitude * (percentage / 100)
61 * The threshold value is computed as (minValue + fraction)
62 *
63 * When the values to be filtered are below that threshold they acquire that
64 * threshold value.
65 *
66 * When the values to be filtered are above that threshold they remain
67 * unchanged.
68 *
69 * This effectively re-floors the values to threshold.
70 */
72 : public FilterNameInterface
73{
74 public:
76 double std_dev,
77 double threshold);
78 FilterLowIntensitySignalRemoval(const QString &parameters);
80
82
84 operator=(const FilterLowIntensitySignalRemoval &other);
85
86 Trace &filter(Trace &data_points) const override;
87
88 double getThreshold() const;
89 QString name() const override;
90
91 QString toString() const override;
92
93 protected:
94 void buildFilterFromString(const QString &strBuildParams) override;
95
96 Trace &nonConstFilter(Trace &data_points);
97
98 std::size_t detectClusterApices(const Trace &trace);
99
100 Trace::const_iterator backwardFindApex(const Trace &trace,
101 Trace::const_iterator iter,
102 double distance_threshold);
103
104 Trace::const_iterator forwardFindApex(const Trace &trace,
105 Trace::const_iterator iter,
106 double distance_threshold);
107 Trace reconstructTrace(const Trace &trace);
108
109 private:
110 static constexpr double nan = std::numeric_limits<double>::quiet_NaN();
111
115
116 constexpr static double INTRA_CLUSTER_INTER_PEAK_DISTANCE = 1.1;
117
118 const std::size_t m_minIntPointCount = 5;
119 const std::size_t m_minIntStdDevFactor = 2;
120
121 double m_min;
122 double m_max;
123 double m_minMean;
126
127 bool m_seen_upward_phase = false;
128
129 using TraceCIter = Trace::const_iterator;
130
131 // Beware HYPER-ROUGH inialization of the iterator !
132 TraceCIter m_prevApex = static_cast<Trace::const_iterator>(0);
133 TraceCIter m_curApex = static_cast<Trace::const_iterator>(0);
134 TraceCIter m_curIter = static_cast<Trace::const_iterator>(0);
135 TraceCIter m_prevIter = static_cast<Trace::const_iterator>(0);
136
137 using ClusterApices = std::vector<TraceCIter>;
138 using ApicesSPtr = std::shared_ptr<ClusterApices>;
139
140 // All the cluster apices
141 std::vector<ApicesSPtr> m_clusters;
142};
143} // namespace pappso
Redefines the floor intensity of the Trace.
Interface that allows to build filter objects from strings.
A simple container of DataPoint instances.
Definition: trace.h:38
#define PMSPP_LIB_DECL
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
std::shared_ptr< const FilterLowIntensitySignalRemoval > FilterLowIntensitySignalRemovalCstSPtr
std::shared_ptr< FilterLowIntensitySignalRemoval > FilterLowIntensitySignalRemovalSPtr