libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
filtermorpho.h
Go to the documentation of this file.
1/**
2 * \file pappsomspp/filers/filtermorpho.h
3 * \date 02/05/2019
4 * \author Olivier Langella
5 * \brief collection of morphological filters
6 */
7
8/*******************************************************************************
9 * Copyright (c) 2019 Olivier Langella <Olivier.Langella@u-psud.fr>.
10 *
11 * This file is part of the PAPPSOms++ library.
12 *
13 * PAPPSOms++ is free software: you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation, either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * PAPPSOms++ is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
25 *
26 ******************************************************************************/
27
28#pragma once
29
30#include "filtersuite.h"
31#include <cstddef>
32
33namespace pappso
34{
35
36struct DataPoint;
37
38/** @brief base class that apply a signal treatment based on a window
39 */
41{
42
43 public:
44 FilterMorphoWindowBase(std::size_t half_window_size);
47
49
50 virtual Trace &filter(Trace &data_points) const override;
51
52 virtual std::size_t getHalfWindowSize() const;
53
54
55 virtual QString name() const override;
56 virtual QString toString() const override;
57
58
59 protected:
60 void buildFilterFromString(const QString &strBuildParams) override;
61
62 virtual double getWindowValue(std::vector<DataPoint>::const_iterator begin,
63 std::vector<DataPoint>::const_iterator end) const = 0;
64
65 protected:
66 std::size_t m_halfWindowSize = 0;
67};
68
69/** @brief test purpose
70 */
72{
73
74 public:
75 FilterMorphoSum(std::size_t half_window_size);
76 FilterMorphoSum(const FilterMorphoSum &other);
77 virtual ~FilterMorphoSum(){};
78
79 FilterMorphoSum &operator=(const FilterMorphoSum &other);
80
81
82 protected:
83 double getWindowValue(std::vector<DataPoint>::const_iterator begin,
84 std::vector<DataPoint>::const_iterator end) const override;
85};
86
87/** @brief transform the trace into its maximum over a window
88 */
90{
91
92 public:
93 FilterMorphoMax(std::size_t half_window_size);
94 FilterMorphoMax(const FilterMorphoMax &other);
95 virtual ~FilterMorphoMax(){};
96
97 FilterMorphoMax &operator=(const FilterMorphoMax &other);
98
99
100 protected:
101 double getWindowValue(std::vector<DataPoint>::const_iterator begin,
102 std::vector<DataPoint>::const_iterator end) const override;
103};
104
105/** @brief transform the trace into its minimum over a window
106 */
108{
109
110 public:
111 FilterMorphoMin(std::size_t half_window_size);
112 FilterMorphoMin(const FilterMorphoMin &other);
113 virtual ~FilterMorphoMin(){};
114
115 FilterMorphoMin &operator=(const FilterMorphoMin &other);
116
117
118 protected:
119 double getWindowValue(std::vector<DataPoint>::const_iterator begin,
120 std::vector<DataPoint>::const_iterator end) const override;
121};
122
123/** @brief transform the trace with the minimum of the maximum
124 * equivalent of the dilate filter for pictures
125 */
127{
128
129 public:
130 FilterMorphoMinMax(std::size_t half_window_size);
133
134 FilterMorphoMinMax &operator=(const FilterMorphoMinMax &other);
135 Trace &filter(Trace &data_points) const override;
136
137 std::size_t getMinMaxHalfEdgeWindows() const;
138
139 private:
142};
143
144/** @brief transform the trace with the maximum of the minimum
145 * equivalent of the erode filter for pictures
146 */
148{
149
150 public:
151 FilterMorphoMaxMin(std::size_t half_window_size);
154
155 FilterMorphoMaxMin &operator=(const FilterMorphoMaxMin &other);
156 Trace &filter(Trace &data_points) const override;
157
158 std::size_t getMaxMinHalfEdgeWindows() const;
159
160 private:
163};
164
165/** @brief anti spike filter
166 * set to zero alone values inside the window
167 */
169{
170
171 public:
172 FilterMorphoAntiSpike(std::size_t half_window_size);
173 /**
174 * @param strBuildParams string to build the filter
175 * "antiSpike|2"
176 */
177 FilterMorphoAntiSpike(const QString &strBuildParams);
178
181
182 FilterMorphoAntiSpike &operator=(const FilterMorphoAntiSpike &other);
183 Trace &filter(Trace &data_points) const override;
184
185 std::size_t getHalfWindowSize() const;
186
187
188 QString toString() const override;
189
190 QString name() const override;
191
192
193 protected:
194 void buildFilterFromString(const QString &strBuildParams) override;
195
196 private:
197 std::size_t m_halfWindowSize = 0;
198};
199
200
201/** @brief median filter
202 * apply median of y values inside the window
203 */
205{
206
207 public:
208 FilterMorphoMedian(std::size_t half_window_size);
211
212 FilterMorphoMedian &operator=(const FilterMorphoMedian &other);
213
214 protected:
215 double getWindowValue(std::vector<DataPoint>::const_iterator begin,
216 std::vector<DataPoint>::const_iterator end) const override;
217};
218
219
220/** @brief mean filter
221 * apply mean of y values inside the window : this results in a kind of
222 * smoothing
223 */
225{
226
227 public:
228 FilterMorphoMean(const QString &strBuildParams);
229 FilterMorphoMean(std::size_t half_window_size);
231 virtual ~FilterMorphoMean(){};
232
233 FilterMorphoMean &operator=(const FilterMorphoMean &other);
234
235 void buildFilterFromString(const QString &strBuildParams) override;
236
237 QString toString() const override;
238
239 QString name() const override;
240
241 protected:
242 double getWindowValue(std::vector<DataPoint>::const_iterator begin,
243 std::vector<DataPoint>::const_iterator end) const override;
244};
245
246/** @brief compute background of a trace
247 * compute background noise on a trace
248 */
250{
251
252 public:
253 FilterMorphoBackground(const QString &strBuildParams);
254 FilterMorphoBackground(std::size_t median_half_window_size, std::size_t minmax_half_window_size);
256 virtual ~FilterMorphoBackground();
257
261
262 Trace &filter(Trace &data_points) const override;
263
264
265 void buildFilterFromString(const QString &strBuildParams) override;
266
267 QString toString() const override;
268
269 QString name() const override;
270
271 private:
274};
275} // namespace pappso
generic interface to apply a filter on a trace
anti spike filter set to zero alone values inside the window
FilterMorphoAntiSpike(std::size_t half_window_size)
void buildFilterFromString(const QString &strBuildParams) override
build this filter using a string
Trace & filter(Trace &data_points) const override
FilterMorphoMedian * mpa_filterMorphoMedian
QString toString() const override
const FilterMorphoMedian & getFilterMorphoMedian() const
FilterMorphoBackground & operator=(const FilterMorphoBackground &other)
const FilterMorphoMinMax & getFilterMorphoMinMax() const
FilterMorphoBackground(const QString &strBuildParams)
FilterMorphoMinMax * mpa_filterMorphoMinMax
QString name() const override
transform the trace with the maximum of the minimum equivalent of the erode filter for pictures
FilterMorphoMaxMin(std::size_t half_window_size)
FilterMorphoMax m_filterMax
FilterMorphoMin m_filterMin
transform the trace into its maximum over a window
FilterMorphoMax(std::size_t half_window_size)
mean filter apply mean of y values inside the window : this results in a kind of smoothing
FilterMorphoMean(const QString &strBuildParams)
median filter apply median of y values inside the window
FilterMorphoMedian(std::size_t half_window_size)
transform the trace with the minimum of the maximum equivalent of the dilate filter for pictures
FilterMorphoMax m_filterMax
FilterMorphoMin m_filterMin
FilterMorphoMinMax(std::size_t half_window_size)
transform the trace into its minimum over a window
FilterMorphoMin(std::size_t half_window_size)
FilterMorphoSum(std::size_t half_window_size)
base class that apply a signal treatment based on a window
virtual double getWindowValue(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end) const =0
void buildFilterFromString(const QString &strBuildParams) override
build this filter using a string
virtual QString name() const override
FilterMorphoWindowBase(std::size_t half_window_size)
virtual std::size_t getHalfWindowSize() const
virtual QString toString() const override
FilterMorphoWindowBase & operator=(const FilterMorphoWindowBase &other)
Interface that allows to build filter objects from strings.
A simple container of DataPoint instances.
Definition trace.h:148
#define PMSPP_LIB_DECL
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
@ filter
concerning filters (psm, peptide, protein validation)