Skip to content

Commit

Permalink
encourage use of spike_count instead of Spikecount
Browse files Browse the repository at this point in the history
  • Loading branch information
anilbey committed Jan 9, 2024
1 parent 2682494 commit 43bf8b3
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 48 deletions.
12 changes: 6 additions & 6 deletions docs/source/eFeatures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -150,20 +150,20 @@ time from stimulus start to last spike
else:
time_to_last_spike = 0

`Python efeature`_ : Spikecount
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
`Python efeature`_ : spike_count
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

number of spikes in the trace, including outside of stimulus interval

- **Required features**: LibV1:peak_indices
- **Units**: constant
- **Pseudocode**: ::

Spikecount = len(peak_indices)
spike_count = len(peak_indices)

**Note**: In the future this feature will be called "spike_count".

`Python efeature`_ : Spikecount_stimint
`Python efeature`_ : spike_count_stimint
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

number of spikes inside the stimulus interval
Expand All @@ -173,7 +173,7 @@ number of spikes inside the stimulus interval
- **Pseudocode**: ::

peaktimes_stimint = numpy.where((peak_time >= stim_start) & (peak_time <= stim_end))
Spikecount_stimint = len(peaktimes_stimint)
spike_count_stimint = len(peaktimes_stimint)

**Note**: In the future this feature will be called "spike_count_stimint".

Expand Down Expand Up @@ -1902,7 +1902,7 @@ Computes the impedance given a ZAP current input and its voltage response.
It will return the frequency at which the impedance is maximal, in the range (0, impedance_max_freq] Hz,
with impedance_max_freq being a setting with 50.0 as a default value.

- **Required features**: current, LibV1:Spikecount, LibV5:voltage_base, LibV5:current_base
- **Required features**: current, spike_count, LibV5:voltage_base, LibV5:current_base
- **Units**: Hz
- **Pseudocode**: ::

Expand Down
8 changes: 4 additions & 4 deletions docs/source/tex/efeatures.tex
Original file line number Diff line number Diff line change
Expand Up @@ -858,16 +858,16 @@ \section{Elementary features}
\end{efeature}

\begin{efeature}
{Spikecount}
{LibV1}
{Spikecount}
{spike_count}
{Python efeature}
{spike_count}
{none}
{peak indices\\&trace check}
{none}
{none}
{The number of peaks during stimulus}
{
APPEND length of peak\_indices TO Spikecount
APPEND length of peak\_indices TO spike_count
}
Yield the length of \myid{peak indices}.

Expand Down
4 changes: 2 additions & 2 deletions efel/units/units.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
"ISI_log_slope_skip": "ms",
"ISI_semilog_slope": "ms",
"ISI_values": "ms",
"Spikecount": "constant",
"Spikecount_stimint": "constant",
"spike_count": "constant",
"spike_count_stimint": "constant",
"adaptation_index": "constant",
"adaptation_index_2": "constant",
"all_ISI_values": "ms",
Expand Down
2 changes: 1 addition & 1 deletion examples/deap/GranuleCell1/GranuleCellDeap1-scoop.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from deap import tools

FEATURES = ['voltage_base',
'Spikecount',
'spike_count',
'min_voltage_between_spikes',
'steady_state_voltage_stimend']

Expand Down
2 changes: 1 addition & 1 deletion examples/deap/GranuleCell1/GranuleCellDeap1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"\n",
" result = efel.getFeatureValues(\n",
" traces, [\n",
" 'voltage_base', 'Spikecount', 'min_voltage_between_spikes', 'AP_height', 'steady_state_voltage_stimend'])\n",
" 'voltage_base', 'spike_count', 'min_voltage_between_spikes', 'AP_height', 'steady_state_voltage_stimend'])\n",
"\n",
" for feature_name, feature_list in result[0].items():\n",
" if feature_list is not None and len(feature_list) > 0:\n",
Expand Down
4 changes: 2 additions & 2 deletions tests/featurenames.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
"ISI_semilog_slope",
"ISI_values",
"ISIs",
"Spikecount",
"Spikecount_stimint",
"spike_count",
"spike_count_stimint",
"adaptation_index",
"adaptation_index2",
"all_ISI_values",
Expand Down
7 changes: 3 additions & 4 deletions tests/test_allfeatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,9 @@ def test_allfeatures():
"""allfeatures: Regression testing all features on a trace"""

feature_values = get_allfeature_values()
# drop spike_count and spike_count_stimint from feature values since they
# are the same as deprecated Spikecount and Spikecount_stimint
feature_values.pop('spike_count')
feature_values.pop('spike_count_stimint')
# drop Spikecount and Spikecount_stimint deprecated features
feature_values.pop('Spikecount')
feature_values.pop('Spikecount_stimint')
test_data_path = os.path.join(testdata_dir, 'expectedresults.json')
with open(test_data_path, 'r') as expected_json:
expected_results = json.load(expected_json)
Expand Down
50 changes: 25 additions & 25 deletions tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ def test_strict_stiminterval():
trace['stim_start'] = [stim_start]
trace['stim_end'] = [stim_end]

features = ['peak_indices', 'peak_time', 'Spikecount']
features = ['peak_indices', 'peak_time', 'spike_count']

feature_values = \
efel.getFeatureValues(
Expand All @@ -625,7 +625,7 @@ def test_strict_stiminterval():

peak_indices = feature_values[0]['peak_indices']
peak_time = feature_values[0]['peak_time']
spikecount = feature_values[0]['Spikecount']
spikecount = feature_values[0]['spike_count']
assert len(peak_indices) == n_of_spikes
assert len(peak_time) == n_of_spikes
assert spikecount == n_of_spikes
Expand Down Expand Up @@ -1132,7 +1132,7 @@ def test_getDistance_trace_check():
trace['stim_end'] = [70]
traces.append(trace)
numpy.testing.assert_allclose(
efel.getDistance(trace, 'Spikecount', 0, 1), 3.0
efel.getDistance(trace, 'spike_count', 0, 1), 3.0
)

trace['stim_end'] = [50]
Expand All @@ -1141,15 +1141,15 @@ def test_getDistance_trace_check():
numpy.testing.assert_allclose(
efel.getDistance(
trace,
'Spikecount',
'spike_count',
0,
1,
trace_check=False),
3.0)

efel.reset()
numpy.testing.assert_allclose(
efel.getDistance(trace, 'Spikecount', 0, 1), 250.0
efel.getDistance(trace, 'spike_count', 0, 1), 250.0
)


Expand Down Expand Up @@ -1261,8 +1261,8 @@ def test_derivwindow1():
numpy.testing.assert_allclose(AP_begin_voltage, -45.505521563640386)


def test_spikecount1():
"""basic: Test Spikecount 1"""
def test_spike_count1():
"""basic: Test spike_count 1"""

import efel
efel.reset()
Expand All @@ -1279,20 +1279,20 @@ def test_spikecount1():
trace['stim_start'] = [stim_start]
trace['stim_end'] = [stim_end]

features = ['peak_indices', 'Spikecount']
features = ['peak_indices', 'spike_count']

feature_values = \
efel.getFeatureValues(
[trace],
features)

peak_indices = feature_values[0]['peak_indices']
spikecount = feature_values[0]['Spikecount'][0]
spikecount = feature_values[0]['spike_count'][0]
assert len(peak_indices) == spikecount


def test_spikecount_stimint1():
"""basic: Test Spikecount_stimint 1."""
def test_spike_count_stimint1():
"""basic: Test spike_count_stimint 1."""
import efel
efel.reset()

Expand All @@ -1307,16 +1307,16 @@ def test_spikecount_stimint1():
trace['stim_start'] = [stim_start]
trace['stim_end'] = [stim_end]

features = ['peak_time', 'Spikecount_stimint', 'Spikecount']
features = ['peak_time', 'spike_count_stimint', 'spike_count']

feature_values = \
efel.getFeatureValues(
[trace],
features)

peak_times = feature_values[0]['peak_time']
spikecount = feature_values[0]['Spikecount'][0]
spikecount_stimint = feature_values[0]['Spikecount_stimint'][0]
spikecount = feature_values[0]['spike_count'][0]
spikecount_stimint = feature_values[0]['spike_count_stimint'][0]

interval_peaktimes, = \
numpy.where((peak_times >= stim_start) & (peak_times <= stim_end))
Expand Down Expand Up @@ -1610,8 +1610,8 @@ def test_ohmic_input_resistance_vb_ssse_zero_stimulus_current():
assert ohmic_input_resistance is None


def test_spikecount2():
"""basic: Test Spikecount 2: test empty trace"""
def test_spike_count2():
"""basic: Test spike_count 2: test empty trace"""

import efel
efel.reset()
Expand All @@ -1629,14 +1629,14 @@ def test_spikecount2():
trace['stim_start'] = [stim_start]
trace['stim_end'] = [stim_end]

features = ['Spikecount']
features = ['spike_count']

feature_values = \
efel.getFeatureValues(
[trace],
features)

spikecount = feature_values[0]['Spikecount'][0]
spikecount = feature_values[0]['spike_count'][0]
assert spikecount == 0


Expand Down Expand Up @@ -1712,7 +1712,7 @@ def test_getFeatureNames():
with open(test_data_path, 'r') as featurenames_json:
expected_featurenames = json.load(featurenames_json)
# add the new names for the deprecated ones
expected_featurenames += ["spike_count", "spike_count_stimint"]
expected_featurenames += ["Spikecount", "Spikecount_stimint"]
assert set(efel.getFeatureNames()) == set(expected_featurenames)


Expand Down Expand Up @@ -2038,7 +2038,7 @@ def test_mean_AP_amplitude():


def test_unfinished_peak():
"""basic: Test if unfinished peak doesn't break Spikecount"""
"""basic: Test if unfinished peak doesn't break spike_count"""

import efel
efel.setIntSetting('strict_stiminterval', True)
Expand All @@ -2055,17 +2055,17 @@ def test_unfinished_peak():
trace['stim_start'] = [10]
trace['stim_end'] = [70]

traces_results = efel.getFeatureValues([trace], ['Spikecount'])
spikecount = traces_results[0]['Spikecount'][0]
traces_results = efel.getFeatureValues([trace], ['spike_count'])
spikecount = traces_results[0]['spike_count'][0]

assert spikecount == 3

# When the signal at the end of the trace is larger than the threshold,
# Spikecount and possibly other features cannont be estimated.
# spike_count and possibly other features cannont be estimated.
v[int(80 / dt):] = -19

traces_results = efel.getFeatureValues([trace], ['Spikecount'])
spikecount = traces_results[0]['Spikecount'][0]
traces_results = efel.getFeatureValues([trace], ['spike_count'])
spikecount = traces_results[0]['spike_count'][0]

assert spikecount == 3

Expand Down
2 changes: 1 addition & 1 deletion tests/test_cppcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def test_getFeatureNames(self): # pylint: disable=R0201
with open(test_data_path, 'r') as featurenames_json:
expected_featurenames = json.load(featurenames_json)
# add the new names for the deprecated ones
expected_featurenames += ["spike_count", "spike_count_stimint"]
expected_featurenames += ["Spikecount", "Spikecount_stimint"]
assert set(feature_names) == set(expected_featurenames)

def test_getFeatureDouble_failure(self): # pylint: disable=R0201
Expand Down
4 changes: 2 additions & 2 deletions tests/testdata/allfeatures/expectedresults.json
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,10 @@
675.4999999993856,
250.29999999977235
],
"Spikecount": [
"spike_count": [
6
],
"Spikecount_stimint": [
"spike_count_stimint": [
6
],
"adaptation_index": [
Expand Down

0 comments on commit 43bf8b3

Please sign in to comment.