Skip to content

Commit

Permalink
Merge pull request #108 from BlueBrain/bpo-update
Browse files Browse the repository at this point in the history
Update replace_axon functions to be compatible with latest BPO
  • Loading branch information
AurelienJaquier authored Oct 2, 2024
2 parents 2da372c + 8f405eb commit b07220d
Show file tree
Hide file tree
Showing 19 changed files with 102 additions and 98 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ jobs:

- name: Build a source tarball and wheel
run: |
pip install wheel
python setup.py sdist bdist_wheel
pip install build
python -m build
- name: Get and store tag from 'Bump version and push tag' step
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 2 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ max-line-length=100
[DESIGN]
# Maximum number of arguments for function / method
max-args=8
# Maximum number of positional arguments for function / method
max-positional-arguments=8
# Argument names that match this expression will be ignored. Default to name
# with leading underscore
ignored-argument-names=_.*
Expand Down
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ Copyright (c) 2020-2024 Blue Brain Project/EPFL

.. |license| image:: https://img.shields.io/badge/License-Apache_2.0-blue.svg
:target: https://github.com/BlueBrain/EModelRunner/blob/main/LICENSE.txt
:alt: Build Status
:alt: License

.. |docs| image:: https://readthedocs.org/projects/emodelrunner/badge/?version=latest
:target: https://emodelrunner.readthedocs.io/en/latest/?badge=latest
Expand All @@ -284,3 +284,4 @@ Copyright (c) 2020-2024 Blue Brain Project/EPFL

.. |zenodo| image:: https://zenodo.org/badge/DOI/10.5281/zenodo.8116075.svg
:target: https://doi.org/10.5281/zenodo.8116075
:alt: Zenodo
1 change: 1 addition & 0 deletions emodelrunner/GUI_utils/plotshape.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ def get_morph_lines(
- list: voltages previously plotted (mV)
- bool: True to force the draw of figure, False to blit the figure
"""
# pylint: disable=too-many-positional-arguments
# Adapted from the NEURON package (fct _do_plot in __init__):
# https://www.neuron.yale.edu/neuron/
# where this part of the code was itself adapted from
Expand Down
2 changes: 1 addition & 1 deletion emodelrunner/create_cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def create_cell(
Returns:
CellModelCustom: cell model
"""
# pylint: disable=too-many-arguments, too-many-locals
# pylint: disable=too-many-arguments, too-many-locals, too-many-positional-arguments
# load mechanisms
mechs = load_mechanisms(unopt_params_path)

Expand Down
2 changes: 1 addition & 1 deletion emodelrunner/create_hoc_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ def create_hoc(
Returns:
str: hoc script describing the cell model
"""
# pylint: disable=too-many-locals
# pylint: disable=too-many-locals, too-many-positional-arguments
with open(template_path, "r", encoding="utf-8") as template_file:
template = template_file.read()
template = jinja2.Template(template)
Expand Down
4 changes: 4 additions & 0 deletions emodelrunner/morphology/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,16 @@ def create_morphology(morph_args, package_type):
morph_args.morph_path,
do_replace_axon=morph_args.do_replace_axon,
replace_axon_hoc=replace_axon_hoc,
axon_stub_length=60,
axon_nseg_frequency=15,
)
elif package_type == PackageType.thalamus:
morph = ThalamusNrnFileMorphology(
morph_args.morph_path,
do_replace_axon=morph_args.do_replace_axon,
replace_axon_hoc=replace_axon_hoc,
axon_stub_length=60,
axon_nseg_frequency=15,
)
else:
raise ValueError(f"unsupported package type: {package_type}")
Expand Down
23 changes: 15 additions & 8 deletions emodelrunner/morphology/morphology.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class SSCXNrnFileMorphology(ephys.morphologies.NrnFileMorphology):
'proc replace_axon(){ ... }
If None,the default replace_axon is used
do_set_nseg (bool): if True, it will use nseg_frequency
axon_stub_length (float): Length of replacement axon
axon_nseg_frequency (int): frequency of nseg, for axon
nseg_frequency (float): frequency of nseg
morph_modifiers (list): list of functions to modify the icell
with (sim, icell) as arguments
Expand All @@ -46,17 +48,18 @@ class SSCXNrnFileMorphology(ephys.morphologies.NrnFileMorphology):
"""

@staticmethod
def replace_axon(sim=None, icell=None):
def replace_axon(sim=None, icell=None, axon_stub_length=60, axon_nseg_frequency=15):
"""Replace axon.
Args:
sim (bluepyopt.ephys.NrnSimulator): neuron simulator
icell (neuron cell): cell instantiation in simulator
axon_stub_length (float): Length of replacement axon
axon_nseg_frequency (int): frequency of nseg, for axon
"""
L_target = 60 # length of stub axon
nseg0 = 5 # number of segments for each of the two axon sections
L_target = axon_stub_length # length of stub axon

nseg_total = nseg0 * 2
nseg_total = 2 + 4 * int(L_target / 2.0 / axon_nseg_frequency) # -> 10
chunkSize = L_target / nseg_total

diams = []
Expand Down Expand Up @@ -133,6 +136,8 @@ class ThalamusNrnFileMorphology(ephys.morphologies.NrnFileMorphology):
'proc replace_axon(){ ... }
If None,the default replace_axon is used
do_set_nseg (bool): if True, it will use nseg_frequency
axon_stub_length (float): Length of replacement axon
axon_nseg_frequency (int): frequency of nseg, for axon
nseg_frequency (float): frequency of nseg
morph_modifiers (list): list of functions to modify the icell
with (sim, icell) as arguments
Expand All @@ -141,17 +146,19 @@ class ThalamusNrnFileMorphology(ephys.morphologies.NrnFileMorphology):
"""

@staticmethod
def replace_axon(sim=None, icell=None):
def replace_axon(sim=None, icell=None, axon_stub_length=60, axon_nseg_frequency=15):
"""Replace axon.
Args:
sim (bluepyopt.ephys.NrnSimulator): neuron simulator
icell (neuron cell): cell instantiation in simulator
axon_stub_length (float): Length of replacement axon
axon_nseg_frequency (int): frequency of nseg, for axon
"""
L_target = 60 # length of stub axon
nseg0 = 5 # number of segments for each of the two axon sections
# pylint: disable=too-many-locals
L_target = axon_stub_length # length of stub axon

nseg_total = nseg0 * 2
nseg_total = 2 + 4 * int(L_target / 2.0 / axon_nseg_frequency) # -> 10
chunkSize = L_target / nseg_total

diams = []
Expand Down
2 changes: 1 addition & 1 deletion emodelrunner/protocols/create_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def define_pairsim_protocols(
Returns:
synplas_protocols.SweepProtocolPairSim: pair simulation synapse plasticity protocols
"""
# pylint: disable=too-many-arguments, too-many-locals
# pylint: disable=too-many-arguments, too-many-locals, too-many-positional-arguments
# locations
soma_loc = ephys.locations.NrnSeclistCompLocation(
name="soma", seclist_name="somatic", sec_index=0, comp_x=0.5
Expand Down
4 changes: 2 additions & 2 deletions emodelrunner/protocols/sscx_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(
pre_protocols (bluepyopt.ephys.protocols.Protocol): protocols to run
before the 'other protocols'
"""
# pylint: disable=too-many-arguments
# pylint: disable=too-many-arguments, too-many-positional-arguments
super().__init__(name=name)

self.rmp_protocol = rmp_protocol
Expand Down Expand Up @@ -697,7 +697,7 @@ def search_spike_threshold(
Returns:
float: threshold current amplitude (nA)
"""
# pylint: disable=undefined-loop-variable, too-many-arguments
# pylint: disable=undefined-loop-variable, too-many-arguments, too-many-positional-arguments
step_currents = np.linspace(lower_bound, upper_bound, num=self.short_steps)

if len(step_currents) == 0:
Expand Down
6 changes: 3 additions & 3 deletions emodelrunner/protocols/thalamus_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __init__(
pre_protocols=None,
):
"""Constructor."""
# pylint: disable=too-many-arguments
# pylint: disable=too-many-arguments, too-many-positional-arguments
super().__init__(name=name)

self.rmp_protocol = rmp_protocol
Expand Down Expand Up @@ -426,7 +426,7 @@ def binsearch_holdi(
depth=1,
):
"""Do binary search to find holding current."""
# pylint: disable=too-many-arguments
# pylint: disable=too-many-arguments, too-many-positional-arguments
middle_bound = upper_bound - abs(upper_bound - lower_bound) / 2

if depth > max_depth:
Expand Down Expand Up @@ -739,7 +739,7 @@ def binsearch_spike_threshold(
Assumption is that lower_bound has no spike, upper_bound has.
"""
# pylint: disable=too-many-arguments
# pylint: disable=too-many-arguments, too-many-positional-arguments
if depth > max_depth or abs(upper_bound - lower_bound) < precision:
return upper_bound
middle_bound = upper_bound - abs(upper_bound - lower_bound) / 2
Expand Down
2 changes: 1 addition & 1 deletion emodelrunner/synapses/glusynapse.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(
number (int/None): force synapse to fire N times when using NetStim
noise (int/None): force synapse to have given noise when using NetStim
"""
# pylint: disable=too-many-arguments
# pylint: disable=too-many-arguments, too-many-positional-arguments
self.seed = seed
self.rng_settings_mode = rng_settings_mode
self.section = section
Expand Down
2 changes: 1 addition & 1 deletion emodelrunner/synapses/mechanism.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __init__(
syn_setup_params (dict): contains extra parameters to setup synapses
when using GluSynapseCustom
"""
# pylint: disable=too-many-arguments
# pylint: disable=too-many-arguments, too-many-positional-arguments
super().__init__(name, comment)
self.synapses_data = synapses_data
self.synconf_dict = synconf_dict
Expand Down
2 changes: 1 addition & 1 deletion emodelrunner/synapses/minis.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(
spont_minis_rate=None,
):
"""Constructor."""
# pylint: disable=too-many-arguments
# pylint: disable=too-many-arguments, too-many-positional-arguments
super().__init__()
self.gid = gid
if stop is None:
Expand Down
2 changes: 1 addition & 1 deletion emodelrunner/synapses/synapse.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def __init__(
number (int/None): force synapse to fire N times when using NetStim
noise (int/None): force synapse to have given noise when using NetStim
"""
# pylint: disable=too-many-arguments
# pylint: disable=too-many-arguments, too-many-positional-arguments
self.seed = seed
self.rng_settings_mode = rng_settings_mode
self.section = section
Expand Down
58 changes: 58 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
[build-system]
requires = ["setuptools >= 64", "setuptools_scm"]
build-backend = "setuptools.build_meta"

[project]
name = "EModelRunner"
authors = [
{name = "Blue Brain Project, EPFL"},
]
description="Runs cells from Blue Brain Project cell packages, such as sscx, synapse plasticity, etc."
readme = "README.rst"
license = {file = "LICENSE.txt"}
requires-python = ">= 3.8"
dynamic = ["version"]
dependencies = [
"numpy",
"efel>=4.2,<6",
"bluepyopt>=1.14.15",
"neurom>=3.1.0",
"h5py",
"matplotlib",
"schema",
"Pebble>=4.3.10",
"tqdm>=4.65.0",
]
classifiers=[
"Development Status :: 5 - Stable",
"Intended Audience :: Education",
"Intended Audience :: Science/Research",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering :: Bio-Informatics",
]

[project.optional-dependencies]
docs = ["sphinx", "sphinx-bluebrain-theme"]

[project.urls]
Homepage = "https://github.com/BlueBrain/EModelRunner"
Source = "https://github.com/BlueBrain/EModelRunner"
Repository = "https://github.com/BlueBrain/EModelRunner.git"
Tracker = "https://github.com/BlueBrain/EModelRunner/issues"
Documentation = "https://emodelrunner.readthedocs.io/en/latest"

[tool.setuptools]
include-package-data = true

[tool.setuptools.packages.find]
exclude = ["tests",]

[tool.setuptools_scm]
version_scheme = "python-simplified-semver"
local_scheme = "no-local-version"
68 changes: 0 additions & 68 deletions setup.py

This file was deleted.

Loading

0 comments on commit b07220d

Please sign in to comment.