From d3a726fe5058d5f375a3789ca5dd1fec24c67302 Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Thu, 19 Oct 2023 11:34:27 +0200 Subject: [PATCH] using std::find_if in LibV5 --- efel/cppcore/LibV5.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/efel/cppcore/LibV5.cpp b/efel/cppcore/LibV5.cpp index 69850015..fdb0b44d 100644 --- a/efel/cppcore/LibV5.cpp +++ b/efel/cppcore/LibV5.cpp @@ -27,6 +27,7 @@ #include using std::distance; +using std::find_if; // slope of loglog of ISI curve @@ -580,7 +581,7 @@ static int __AP_begin_indices(const vector& t, const vector& v, // restrict to time interval where stimulus is applied vector minima, peak_indices; auto stimbeginindex = distance(t.begin(), - std::find_if(t.begin(), t.end(), + find_if(t.begin(), t.end(), [stimstart](double time){ return time >= stimstart; })); if (stimbeginindex > 1){ @@ -732,7 +733,7 @@ static int __AP_end_indices(const vector& t, const vector& v, // assure that the width of the slope is bigger than 4 apei[i] = distance( dvdt.begin(), - std::find_if(dvdt.begin() + max_slope, dvdt.begin() + picopy[i + 1], + find_if(dvdt.begin() + max_slope, dvdt.begin() + picopy[i + 1], [derivativethreshold](double x){ return x >= derivativethreshold; })); } return apei.size(); @@ -1195,7 +1196,7 @@ static int __AP_begin_width(const vector& t, const vector& v, // because AP_begin_indices are all after stim start // if not done, could cause cases where AP_begin_indices[i] > min_ahp_indices[i] // leading to segmentation faults - auto it = std::find_if(t.begin(), t.end(), [stimstart](double val) { + auto it = find_if(t.begin(), t.end(), [stimstart](double val) { return val >= stimstart; }); int stimbeginindex = distance(t.begin(), it); @@ -2404,7 +2405,7 @@ static int __sag_time_constant(const vector& times, // get start index const size_t decayStartIdx = distance(voltage.begin(), - std::find_if(voltage.begin(), voltage.end(), + find_if(voltage.begin(), voltage.end(), [minimum_voltage](double v){ return v <= minimum_voltage; })); @@ -2413,7 +2414,7 @@ static int __sag_time_constant(const vector& times, // get end index const size_t decayEndIdx = distance(voltage.begin(), - std::find_if(voltage.begin() + decayStartIdx, voltage.end(), + find_if(voltage.begin() + decayStartIdx, voltage.end(), [steady_state_90](double v){ return v >= steady_state_90; })); // voltage reference by which the voltage (i the decay interval)