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);
166 
167  FilterMorphoAntiSpike &operator=(const FilterMorphoAntiSpike &other);
168  Trace &filter(Trace &data_points) const override;
169 
170  std::size_t getHalfWindowSize() const;
171 
172 
173  void buildFilterFromString(const QString &strBuildParams) override;
174 
175  QString toString() const override;
176 
177  QString name() const override;
178 };
179 
180 
181 /** @brief median filter
182  * apply median of y values inside the window
183  */
185 {
186 
187  public:
188  FilterMorphoMedian(std::size_t half_window_size);
190  virtual ~FilterMorphoMedian(){};
191 
192  FilterMorphoMedian &operator=(const FilterMorphoMedian &other);
193  double
194  getWindowValue(std::vector<DataPoint>::const_iterator begin,
195  std::vector<DataPoint>::const_iterator end) const override;
196 };
197 
198 
199 /** @brief mean filter
200  * apply mean of y values inside the window : this results in a kind of
201  * smoothing
202  */
204 {
205 
206  public:
207  FilterMorphoMean(std::size_t half_window_size);
208  FilterMorphoMean(const FilterMorphoMean &other);
209  virtual ~FilterMorphoMean(){};
210 
211  FilterMorphoMean &operator=(const FilterMorphoMean &other);
212  double
213  getWindowValue(std::vector<DataPoint>::const_iterator begin,
214  std::vector<DataPoint>::const_iterator end) const override;
215 
216  std::size_t getMeanHalfEdgeWindows() const;
217 };
218 
219 /** @brief compute background of a trace
220  * compute background noise on a trace
221  */
223 {
224  private:
227 
228  public:
229  FilterMorphoBackground(std::size_t median_half_window_size,
230  std::size_t minmax_half_window_size);
233 
234  FilterMorphoBackground &operator=(const FilterMorphoBackground &other);
235  const FilterMorphoMedian &getFilterMorphoMedian() const;
236  const FilterMorphoMinMax &getFilterMorphoMinMax() const;
237 
238  Trace &filter(Trace &data_points) const override;
239 };
240 } // 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:223
FilterMorphoMedian m_filterMorphoMedian
Definition: filtermorpho.h:225
FilterMorphoMinMax m_filterMorphoMinMax
Definition: filtermorpho.h:226
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:204
median filter apply median of y values inside the window
Definition: filtermorpho.h:185
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:132
#define PMSPP_LIB_DECL
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39