Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ap phaseslope range #400

Merged
merged 5 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on `Keep a Changelog <https://keepachangelog.com/en/1.0.0/>`_,
and this project adheres to `Semantic Versioning <https://semver.org/spec/v2.0.0.html>`_.

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
----------------
Expand Down
2 changes: 1 addition & 1 deletion docs/source/eFeatures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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**: ::

Expand Down
14 changes: 8 additions & 6 deletions efel/cppcore/SpikeShape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2279,7 +2279,7 @@ int SpikeShape::AP_fall_rate_change(mapStr2intVec& IntFeatureData,
static int __AP_phaseslope(const vector<double>& v, const vector<double>& t,
double stimStart, double stimEnd,
vector<double>& ap_phaseslopes, vector<int> apbi,
double range) {
int range) {
vector<double> dvdt(v.size());
vector<double> dv;
vector<double> dt;
Expand All @@ -2292,8 +2292,8 @@ static int __AP_phaseslope(const vector<double>& v, const vector<double>& 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;
Expand All @@ -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<double> 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);
Expand Down
1 change: 1 addition & 0 deletions efel/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 8 additions & 1 deletion tests/testdata/allfeatures/expectedresults.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down