libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
filterlocalmaximum.cpp
Go to the documentation of this file.
1
/**
2
* \file pappsomspp/filers/filterlocalmaximum.cpp
3
* \date 24/09/2019
4
* \author Olivier Langella
5
* \brief filter to select local maximum in a spectrum
6
* inspired from the proteowizard library "LocalMaximumPeakDetector"
7
*/
8
9
/*******************************************************************************
10
* Copyright (c) 2019 Olivier Langella <Olivier.Langella@u-psud.fr>.
11
*
12
* This file is part of the PAPPSOms++ library.
13
*
14
* PAPPSOms++ is free software: you can redistribute it and/or modify
15
* it under the terms of the GNU General Public License as published by
16
* the Free Software Foundation, either version 3 of the License, or
17
* (at your option) any later version.
18
*
19
* PAPPSOms++ is distributed in the hope that it will be useful,
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
* GNU General Public License for more details.
23
*
24
* You should have received a copy of the GNU General Public License
25
* along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
26
*
27
******************************************************************************/
28
29
30
#include "
filterlocalmaximum.h
"
31
#include "
../../trace/trace.h
"
32
using namespace
pappso
;
33
34
FilterLocalMaximum::FilterLocalMaximum
(std::size_t half_window_size)
35
:
m_halfWindowSize
(half_window_size)
36
{
37
}
38
39
FilterLocalMaximum::FilterLocalMaximum
(
const
FilterLocalMaximum
&other)
40
:
m_halfWindowSize
(other.
m_halfWindowSize
)
41
{
42
}
43
44
FilterLocalMaximum::~FilterLocalMaximum
()
45
{
46
}
47
48
Trace
&
49
FilterLocalMaximum::filter
(
Trace
&data_points)
const
50
{
51
52
if
(
m_halfWindowSize
== 0)
53
return
data_points;
54
Trace
new_trace;
55
auto
it = data_points.begin();
56
57
auto
itend = data_points.end() -
m_halfWindowSize
- 1;
// no filter at the end of signal
58
// new_trace.reserve(data_points.size());
59
60
while
((it != data_points.end()) &&
61
(std::distance(data_points.begin(), it) < (
int
)
m_halfWindowSize
))
62
{
63
// no filter at the begining of the signal
64
it++;
65
}
66
while
(it != itend)
67
{
68
auto
itwend = it +
m_halfWindowSize
+ 1;
69
auto
itw =
maxYDataPoint
(it -
m_halfWindowSize
, it + 1);
70
if
(itw == it)
71
{
72
itw =
maxYDataPoint
(it, itwend);
73
if
(itw == it)
74
{
75
new_trace.push_back({it->x, it->y});
76
}
77
}
78
79
it++;
80
}
81
82
data_points = std::move(new_trace);
83
return
data_points;
84
}
85
86
std::size_t
87
FilterLocalMaximum::getHalfWindowSize
()
const
88
{
89
return
m_halfWindowSize
;
90
}
pappso::FilterLocalMaximum::getHalfWindowSize
std::size_t getHalfWindowSize() const
Definition
filterlocalmaximum.cpp:87
pappso::FilterLocalMaximum::filter
Trace & filter(Trace &data_points) const override
Definition
filterlocalmaximum.cpp:49
pappso::FilterLocalMaximum::~FilterLocalMaximum
virtual ~FilterLocalMaximum()
Definition
filterlocalmaximum.cpp:44
pappso::FilterLocalMaximum::m_halfWindowSize
std::size_t m_halfWindowSize
Definition
filterlocalmaximum.h:68
pappso::FilterLocalMaximum::FilterLocalMaximum
FilterLocalMaximum(std::size_t half_window_size)
Definition
filterlocalmaximum.cpp:34
pappso::Trace
A simple container of DataPoint instances.
Definition
trace.h:152
filterlocalmaximum.h
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition
aa.cpp:39
pappso::maxYDataPoint
std::vector< DataPoint >::const_iterator maxYDataPoint(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end)
Definition
trace.cpp:169
trace.h
pappsomspp
core
processing
filters
filterlocalmaximum.cpp
Generated on
for libpappsomspp by
1.15.0