Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Commit af06928

Browse files
authored
Merge pull request #393 from lukasgd/arbor_integration
Arbor cable cell exporter and backend
2 parents 38ba649 + 70fddf8 commit af06928

File tree

76 files changed

+51402
-258
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+51402
-258
lines changed

MANIFEST.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
include versioneer.py
22
include bluepyopt/_version.py
3+
include bluepyopt/ephys/static/arbor_mechanisms.json
34
include bluepyopt/ephys/templates/cell_template.jinja2
5+
include bluepyopt/ephys/templates/acc/_json_template.jinja2
6+
include bluepyopt/ephys/templates/acc/decor_acc_template.jinja2
7+
include bluepyopt/ephys/templates/acc/label_dict_acc_template.jinja2
48

59
include.txt
610
include AUTHORS.txt

Makefile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ l5pc_nbconvert: jupyter
1515
cd examples/l5pc && \
1616
jupyter nbconvert --to python L5PC.ipynb && \
1717
sed '/get_ipython/d;/plt\./d;/plot_responses/d;/import matplotlib/d;/neurom/d;/axes/d;/fig/d;/for index/d' L5PC.py >L5PC.tmp && \
18-
mv L5PC.tmp L5PC.py
18+
mv L5PC.tmp L5PC.py && \
19+
python l5pc_validate_neuron_arbor_pm.py --prepare-only --regions somatic --param-values ../../bluepyopt/tests/testdata/l5pc_validate_neuron_arbor/param_values.json && \
20+
jupyter nbconvert --to python l5pc_validate_neuron_arbor_somatic.ipynb && \
21+
sed '/get_ipython/d;/plt\./d;/import matplotlib/d;/from IPython.display/d;/multiprocessing/d;s/pool.map/map/g;s/# test_l5pc: insert //g;/# test_l5pc: skip/d' l5pc_validate_neuron_arbor_somatic.py >l5pc_validate_neuron_arbor_somatic.tmp && \
22+
mv l5pc_validate_neuron_arbor_somatic.tmp l5pc_validate_neuron_arbor_somatic.py
1923
l5pc_nrnivmodl:
2024
cd examples/l5pc && nrnivmodl mechanisms
2125
l5pc_zip:
@@ -28,7 +32,11 @@ sc_prepare: jupyter
2832
cd examples/simplecell && \
2933
jupyter nbconvert --to python simplecell.ipynb && \
3034
sed '/get_ipython/d;/plt\./d;/plot_responses/d;/import matplotlib/d' simplecell.py >simplecell.tmp && \
31-
mv simplecell.tmp simplecell.py
35+
mv simplecell.tmp simplecell.py && \
36+
jupyter nbconvert --to python simplecell_arbor.ipynb && \
37+
sed '/get_ipython/d;/plt\./d;/plot_responses/d;/import matplotlib/d' simplecell_arbor.py >simplecell_arbor.tmp && \
38+
mv simplecell_arbor.tmp simplecell_arbor.py
39+
3240
meta_prepare: jupyter
3341
cd examples/metaparameters && \
3442
jupyter nbconvert --to python metaparameters.ipynb && \
@@ -41,6 +49,8 @@ coverage_test: test
4149
jupyter:
4250
pip install jupyter
4351
pip install ipython --upgrade
52+
pip install papermill
53+
pip install scipy
4454
install_test_requirements:
4555
pip install -q $(TEST_REQUIREMENTS) --upgrade
4656
test: clean unit functional
@@ -65,6 +75,8 @@ clean:
6575
rm -rf bluepyopt/tests/coverage.xml
6676
rm -rf bluepyopt/tests/coverage_html
6777
rm -rf examples/l5pc/L5PC.py
78+
rm -rf examples/l5pc/l5pc_validate_neuron_arbor_somatic.ipynb
79+
rm -rf examples/l5pc/l5pc_validate_neuron_arbor_somatic.py
6880
rm -rf examples/l5pc/x86_64
6981
rm -rf examples/stochkv/x86_64
7082
rm -rf x86_64

README.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ We are providing support using a chat channel on `Gitter <https://gitter.im/Blue
107107

108108
News
109109
====
110+
- 2023/01: BluePyOpt now supports the Arbor simulator.
110111
- 2022/12: Support for LFPy models merged into master. Examples and preprint: https://github.com/alejoe91/multimodalfitting, https://www.biorxiv.org/content/10.1101/2022.08.03.502468v1.full
111112
- 2022/12: BluePyOpt now has the ability to write out NeuroML files: https://github.com/BlueBrain/BluePyOpt/tree/master/bluepyopt/neuroml
112113
- 2021/08/30: BluePyOpt dropped Python 2.7 support.
@@ -141,6 +142,11 @@ And then bluepyopt itself:
141142
142143
pip install bluepyopt
143144
145+
Support for simulators other than NEURON is optional and not installed by default. If you want to use [Arbor](https://arbor-sim.org/) to run your models, use the following line instead to install bluepyopt.
146+
147+
.. code-block:: bash
148+
149+
pip install bluepyopt[arbor]
144150
145151
Cloud infrastructure
146152
====================
@@ -158,7 +164,8 @@ Single compartmental model
158164
An iPython notebook with an introductory optimisation of a one compartmental
159165
model with 2 HH channels can be found at
160166

161-
https://github.com/BlueBrain/BluePyOpt/blob/master/examples/simplecell/simplecell.ipynb
167+
https://github.com/BlueBrain/BluePyOpt/blob/master/examples/simplecell/simplecell.ipynb (NEURON)
168+
https://github.com/BlueBrain/BluePyOpt/blob/master/examples/simplecell/simplecell_arbor.ipynb (Arbor)
162169

163170

164171
|landscape_example|
@@ -173,7 +180,8 @@ Scripts for a more complex neocortical L5PC are in
173180

174181
With a notebook:
175182

176-
https://github.com/BlueBrain/BluePyOpt/blob/master/examples/l5pc/L5PC.ipynb
183+
https://github.com/BlueBrain/BluePyOpt/blob/master/examples/l5pc/L5PC.ipynb (NEURON)
184+
https://github.com/BlueBrain/BluePyOpt/blob/master/examples/l5pc/L5PC_arbor.ipynb (Arbor)
177185

178186
Thalamocortical Cells
179187
---------------------

bluepyopt/deapext/optimisations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def setup_deap(self):
201201
# import deap_efel_eval1
202202
self.toolbox.register(
203203
"evaluate",
204-
self.evaluator.set_neuron_variables_and_evaluate_with_lists
204+
self.evaluator.init_simulator_and_evaluate_with_lists
205205
)
206206

207207
# Register the mate operator

bluepyopt/deapext/optimisationsCMA.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def setup_deap(self):
213213
# Register the evaluation function for the individuals
214214
self.toolbox.register(
215215
"evaluate",
216-
self.evaluator.set_neuron_variables_and_evaluate_with_lists
216+
self.evaluator.init_simulator_and_evaluate_with_lists
217217
)
218218

219219
import copyreg

bluepyopt/ephys/acc.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
'''Dependencies of Arbor simulator backend'''
2+
3+
try:
4+
import arbor
5+
except ImportError as e:
6+
class arbor:
7+
def __getattribute__(self, _):
8+
raise ImportError("Exporting cell models to ACC/JSON, loading"
9+
" them or optimizing them with the Arbor"
10+
" simulator requires missing dependency arbor."
11+
" To install BluePyOpt with arbor,"
12+
" run 'pip install bluepyopt[arbor]'.")
13+
14+
15+
class ArbLabel:
16+
"""Arbor label"""
17+
18+
def __init__(self, type, name, s_expr):
19+
if type not in ['locset', 'region', 'iexpr']:
20+
raise ValueError('Invalid Arbor label type %s' % type)
21+
self._type = type
22+
self._name = name
23+
self._s_expr = s_expr
24+
25+
@property
26+
def defn(self):
27+
"""Label definition for label-dict"""
28+
return '(%s-def "%s" %s)' % (self._type, self._name, self._s_expr)
29+
30+
@property
31+
def ref(self):
32+
"""Reference to label defined in label-dict"""
33+
return '(%s "%s")' % (self._type, self._name)
34+
35+
@property
36+
def name(self):
37+
"""Name of the label"""
38+
return self._name
39+
40+
@property
41+
def loc(self):
42+
"""S-expression defining the location of the label"""
43+
return self._s_expr
44+
45+
def __eq__(self, other):
46+
if other is None:
47+
return False
48+
elif not isinstance(other, ArbLabel):
49+
raise TypeError('%s is not an ArbLabel' % str(other))
50+
else:
51+
return self._s_expr == other._s_expr
52+
53+
def __hash__(self):
54+
return hash(self._s_expr)
55+
56+
def __repr__(self):
57+
return self.defn

0 commit comments

Comments
 (0)