43 std::vector<int> averaged;
44 int up = signal.size()/UNIT;
45 int nticks = signal.size();
47 for(
int i=0;i<up;i++){
49 for(
int j=0;j<UNIT;j++){
50 temp += signal.at(i*UNIT+j);
52 averaged.push_back(temp);
55 auto imax = std::min_element(signal.begin(), signal.end());
56 double max_value = *imax;
57 if(max_value-baseline>1000) { CONTIN /=1.25; JUMPS *= 1.2; }
59 int NumberOfLedge = 0 ;
60 int StartOfLastLedgeCandidate = 0;
61 for(
int LE = 0; LE < 3; LE++){
62 if(LE>0 && StartOfLastLedgeCandidate == 0 )
break;
63 if(StartOfLastLedgeCandidate>nticks-200)
break;
64 if(NumberOfLedge>0 && (LedgeEnd[NumberOfLedge-1]+200)>
nticks)
break;
66 int decreaseD = 0, tolerence=0;
69 if(StartOfLastLedgeCandidate==0) {
73 if(NumberOfLedge == 0)
74 StartWindow = (StartOfLastLedgeCandidate+200)/UNIT;
76 if(StartOfLastLedgeCandidate>LedgeEnd[NumberOfLedge-1])
78 StartWindow = (StartOfLastLedgeCandidate+50)/UNIT;
80 StartWindow = (LedgeEnd[NumberOfLedge-1]+30)/UNIT;
83 for(
int i=StartWindow+1;i<up-1;i++){
84 if(averaged.at(i)<averaged.at(i-1)) {
85 if(decreaseD==0) start = i;
89 if(averaged.at(i+1)<averaged.at(i-1)&&tolerence<JUMPS&&decreaseD>0){
97 StartOfLastLedgeCandidate = start*UNIT;
125 int tempLedgeEnd = 0;
127 for(
int i = StartOfLastLedgeCandidate/UNIT; i<up-1; i++){
128 if(averaged.at(i+1)-averaged.at(i)>5*UNIT) {
129 tempLedgeEnd = i*UNIT+5;
130 if(tempLedgeEnd>nticks) tempLedgeEnd = nticks-1;
135 if(tempLedgeEnd == 0) {
137 for(
int i = StartOfLastLedgeCandidate+80;i<nticks-20;i+=20){
138 for(
int j=i;j<20+i;j++){
139 tempA.at(j-i) = signal.at(j);
142 if(
stat.first-baseline<2&&stat.second>3){
148 if(tempLedgeEnd == 0) tempLedgeEnd = nticks-1;
153 double height = signal.at(StartOfLastLedgeCandidate+1)- signal.at(tempLedgeEnd);
154 if(height<0) ledge = 0;
155 if((tempLedgeEnd-StartOfLastLedgeCandidate) > 80){
157 height50 = signal.at(StartOfLastLedgeCandidate+51);
158 double height50Pre = signal.at(StartOfLastLedgeCandidate+1)- height*(1-exp(-50/100.));
160 if(height50-height50Pre<-12) ledge = 0;
183 if(averaged.at(tempLedgeEnd/UNIT)-baseline*UNIT>5.*UNIT) ledge = 0;
185 if(averaged.at(StartOfLastLedgeCandidate/UNIT)-baseline*UNIT>100*UNIT) ledge = 0;
188 if(ledge==1 && StartOfLastLedgeCandidate>1000){
191 for(
int i=StartOfLastLedgeCandidate-1000; i<StartOfLastLedgeCandidate-100; i++){
192 if(signal.at(i)>hmax) hmax= signal.at(i);
194 if(hmax-baseline<200) ledge=0;
200 LedgeStart[NumberOfLedge] =
std::max(StartOfLastLedgeCandidate-20, 0);
201 LedgeEnd[NumberOfLedge] =
std::min(tempLedgeEnd+10, (
int)signal.size());
206 return NumberOfLedge;
static int max(int a, int b)
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)