libpappsomspp
Library for mass spectrometry
pappso::FilterMorphoWindowBase Class Referenceabstract

base class that apply a signal treatment based on a window More...

#include <filtermorpho.h>

Inheritance diagram for pappso::FilterMorphoWindowBase:
pappso::FilterInterface pappso::FilterMorphoMax pappso::FilterMorphoMean pappso::FilterMorphoMedian pappso::FilterMorphoMin pappso::FilterMorphoSum

Public Member Functions

 FilterMorphoWindowBase (std::size_t half_window_size)
 
 FilterMorphoWindowBase (const FilterMorphoWindowBase &other)
 
virtual ~FilterMorphoWindowBase ()
 
FilterMorphoWindowBaseoperator= (const FilterMorphoWindowBase &other)
 
virtual Tracefilter (Trace &data_points) const override
 
virtual std::size_t getHalfWindowSize () const
 

Protected Member Functions

virtual double getWindowValue (std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end) const =0
 

Protected Attributes

std::size_t m_halfWindowSize = 0
 

Detailed Description

base class that apply a signal treatment based on a window

Definition at line 58 of file filtermorpho.h.

Constructor & Destructor Documentation

◆ FilterMorphoWindowBase() [1/2]

FilterMorphoWindowBase::FilterMorphoWindowBase ( std::size_t  half_window_size)

Definition at line 35 of file filtermorpho.cpp.

36  : m_halfWindowSize(half_window_size)
37 {
38 }

◆ FilterMorphoWindowBase() [2/2]

FilterMorphoWindowBase::FilterMorphoWindowBase ( const FilterMorphoWindowBase other)

Definition at line 39 of file filtermorpho.cpp.

42 {
43 }

◆ ~FilterMorphoWindowBase()

virtual pappso::FilterMorphoWindowBase::~FilterMorphoWindowBase ( )
inlinevirtual

Definition at line 70 of file filtermorpho.h.

Member Function Documentation

◆ filter()

Trace & FilterMorphoWindowBase::filter ( Trace data_points) const
overridevirtual

Implements pappso::FilterInterface.

Definition at line 60 of file filtermorpho.cpp.

61 {
62 
63  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
64  << m_halfWindowSize << " data_points.size()" << data_points.size();
65  if(m_halfWindowSize == 0)
66  return data_points;
67  Trace old_trace(data_points);
68  auto it = old_trace.begin();
69  auto itend = old_trace.end() - m_halfWindowSize - 1;
70  auto it_target = data_points.begin();
71 
72 
73  std::size_t loop_begin = 0;
74  while((it != itend) && (loop_begin < m_halfWindowSize))
75  {
76  // maxYDataPoint(it_begin, it + m_halfWindowSize + 1);
77  // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
78  // << it->x << " " << m_halfWindowSize;
79  // it_target->x = it->x;
80  it_target->y =
81  getWindowValue(old_trace.begin(), it + m_halfWindowSize + 1);
82  it++;
83  it_target++;
84  loop_begin++;
85  }
86  // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
87  while(it != itend)
88  {
89  // it_target->x = it->x;
90  // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
91  // << it->x;
92  it_target->y =
94  it++;
95  it_target++;
96  }
97  // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
98  while(it != old_trace.end())
99  {
100  // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
101  // << it->x;
102  // it_target->x = it->x;
103  it_target->y = getWindowValue(it - m_halfWindowSize, old_trace.end());
104  it++;
105  it_target++;
106  }
107  // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
108  // problem with move or swap : this lead to segmentation faults in some cases
109  // data_points = std::move(new_trace);
110  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
111  return data_points;
112 }

References getWindowValue(), and m_halfWindowSize.

Referenced by pappso::FilterMorphoMinMax::filter(), pappso::FilterMorphoMaxMin::filter(), and pappso::FilterMorphoBackground::filter().

◆ getHalfWindowSize()

std::size_t FilterMorphoWindowBase::getHalfWindowSize ( ) const
virtual

Definition at line 45 of file filtermorpho.cpp.

46 {
47  return m_halfWindowSize;
48 }

References m_halfWindowSize.

◆ getWindowValue()

virtual double pappso::FilterMorphoWindowBase::getWindowValue ( std::vector< DataPoint >::const_iterator  begin,
std::vector< DataPoint >::const_iterator  end 
) const
protectedpure virtual

◆ operator=()

FilterMorphoWindowBase & FilterMorphoWindowBase::operator= ( const FilterMorphoWindowBase other)

Definition at line 51 of file filtermorpho.cpp.

52 {
54 
55  return *this;
56 }

References m_halfWindowSize.

Member Data Documentation

◆ m_halfWindowSize


The documentation for this class was generated from the following files:
pappso::FilterMorphoWindowBase::getWindowValue
virtual double getWindowValue(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end) const =0
pappso::Trace
A simple container of DataPoint instances.
Definition: trace.h:126
pappso::FilterMorphoWindowBase::m_halfWindowSize
std::size_t m_halfWindowSize
Definition: filtermorpho.h:61