diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8af2a86a..9f3f8e00 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,10 +5,15 @@ All notable changes to this project will be documented in this file. The format is based on `Keep a Changelog `_, and this project adheres to `Semantic Versioning `_. +5.6.29 - 2024-06 +---------------- + +- Added AP_phaseslope_range to efel.settings as int with default value of 2 + 5.6.27 - 2024-05 ---------------- -- FIxed edge case (1 spike and no min_AHP_indices dependency) in AP_begin_indices +- Fixed edge case (1 spike and no min_AHP_indices dependency) in AP_begin_indices 5.6.20 - 2024-05 ---------------- diff --git a/docs/source/eFeatures.rst b/docs/source/eFeatures.rst index 39f00d26..d9f31a32 100644 --- a/docs/source/eFeatures.rst +++ b/docs/source/eFeatures.rst @@ -1549,7 +1549,7 @@ AP_phaseslope (at the point where the derivative crosses the DerivativeThreshold) - **Required features**: AP_begin_indices -- **Parameters**: AP_phaseslope_range +- **Parameters**: AP_phaseslope_range (default=2) - **Units**: 1/(ms) - **Pseudocode**: :: diff --git a/efel/cppcore/SpikeShape.cpp b/efel/cppcore/SpikeShape.cpp index 3b7605b4..06102aa5 100644 --- a/efel/cppcore/SpikeShape.cpp +++ b/efel/cppcore/SpikeShape.cpp @@ -2279,7 +2279,7 @@ int SpikeShape::AP_fall_rate_change(mapStr2intVec& IntFeatureData, static int __AP_phaseslope(const vector& v, const vector& t, double stimStart, double stimEnd, vector& ap_phaseslopes, vector apbi, - double range) { + int range) { vector dvdt(v.size()); vector dv; vector dt; @@ -2292,8 +2292,8 @@ static int __AP_phaseslope(const vector& v, const vector& t, for (size_t i = 0; i < apbi.size(); i++) { apbegin_index = apbi[i]; - range_min_index = apbegin_index - int(range); - range_max_index = apbegin_index + int(range); + range_min_index = apbegin_index - range; + range_max_index = apbegin_index + range; if (range_min_index < 0 || range_max_index < 0) return -1; if (range_min_index > (int)t.size() || range_max_index > (int)t.size()) return -1; @@ -2316,14 +2316,16 @@ int SpikeShape::AP_phaseslope(mapStr2intVec& IntFeatureData, mapStr2Str& StringData) { const auto& doubleFeatures = getFeatures(DoubleFeatureData, - {"V", "T", "stim_start", "stim_end", "AP_phaseslope_range"}); - const auto& intFeatures = getFeatures(IntFeatureData, {"AP_begin_indices"}); + {"V", "T", "stim_start", "stim_end"}); + const auto& intFeatures = + getFeatures(IntFeatureData, + {"AP_begin_indices", "AP_phaseslope_range"}); vector ap_phaseslopes; int retVal = __AP_phaseslope(doubleFeatures.at("V"), doubleFeatures.at("T"), doubleFeatures.at("stim_start")[0], doubleFeatures.at("stim_end")[0], ap_phaseslopes, intFeatures.at("AP_begin_indices"), - doubleFeatures.at("AP_phaseslope_range")[0]); + intFeatures.at("AP_phaseslope_range")[0]); if (retVal > 0) { setVec(DoubleFeatureData, StringData, "AP_phaseslope", ap_phaseslopes); diff --git a/efel/settings.py b/efel/settings.py index 295f5275..7751f347 100644 --- a/efel/settings.py +++ b/efel/settings.py @@ -98,6 +98,7 @@ class Settings: sahp_start: float = 5.0 ignore_first_ISI: bool = True impedance_max_freq: float = 50.0 + AP_phaseslope_range: int = 2 def set_setting(self, setting_name: str, diff --git a/tests/test_settings.py b/tests/test_settings.py index d4d71037..8c8626ab 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -161,6 +161,7 @@ def test_str_method(): "precision_threshold: 1e-10\n" "sahp_start: 5.0\n" "ignore_first_ISI: True\n" - "impedance_max_freq: 50.0" + "impedance_max_freq: 50.0\n" + "AP_phaseslope_range: 2" ) assert str(settings) == expected_output diff --git a/tests/testdata/allfeatures/expectedresults.json b/tests/testdata/allfeatures/expectedresults.json index bb6e0145..69a0f2b8 100644 --- a/tests/testdata/allfeatures/expectedresults.json +++ b/tests/testdata/allfeatures/expectedresults.json @@ -280,7 +280,14 @@ 40.51507371451861, 40.98143755958056 ], - "AP_phaseslope": null, + "AP_phaseslope": [ + 8.368063428797635, + 8.205484762938424, + 5.729511888356036, + 5.224282360605566, + 3.887601463053442, + 4.872345425348057 + ], "AP_rise_indices": [ 7074, 9104,