Skip to content

Commit

Permalink
Merge pull request #352 from AurelienJaquier/dend-validation-features
Browse files Browse the repository at this point in the history
New feature: phaseslope_max
  • Loading branch information
AurelienJaquier authored Jan 17, 2024
2 parents 160db25 + ebfeae7 commit 6b185cb
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ 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.5.4] - 2024-01

- New feature: phaseslope_max

## [5.5.3] - 2024-01

- Add type stub for cppcore module to make Python recognise the C++ functions' arguments and return values.
Expand Down
13 changes: 13 additions & 0 deletions docs/source/eFeatures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1926,6 +1926,19 @@ with impedance_max_freq being a setting with 50.0 as a default value.
else:
return None

`Python efeature`_ : phaseslope_max
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Computes the maximum of the phase slope.
Attention, this feature is sensitive to interpolation timestep.

- **Required features**: time, voltage
- **Units**: V/s
- **Pseudocode**: ::

phaseslope = numpy.diff(voltage) / numpy.diff(time)
phaseslope_max = numpy.array([numpy.max(phaseslope)])



.. _LibV1: https://github.com/BlueBrain/eFEL/blob/master/efel/cppcore/LibV1.cpp
Expand Down
19 changes: 18 additions & 1 deletion efel/pyfeatures/pyfeatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
'impedance',
'burst_number',
'strict_burst_number',
'trace_check'
'trace_check',
'phaseslope_max',
]


Expand Down Expand Up @@ -424,6 +425,22 @@ def spikes_in_burst1_burstlast_diff():
])


def phaseslope_max():
"""Calculate the maximum phase slope"""

voltage = get_cpp_feature("voltage")
time = get_cpp_feature("time")
time = time[:len(voltage)]

from numpy import diff

phaseslope = diff(voltage) / diff(time)
try:
return numpy.array([numpy.max(phaseslope)])
except ValueError:
return None


def get_cpp_feature(featureName, raise_warnings=None):
"""Return value of feature implemented in cpp"""
cppcoreFeatureValues = list()
Expand Down
3 changes: 2 additions & 1 deletion efel/units/units.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,6 @@
"initburst_sahp_ssse": "mV",
"initburst_sahp_vb": "mV",
"depol_block_bool": "constant",
"impedance": "Hz"
"impedance": "Hz",
"phaseslope_max": "V/s"
}
3 changes: 2 additions & 1 deletion tests/featurenames.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,6 @@
"postburst_min_indices",
"postburst_min_values",
"time_to_interburst_min",
"AHP_depth_slow"
"AHP_depth_slow",
"phaseslope_max"
]
2 changes: 1 addition & 1 deletion tests/test_allfeatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def test_allfeatures_on_constant_voltage():
"voltage_deflection", "voltage_deflection_begin", "voltage_deflection_vb_ssse",
"depol_block", "depol_block_bool", "voltage_base", "Spikecount",
"Spikecount_stimint", "burst_number", "strict_burst_number", "trace_check",
"spike_count", "spike_count_stimint"
"spike_count", "spike_count_stimint", "phaseslope_max"
]

for field in array_fields:
Expand Down
10 changes: 10 additions & 0 deletions tests/test_pyfeatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,3 +326,13 @@ def test_trace_check():
mf1_trace["V"] = [0] * len(mf1_trace["V"])
feature_values = efel.getFeatureValues([mf1_trace], ['trace_check'])
assert feature_values[0]['trace_check'][0] == 0


def test_phaseslope_max():
"""Unit test for phaseslope_max."""
expected_values = {
"mean_frequency1": 574.86769012,
"depol_block_spiking": 93.51242208,
"depol_block_db": 180.7325033,
}
_test_expected_value("phaseslope_max", expected_values)
3 changes: 2 additions & 1 deletion tests/testdata/allfeatures/expectedresults.json
Original file line number Diff line number Diff line change
Expand Up @@ -60639,5 +60639,6 @@
32.02907786238346,
32.65404519917785,
33.435288866699345
]
],
"phaseslope_max": [111.6276337625179]
}

0 comments on commit 6b185cb

Please sign in to comment.