Functions
AlgParts.h File Reference
#include <vector>

Go to the source code of this file.

Functions

void do_frugal_update (short &median, int &runningDiff, const short sample, const int ncontig)
 
std::vector< short > frugal_pedestal_sigkill (const std::vector< short > &raw_in, const int lookahead, const int threshold, const int ncontig)
 
std::vector< short > frugal_iqr (const std::vector< short > &raw_in, const std::vector< short > &median, const int ncontig)
 
std::vector< short > frugal_pedestal (const std::vector< short > &raw_in, const int ncontig)
 
std::vector< short > apply_fir_filter (const std::vector< short > &input, const size_t ntaps, const short *taps)
 

Function Documentation

std::vector<short> apply_fir_filter ( const std::vector< short > &  input,
const size_t  ntaps,
const short *  taps 
)

Definition at line 104 of file AlgParts.h.

106 {
107  std::vector<short> filtered(input.size(), 0);
108  for(size_t i=0; i<input.size(); ++i){
109  for(size_t j=0; j<ntaps; ++j){
110  const size_t index=i>j ? i-j : 0;
111  filtered[i]+=input[index]*taps[j];
112  }
113  }
114  return filtered;
115 }
void do_frugal_update ( short &  median,
int &  runningDiff,
const short  sample,
const int  ncontig 
)

Definition at line 6 of file AlgParts.h.

7 {
8  if(sample>median) ++runningDiff;
9  if(sample<median) --runningDiff;
10 
11  if(runningDiff > ncontig){
12  ++median;
13  runningDiff=0;
14  }
15  if(runningDiff < -1*ncontig){
16  --median;
17  runningDiff=0;
18  }
19 }
double median(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:26
std::vector<short> frugal_iqr ( const std::vector< short > &  raw_in,
const std::vector< short > &  median,
const int  ncontig 
)

Definition at line 59 of file AlgParts.h.

62 {
63  std::vector<short> iqr(raw_in.size(), 0);
64 
65  int runningDiffLo=0;
66  int runningDiffHi=0;
67 
68  short quartileLo=median[0]-1;
69  short quartileHi=median[0]+1;
70 
71  for(size_t i=0; i<raw_in.size(); ++i){
72  short s=raw_in[i]; // The current sample
73  short m=median[i];
74 
75  if(s<m)
76  do_frugal_update(quartileLo, runningDiffLo, s, ncontig);
77  if(s>m)
78  do_frugal_update(quartileHi, runningDiffHi, s, ncontig);
79 
80  iqr[i]=quartileHi-quartileLo;
81  }
82 
83  return iqr;
84 }
void do_frugal_update(short &median, int &runningDiff, const short sample, const int ncontig)
Definition: AlgParts.h:6
static QCString * s
Definition: config.cpp:1042
std::vector<short> frugal_pedestal ( const std::vector< short > &  raw_in,
const int  ncontig 
)

Definition at line 86 of file AlgParts.h.

88 {
89  short median=raw_in[0];
90  std::vector<short> ped(raw_in.size(), 0);
91 
92  int runningDiff=0;
93  for(size_t i=0; i<raw_in.size(); ++i){
94  short s=raw_in[i]; // The current sample
95 
96  do_frugal_update(median, runningDiff, s, ncontig);
97 
98  ped[i]=median;
99  }
100 
101  return ped;
102 }
void do_frugal_update(short &median, int &runningDiff, const short sample, const int ncontig)
Definition: AlgParts.h:6
static QCString * s
Definition: config.cpp:1042
double median(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:26
std::vector<short> frugal_pedestal_sigkill ( const std::vector< short > &  raw_in,
const int  lookahead,
const int  threshold,
const int  ncontig 
)

Definition at line 21 of file AlgParts.h.

24 {
25  short median=raw_in[0];
26  std::vector<short> ped(raw_in.size(), 0);
27  int runningDiff=0;
28  // Are we updating the median (because we're not within a hit)?
29  bool updating=true;
30  for(size_t i=0; i<raw_in.size()-lookahead; ++i){
31  short s=raw_in[i]; // The current sample
32  short sig_cand=raw_in[i+lookahead]; // The sample a little way ahead
33  // Do we later go over the threshold?
34  bool cand_above=(sig_cand>median+threshold);
35  // Are we currently below the threshold?
36  bool current_below=(s<median+threshold);
37  // Is there an upcoming transition over threshold? If so, freeze the pedestal...
38  if(updating && cand_above){
39  updating=false;
40  }
41  // ...until we fall below the pedestal again
42  if( (!updating) && (current_below)){
43  updating=true;
44  }
45  // Do the frugal streaming if we're not in a hit
46  if(updating){
47  do_frugal_update(median, runningDiff, s, ncontig);
48  }
49  ped[i]=median;
50  }
51  // Get the last few samples, which we couldn't do in the main loop
52  // because we'd go out-of-bounds
53  for(size_t i=raw_in.size()-lookahead; i<raw_in.size(); ++i){
54  ped[i]=median;
55  }
56  return ped;
57 }
void do_frugal_update(short &median, int &runningDiff, const short sample, const int ncontig)
Definition: AlgParts.h:6
static QCString * s
Definition: config.cpp:1042
double median(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:26