pappsomspp
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 ()
 
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_half_window_size = 0
 

Detailed Description

base class that apply a signal treatment based on a window

Definition at line 56 of file filtermorpho.h.

Constructor & Destructor Documentation

◆ FilterMorphoWindowBase() [1/2]

FilterMorphoWindowBase::FilterMorphoWindowBase ( std::size_t  half_window_size)

Definition at line 34 of file filtermorpho.cpp.

36  : m_half_window_size(half_window_size)
37 {

◆ FilterMorphoWindowBase() [2/2]

FilterMorphoWindowBase::FilterMorphoWindowBase ( const FilterMorphoWindowBase other)

Definition at line 38 of file filtermorpho.cpp.

◆ ~FilterMorphoWindowBase()

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

Definition at line 68 of file filtermorpho.h.

Member Function Documentation

◆ filter()

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

Implements pappso::FilterInterface.

Definition at line 49 of file filtermorpho.cpp.

51 {
52 
53  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
54  << m_half_window_size << " data_points.size()" << data_points.size();
55  if(m_half_window_size == 0)
56  return data_points;
57  Trace old_trace(data_points);
58  auto it = old_trace.begin();
59  auto itend = old_trace.end() - m_half_window_size - 1;
60  auto it_target = data_points.begin();
61 
62 
63  std::size_t loop_begin = 0;
64  while((it != itend) && (loop_begin < m_half_window_size))
65  {
66  // maxYDataPoint(it_begin, it + m_half_window_size + 1);
67  // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
68  // << it->x << " " << m_half_window_size;
69  // it_target->x = it->x;
70  it_target->y =
71  getWindowValue(old_trace.begin(), it + m_half_window_size + 1);
72  it++;
73  it_target++;
74  loop_begin++;
75  }
76  // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
77  while(it != itend)
78  {
79  // it_target->x = it->x;
80  // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
81  // << it->x;
82  it_target->y =
84  it++;
85  it_target++;
86  }
87  // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
88  while(it != old_trace.end())
89  {
90  // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
91  // << it->x;
92  // it_target->x = it->x;
93  it_target->y = getWindowValue(it - m_half_window_size, old_trace.end());
94  it++;
95  it_target++;
96  }
97  // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
98  // problem with move or swap : this lead to segmentation faults in some cases
99  // data_points = std::move(new_trace);
100  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
101  return data_points;

References getWindowValue(), and m_half_window_size.

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

◆ getHalfWindowSize()

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

Definition at line 44 of file filtermorpho.cpp.

46 {
47  return m_half_window_size;

References m_half_window_size.

◆ getWindowValue()

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

Member Data Documentation

◆ m_half_window_size

std::size_t pappso::FilterMorphoWindowBase::m_half_window_size = 0
protected

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:125
pappso::FilterMorphoWindowBase::m_half_window_size
std::size_t m_half_window_size
Definition: filtermorpho.h:59