Skip to content

Commit

Permalink
#320 working on noise level
Browse files Browse the repository at this point in the history
  • Loading branch information
FloCiaglia committed Oct 23, 2019
1 parent 969f1b2 commit 2646466
Show file tree
Hide file tree
Showing 2 changed files with 1,331 additions and 443 deletions.
38 changes: 19 additions & 19 deletions src/GaussianFitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,24 +665,24 @@ int GaussianFitter::guess_peaks(std::vector<Peak*>* results,
int grad = -1;
for(int i = 0; i<(int)ampData.size()-1; i++){

if(ampData[i] > noise_level){
// were we sloping up before?
if (grad == 1){
// sloping down
if(ampData[i+1] < ampData[i]){
// were we sloping up before?
if (grad == 1){
// sloping down
if(ampData[i+1] < ampData[i]){
if(ampData[i]>=noise_level){
//record the peak
peak_guesses_loc.push_back(i);
//now we are sloping down
grad = -1;
}
//Peak location
// previously decreasing
}else if(grad == -1){
if(ampData[i+1] > ampData[i]){
//sloping up
grad = 1;
}
}
//now we are sloping down
grad = -1;
}
//Peak location
// previously decreasing
}else if(grad == -1){
if(ampData[i+1] > ampData[i]){
//sloping up
grad = 1;
}
}
}

Expand All @@ -696,8 +696,8 @@ int GaussianFitter::guess_peaks(std::vector<Peak*>* results,
int peaks_found=0;
for(int i=0; i< peakCount; i++){
// Create a better guess by using a better width
int guess = -1; // "guess" represents our guess of the width value.
int half_ampData_guess = ampData[peak_guesses_loc[i]]/2;
float guess = -1; // "guess" represents our guess of the width value.
float half_ampData_guess = ampData[peak_guesses_loc[i]]/2.;
int idx_lo=0,idx_hi=0;
// look low
int prev = ampData[peak_guesses_loc[i]];
Expand All @@ -708,7 +708,7 @@ int GaussianFitter::guess_peaks(std::vector<Peak*>* results,
prev = ampData[j];
if(ampData[j] < half_ampData_guess){
idx_lo = j;
guess = (idxData[peak_guesses_loc[i]] - j -1);
guess = (idxData[peak_guesses_loc[i]] - j -1)+.5;
break;
}
}
Expand All @@ -722,7 +722,7 @@ int GaussianFitter::guess_peaks(std::vector<Peak*>* results,
prev = ampData[j];
if(ampData[j] < half_ampData_guess){
idx_hi = j;
guess = (j-idxData[peak_guesses_loc[i]] -1);
guess = (j-idxData[peak_guesses_loc[i]] -1)-.5;
break;
}
}
Expand Down
Loading

0 comments on commit 2646466

Please sign in to comment.