Skip to content

Commit

Permalink
Update deps: efel5*, pytest 8, python38+ vcs: #minor (#103)
Browse files Browse the repository at this point in the history
* allow efel 5.*

* pytest remove nose style setup func

* replace Spikecount->spike_count

* drop py37

* formatting

* format tests dir

* fix error in feature names
  • Loading branch information
anilbey committed Feb 7, 2024
1 parent 95afd0e commit 3f7ef23
Show file tree
Hide file tree
Showing 15 changed files with 116 additions and 113 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Expand Up @@ -102,7 +102,7 @@ Dependencies

The main dependencies of EModelRunner are::

Python3.7+
Python3.8+
Matplotlib
Numpy
Neurom
Expand All @@ -117,7 +117,7 @@ pre-installed versions.
Python
------

Modern Linux systems will have Python 2.7 or 3 installed. Make sure that your python version is 3.7 or higher.
Modern Linux systems will have Python installed. Make sure that your python version is 3.8 or higher.

Make sure you're using a recent version of pip. It's best to run ::

Expand Down
1 change: 1 addition & 0 deletions emodelrunner/factsheets/units.py
@@ -1,4 +1,5 @@
"""Contains the units of the features used in factsheets."""

from types import MappingProxyType
from efel.units import _units as efel_units

Expand Down
12 changes: 6 additions & 6 deletions emodelrunner/load.py
Expand Up @@ -176,12 +176,12 @@ def load_unoptimized_parameters(params_path, v_init, celsius):
dist_param_names = definition["parameters"]
else:
dist_param_names = None
distributions[
distribution
] = ephys.parameterscalers.NrnSegmentSomaDistanceScaler(
name=distribution,
distribution=definition["fun"],
dist_param_names=dist_param_names,
distributions[distribution] = (
ephys.parameterscalers.NrnSegmentSomaDistanceScaler(
name=distribution,
distribution=definition["fun"],
dist_param_names=dist_param_names,
)
)

params_definitions = definitions["parameters"]
Expand Down
140 changes: 72 additions & 68 deletions emodelrunner/protocols/reader.py
Expand Up @@ -102,17 +102,17 @@ def _parse_step_and_ramp(
def _parse_sscx_threshold_detection(self, protocol_definition, recordings, prefix):
"""Parses the sscx threshold detection protocol into self.protocols_dict."""
if protocol_definition["type"] == "RatSSCxThresholdDetectionProtocol":
self.protocols_dict[
"ThresholdDetection"
] = sscx_protocols.RatSSCxThresholdDetectionProtocol(
"IDRest",
step_protocol_template=read_step_protocol(
"Threshold",
sscx_protocols,
protocol_definition["step_template"],
recordings,
),
prefix=prefix,
self.protocols_dict["ThresholdDetection"] = (
sscx_protocols.RatSSCxThresholdDetectionProtocol(
"IDRest",
step_protocol_template=read_step_protocol(
"Threshold",
sscx_protocols,
protocol_definition["step_template"],
recordings,
),
prefix=prefix,
)
)

def _parse_thalamus_threshold_detection(
Expand All @@ -121,30 +121,30 @@ def _parse_thalamus_threshold_detection(
"""Parses the thalamus threshold detection protocol into self.protocols_dict."""
if protocol_definition["type"] == "RatSSCxThresholdDetectionProtocol":
if protocol_name == "ThresholdDetection_dep":
self.protocols_dict[
"ThresholdDetection_dep"
] = thalamus_protocols.RatSSCxThresholdDetectionProtocol(
"ThresholdDetection_dep",
step_protocol_template=read_step_protocol(
self.protocols_dict["ThresholdDetection_dep"] = (
thalamus_protocols.RatSSCxThresholdDetectionProtocol(
"ThresholdDetection_dep",
thalamus_protocols,
protocol_definition["step_template"],
recordings,
),
prefix=prefix,
step_protocol_template=read_step_protocol(
"ThresholdDetection_dep",
thalamus_protocols,
protocol_definition["step_template"],
recordings,
),
prefix=prefix,
)
)
elif protocol_name == "ThresholdDetection_hyp":
self.protocols_dict[
"ThresholdDetection_hyp"
] = thalamus_protocols.RatSSCxThresholdDetectionProtocol(
"ThresholdDetection_hyp",
step_protocol_template=read_step_protocol(
self.protocols_dict["ThresholdDetection_hyp"] = (
thalamus_protocols.RatSSCxThresholdDetectionProtocol(
"ThresholdDetection_hyp",
thalamus_protocols,
protocol_definition["step_template"],
recordings,
),
prefix=prefix,
step_protocol_template=read_step_protocol(
"ThresholdDetection_hyp",
thalamus_protocols,
protocol_definition["step_template"],
recordings,
),
prefix=prefix,
)
)

def _parse_vecstim_netstim(
Expand All @@ -162,14 +162,18 @@ def _parse_vecstim_netstim(

def _parse_sscx_main(self, protocol_definitions, prefix):
"""Parses the main sscx protocol into self.protocols_dict."""
self.protocols_dict[
"RinHoldcurrent"
] = sscx_protocols.RatSSCxRinHoldcurrentProtocol(
"RinHoldCurrent",
rin_protocol_template=self.protocols_dict["Rin"],
holdi_precision=protocol_definitions["RinHoldcurrent"]["holdi_precision"],
holdi_max_depth=protocol_definitions["RinHoldcurrent"]["holdi_max_depth"],
prefix=prefix,
self.protocols_dict["RinHoldcurrent"] = (
sscx_protocols.RatSSCxRinHoldcurrentProtocol(
"RinHoldCurrent",
rin_protocol_template=self.protocols_dict["Rin"],
holdi_precision=protocol_definitions["RinHoldcurrent"][
"holdi_precision"
],
holdi_max_depth=protocol_definitions["RinHoldcurrent"][
"holdi_max_depth"
],
prefix=prefix,
)
)

other_protocols = []
Expand All @@ -196,43 +200,43 @@ def _parse_sscx_main(self, protocol_definitions, prefix):
def _parse_thalamus_main(self, protocol_definitions, prefix):
"""Parses the main thalamus protocol into self.protocols_dict."""
try: # Only low-threshold bursting cells have thin protocol
self.protocols_dict[
"RinHoldcurrent_dep"
] = thalamus_protocols.RatSSCxRinHoldcurrentProtocol(
"RinHoldcurrent_dep",
rin_protocol_template=self.protocols_dict["Rin_dep"],
holdi_estimate_multiplier=protocol_definitions["RinHoldcurrent_dep"][
self.protocols_dict["RinHoldcurrent_dep"] = (
thalamus_protocols.RatSSCxRinHoldcurrentProtocol(
"RinHoldcurrent_dep",
rin_protocol_template=self.protocols_dict["Rin_dep"],
holdi_estimate_multiplier=protocol_definitions[
"RinHoldcurrent_dep"
]["holdi_estimate_multiplier"],
holdi_precision=protocol_definitions["RinHoldcurrent_dep"][
"holdi_precision"
],
holdi_max_depth=protocol_definitions["RinHoldcurrent_dep"][
"holdi_max_depth"
],
prefix=prefix,
)
)
rinhold_protocol_dep = self.protocols_dict["RinHoldcurrent_dep"]
thdetect_protocol_dep = self.protocols_dict["ThresholdDetection_dep"]
except KeyError:
rinhold_protocol_dep = None
thdetect_protocol_dep = None

self.protocols_dict["RinHoldcurrent_hyp"] = (
thalamus_protocols.RatSSCxRinHoldcurrentProtocol(
"RinHoldcurrent_hyp",
rin_protocol_template=self.protocols_dict["Rin_hyp"],
holdi_estimate_multiplier=protocol_definitions["RinHoldcurrent_hyp"][
"holdi_estimate_multiplier"
],
holdi_precision=protocol_definitions["RinHoldcurrent_dep"][
holdi_precision=protocol_definitions["RinHoldcurrent_hyp"][
"holdi_precision"
],
holdi_max_depth=protocol_definitions["RinHoldcurrent_dep"][
holdi_max_depth=protocol_definitions["RinHoldcurrent_hyp"][
"holdi_max_depth"
],
prefix=prefix,
)
rinhold_protocol_dep = self.protocols_dict["RinHoldcurrent_dep"]
thdetect_protocol_dep = self.protocols_dict["ThresholdDetection_dep"]
except KeyError:
rinhold_protocol_dep = None
thdetect_protocol_dep = None

self.protocols_dict[
"RinHoldcurrent_hyp"
] = thalamus_protocols.RatSSCxRinHoldcurrentProtocol(
"RinHoldcurrent_hyp",
rin_protocol_template=self.protocols_dict["Rin_hyp"],
holdi_estimate_multiplier=protocol_definitions["RinHoldcurrent_hyp"][
"holdi_estimate_multiplier"
],
holdi_precision=protocol_definitions["RinHoldcurrent_hyp"][
"holdi_precision"
],
holdi_max_depth=protocol_definitions["RinHoldcurrent_hyp"][
"holdi_max_depth"
],
prefix=prefix,
)

other_protocols = [
Expand Down
20 changes: 12 additions & 8 deletions emodelrunner/protocols/sscx_protocols.py
Expand Up @@ -657,8 +657,8 @@ def detect_spike(
response = protocol.run(cell_model, param_values, sim=sim)

feature = ephys.efeatures.eFELFeature(
name="ThresholdDetection.Spikecount",
efel_feature_name="Spikecount",
name="ThresholdDetection.spike_count",
efel_feature_name="spike_count",
recording_names={"": self.prefix + "ThresholdDetection.soma.v"},
stim_start=protocol.stim_start,
stim_end=protocol.stim_end,
Expand Down Expand Up @@ -792,9 +792,11 @@ def __init__(
"""
super().__init__(
name,
stimuli=step_stimuli + [holding_stimulus]
if holding_stimulus is not None
else step_stimuli,
stimuli=(
step_stimuli + [holding_stimulus]
if holding_stimulus is not None
else step_stimuli
),
recordings=recordings,
cvode_active=cvode_active,
)
Expand Down Expand Up @@ -1099,9 +1101,11 @@ def __init__(
"""
super().__init__(
name,
stimuli=[ramp_stimulus, holding_stimulus]
if holding_stimulus is not None
else [ramp_stimulus],
stimuli=(
[ramp_stimulus, holding_stimulus]
if holding_stimulus is not None
else [ramp_stimulus]
),
recordings=recordings,
cvode_active=cvode_active,
)
Expand Down
8 changes: 4 additions & 4 deletions emodelrunner/protocols/thalamus_protocols.py
Expand Up @@ -690,8 +690,8 @@ def detect_spike(

if self.name.endswith("_dep"):
feature = ephys.efeatures.eFELFeature(
name="ThresholdDetection_dep.Spikecount",
efel_feature_name="Spikecount_stimint",
name="ThresholdDetection_dep.spike_count",
efel_feature_name="spike_count_stimint",
recording_names={"": self.prefix + "ThresholdDetection_dep.soma.v"},
stim_start=protocol.step_delay,
stim_end=protocol.step_delay + protocol.step_duration,
Expand All @@ -701,8 +701,8 @@ def detect_spike(

elif self.name.endswith("_hyp"):
feature = ephys.efeatures.eFELFeature(
name="ThresholdDetection_hyp.Spikecount",
efel_feature_name="Spikecount_stimint",
name="ThresholdDetection_hyp.spike_count",
efel_feature_name="spike_count_stimint",
recording_names={"": self.prefix + "ThresholdDetection_hyp.soma.v"},
stim_start=protocol.step_delay,
stim_end=protocol.step_delay + protocol.step_duration,
Expand Down
4 changes: 2 additions & 2 deletions examples/sscx_sample_dir/config/features/cADpyr_L4PC.json
@@ -1,7 +1,7 @@
{
"bAP": {
"soma.v": [
{"feature": "Spikecount", "val": [1.0, 0.01]}
{"feature": "spike_count", "val": [1.0, 0.01]}
],
"dend1.v": [
{"feature": "maximum_voltage_from_voltagebase", "val": [81.329833, 7.018952], "weight": 1, "__comment": "Stuart and Sakmann 1994"}
Expand Down Expand Up @@ -94,7 +94,7 @@
"RMP": {
"soma.v": [
{"feature": "voltage_base", "val": [-73.9134, 1.6714, -4.817202527918724, 0.027690237877764368, 1.9500000000000002, 0], "n": 2, "fid": 288, "strict_stim": true, "__comment": {"source": "cADpyr/L4PC", "meta": {"version": "aca7043"}}},
{"feature": "Spikecount", "val": [0.0, 0.001, 0.0, 0.001, -3.0, 0], "n": 2, "fid": 308, "strict_stim": true, "__comment": {"source": "cADpyr/L4PC", "meta": {"version": "aca7043"}}}
{"feature": "spike_count", "val": [0.0, 0.001, 0.0, 0.001, -3.0, 0], "n": 2, "fid": 308, "strict_stim": true, "__comment": {"source": "cADpyr/L4PC", "meta": {"version": "aca7043"}}}
]
},
"IV_-100": {
Expand Down
4 changes: 2 additions & 2 deletions examples/sscx_sample_dir/config/params/final.json
Expand Up @@ -65,7 +65,7 @@
"_.Step_140.soma.v.inv_second_ISI": 0.12459028529028007,
"_.bAP.dend1.v.maximum_voltage_from_voltagebase": 0.6002072733124426,
"_.bAP.ca_prox_basal.cai.maximum_voltage_from_voltagebase": 4.200408804664744,
"_.bAP.soma.v.Spikecount": 0,
"_.bAP.soma.v.spike_count": 0,
"_.Step_140.soma.v.voltage_after_stim": 1.9994617502528271,
"_.SpikeRec_all.soma.v.decay_time_constant_after_stim": 0.10085645832784906,
"_.Step_280.soma.v.inv_fourth_ISI": 1.0352480907823978,
Expand All @@ -79,7 +79,7 @@
"_.APWaveform_360.soma.v.AP2_amp": 1.2849194517061855,
"_.Step_140.soma.v.voltage_base": 4.375568090259795,
"_.Step_280.soma.v.inv_time_to_first_spike": 0.31328662092696996,
"_.RMP.soma.v.Spikecount": 0,
"_.RMP.soma.v.spike_count": 0,
"_.bAP.dend2.v.maximum_voltage_from_voltagebase": 1.8354820176163507,
"_.Step_200.soma.v.AHP_depth": 1.7706451237580105,
"_.Step_200.soma.v.time_to_last_spike": 0.3030673891317257,
Expand Down
8 changes: 4 additions & 4 deletions examples/synplas_sample_dir/config/params/final.json
Expand Up @@ -65,7 +65,7 @@
"_.Step_140.soma.v.inv_second_ISI": 0.12459028529028007,
"_.bAP.dend1.v.maximum_voltage_from_voltagebase": 0.6002072733124426,
"_.bAP.ca_prox_basal.cai.maximum_voltage_from_voltagebase": 4.200408804664744,
"_.bAP.soma.v.Spikecount": 0,
"_.bAP.soma.v.spike_count": 0,
"_.Step_140.soma.v.voltage_after_stim": 1.9994617502528271,
"_.SpikeRec_all.soma.v.decay_time_constant_after_stim": 0.10085645832784906,
"_.Step_280.soma.v.inv_fourth_ISI": 1.0352480907823978,
Expand All @@ -79,7 +79,7 @@
"_.APWaveform_360.soma.v.AP2_amp": 1.2849194517061855,
"_.Step_140.soma.v.voltage_base": 4.375568090259795,
"_.Step_280.soma.v.inv_time_to_first_spike": 0.31328662092696996,
"_.RMP.soma.v.Spikecount": 0,
"_.RMP.soma.v.spike_count": 0,
"_.bAP.dend2.v.maximum_voltage_from_voltagebase": 1.8354820176163507,
"_.Step_200.soma.v.AHP_depth": 1.7706451237580105,
"_.Step_200.soma.v.time_to_last_spike": 0.3030673891317257,
Expand Down Expand Up @@ -173,7 +173,7 @@
"_.Step_140.soma.v.inv_second_ISI": 0.11491646526546874,
"_.bAP.dend1.v.maximum_voltage_from_voltagebase": 0.3933547355204061,
"_.bAP.ca_prox_basal.cai.maximum_voltage_from_voltagebase": 0.5317743149017081,
"_.bAP.soma.v.Spikecount": 0,
"_.bAP.soma.v.spike_count": 0,
"_.Step_140.soma.v.voltage_after_stim": 2.068875307329713,
"_.SpikeRec_all.soma.v.decay_time_constant_after_stim": 0.12010551765357895,
"_.Step_280.soma.v.inv_fourth_ISI": 0.7202659800227095,
Expand All @@ -187,7 +187,7 @@
"_.APWaveform_360.soma.v.AP2_amp": 0.4910291906341208,
"_.Step_140.soma.v.voltage_base": 4.344090204362258,
"_.Step_280.soma.v.inv_time_to_first_spike": 0.4962190069156973,
"_.RMP.soma.v.Spikecount": 0,
"_.RMP.soma.v.spike_count": 0,
"_.bAP.dend2.v.maximum_voltage_from_voltagebase": 1.186952930680964,
"_.Step_200.soma.v.AHP_depth": 1.5876494345794483,
"_.Step_200.soma.v.time_to_last_spike": 0.8317664467168655,
Expand Down

0 comments on commit 3f7ef23

Please sign in to comment.