libpappsomspp
Library for mass spectrometry
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 
33 namespace pappso
34 {
35 
36 struct DataPoint;
37 
38 /** @brief base class that apply a signal treatment based on a window
39  */
41 {
42  protected:
43  std::size_t m_halfWindowSize = 0;
44 
45  virtual double
46  getWindowValue(std::vector<DataPoint>::const_iterator begin,
47  std::vector<DataPoint>::const_iterator end) const = 0;
48 
49  public:
50  FilterMorphoWindowBase(std::size_t half_window_size);
53 
55 
56  virtual Trace &filter(Trace &data_points) const override;
57 
58  virtual std::size_t getHalfWindowSize() const;
59 };
60 
61 /** @brief test purpose
62  */
64 {
65 
66  public:
67  FilterMorphoSum(std::size_t half_window_size);
68  FilterMorphoSum(const FilterMorphoSum &other);
69  virtual ~FilterMorphoSum(){};
70 
71  FilterMorphoSum &operator=(const FilterMorphoSum &other);
72 
73  double
74  getWindowValue(std::vector<DataPoint>::const_iterator begin,
75  std::vector<DataPoint>::const_iterator end) const override;
76 };
77 
78 /** @brief transform the trace into its maximum over a window
79  */
81 {
82 
83  public:
84  FilterMorphoMax(std::size_t half_window_size);
85  FilterMorphoMax(const FilterMorphoMax &other);
86  virtual ~FilterMorphoMax(){};
87 
88  FilterMorphoMax &operator=(const FilterMorphoMax &other);
89  double
90  getWindowValue(std::vector<DataPoint>::const_iterator begin,
91  std::vector<DataPoint>::const_iterator end) const override;
92 
93  std::size_t getMaxHalfEdgeWindows() const;
94 };
95 
96 /** @brief transform the trace into its minimum over a window
97  */
99 {
100 
101  public:
102  FilterMorphoMin(std::size_t half_window_size);
103  FilterMorphoMin(const FilterMorphoMin &other);
104  virtual ~FilterMorphoMin(){};
105 
106  FilterMorphoMin &operator=(const FilterMorphoMin &other);
107  double
108  getWindowValue(std::vector<DataPoint>::const_iterator begin,
109  std::vector<DataPoint>::const_iterator end) const override;
110 
111  std::size_t getMinHalfEdgeWindows() const;
112 };
113 
114 /** @brief transform the trace with the minimum of the maximum
115  * equivalent of the dilate filter for pictures
116  */
118 {
119  private:
122 
123  public:
124  FilterMorphoMinMax(std::size_t half_window_size);
126  virtual ~FilterMorphoMinMax(){};
127 
128  FilterMorphoMinMax &operator=(const FilterMorphoMinMax &other);
129  Trace &filter(Trace &data_points) const override;
130 
131  std::size_t getMinMaxHalfEdgeWindows() const;
132 };
133 
134 /** @brief transform the trace with the maximum of the minimum
135  * equivalent of the erode filter for pictures
136  */
138 {
139  private:
142 
143  public:
144  FilterMorphoMaxMin(std::size_t half_window_size);
146  virtual ~FilterMorphoMaxMin(){};
147 
148  FilterMorphoMaxMin &operator=(const FilterMorphoMaxMin &other);
149  Trace &filter(Trace &data_points) const override;
150 
151  std::size_t getMaxMinHalfEdgeWindows() const;
152 };
153 
154 /** @brief anti spike filter
155  * set to zero alone values inside the window
156  */
158 {
159  private:
160  std::size_t m_halfWindowSize = 0;
161 
162  public:
163  FilterMorphoAntiSpike(std::size_t half_window_size);
164  /**
165  * @param strBuildParams string to build the filter
166  * "antiSpike|2"
167  */
168  FilterMorphoAntiSpike(const QString &strBuildParams);
169 
172 
173  FilterMorphoAntiSpike &operator=(const FilterMorphoAntiSpike &other);
174  Trace &filter(Trace &data_points) const override;
175 
176  std::size_t getHalfWindowSize() const;
177 
178 
179  void buildFilterFromString(const QString &strBuildParams) override;
180 
181  QString toString() const override;
182 
183  QString name() const override;
184 };
185 
186 
187 /** @brief median filter
188  * apply median of y values inside the window
189  */
191 {
192 
193  public:
194  FilterMorphoMedian(std::size_t half_window_size);
196  virtual ~FilterMorphoMedian(){};
197 
198  FilterMorphoMedian &operator=(const FilterMorphoMedian &other);
199  double
200  getWindowValue(std::vector<DataPoint>::const_iterator begin,
201  std::vector<DataPoint>::const_iterator end) const override;
202 };
203 
204 
205 /** @brief mean filter
206  * apply mean of y values inside the window : this results in a kind of
207  * smoothing
208  */
210 {
211 
212  public:
213  FilterMorphoMean(std::size_t half_window_size);
214  FilterMorphoMean(const FilterMorphoMean &other);
215  virtual ~FilterMorphoMean(){};
216 
217  FilterMorphoMean &operator=(const FilterMorphoMean &other);
218  double
219  getWindowValue(std::vector<DataPoint>::const_iterator begin,
220  std::vector<DataPoint>::const_iterator end) const override;
221 
222  std::size_t getMeanHalfEdgeWindows() const;
223 };
224 
225 /** @brief compute background of a trace
226  * compute background noise on a trace
227  */
229 {
230  private:
233 
234  public:
235  FilterMorphoBackground(std::size_t median_half_window_size,
236  std::size_t minmax_half_window_size);
239 
240  FilterMorphoBackground &operator=(const FilterMorphoBackground &other);
241  const FilterMorphoMedian &getFilterMorphoMedian() const;
242  const FilterMorphoMinMax &getFilterMorphoMinMax() const;
243 
244  Trace &filter(Trace &data_points) const override;
245 };
246 } // namespace pappso
generic interface to apply a filter on a trace
anti spike filter set to zero alone values inside the window
Definition: filtermorpho.h:158
compute background of a trace compute background noise on a trace
Definition: filtermorpho.h:229
FilterMorphoMedian m_filterMorphoMedian
Definition: filtermorpho.h:231
FilterMorphoMinMax m_filterMorphoMinMax
Definition: filtermorpho.h:232
transform the trace with the maximum of the minimum equivalent of the erode filter for pictures
Definition: filtermorpho.h:138
FilterMorphoMax m_filterMax
Definition: filtermorpho.h:141
FilterMorphoMin m_filterMin
Definition: filtermorpho.h:140
transform the trace into its maximum over a window
Definition: filtermorpho.h:81
mean filter apply mean of y values inside the window : this results in a kind of smoothing
Definition: filtermorpho.h:210
median filter apply median of y values inside the window
Definition: filtermorpho.h:191
transform the trace with the minimum of the maximum equivalent of the dilate filter for pictures
Definition: filtermorpho.h:118
FilterMorphoMax m_filterMax
Definition: filtermorpho.h:120
FilterMorphoMin m_filterMin
Definition: filtermorpho.h:121
transform the trace into its minimum over a window
Definition: filtermorpho.h:99
base class that apply a signal treatment based on a window
Definition: filtermorpho.h:41
virtual Trace & filter(Trace &data_points) const override
virtual double getWindowValue(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end) const =0
FilterMorphoWindowBase(std::size_t half_window_size)
virtual std::size_t getHalfWindowSize() const
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