Neuronunit reduced cells
Hi @wvangeit and @rgerkin,
This represents the long proposed pull request that reconciles BluePyOpt and Neuronunit optimization. In the examples directory, there is a neuronunit sub-directory with three notebooks demonstrating optimization with this BluePyOpt/Neuronunit fusion. One that optimizes electro physiology properties in reduced models. The other two examples are about fitting the Izhikevich and Adexp models optimized to fit spike times using EFEL and BPO
Below I have decided to bring to attention several aspects of the proposed merge:
Inside the file: bluepyopt/ephys/protocols.py there is class NeuronUnitAllenStepProtocol(SweepProtocol), that inherits from the other classes in that file, but it contains some neuronunit specific logic for running reduced cell models.
The reduced cell models I am optimizing evaluate relatively quickly ~0.0009seconds this is because they use just in time compilation. I believe there are more performance gains I can access at a later point (probably via python numba.vectorize).
In all instances the reduced cell models that are optimized inherit BPO model methods (such as freeze and unfreeze), which means that they can be used with BPO cell evaluator class and objective calculator classes too. The models also use the BPO parameter type to assign model parameter boundaries.
I have re-implented the bluepyopt/deapext/algorithms.py file and put it in here. I also put a key word argument switch in (bluepyopt/deapext/optimisations.py)[https://github.com/russelljjarvis/BluePyOpt/blob/neuronunit_reduced_cells/bluepyopt/deapext/optimisations.py#L307-L312], that runs the neuronunit version of algorithms.py if it is provided as a keyword argument to the DEAPOptimisation class of bpop, for example:
optimisation = bpop.optimisations.DEAPOptimisation(
neuronunit=True
)
The main two differences are: I have found reduced model optimization works a lot better with elitism, so elitist behavior is default, and also there are progress bars (for both java script and shell, time diminishing eta), and some methods that were specific to reduced model optimization.
Sorry that my code editor is doing something weird to tabs/spaces and it has introduced many superficial changes at the code formatting level.
This branch uses .circleci.config.yml for continuous integration, that is not something I am intending to merge as I don't expect it to be useful to everyone else. I just use circle-ci because it can run building and testing for hours without timing out. There are also two new test files inside the BPO tests subdirectory that are specific to neuronunit/bpo optimization.
One other thing on my to do list is to to try to better reconcile BPO Protocol objects with neuronunits equivalent method of managing protocols. One design/structural problem in this context is that neuronunit tests, tend to be associated with their own pre built protocols, which are methods that belong to neuronunit test classes, they are often called things like generate_prediction/generate_feature. These methods could be easily wrapped inside BPO protocol objects.
Also perhaps I could merge into a dedicated Reduced_cells branch of BPO?
Please regard this as a draft PR request, while I try to find a way to restore the original formatting of the files. Feel free to propose any revisions.
Note: Although continuous integration fails when github evaluates the PR on BluePyOpt/origin/master the general body of code is able to pass CI building and unit testing via circlec, see BPO , neuronunit and reduced cell models
Hi @russelljjarvis, could you also bring this branch up to date with master? It seems too complex for github to resolve the issues automatically. Thx.
AOK Thanks for all the feedback, I will work on resolving issues in the next month.
Thank you.
Hi @russelljjarvis, could you also bring this branch up to date with master? It seems too complex for github to resolve the issues automatically. Thx.
Merged into master.
I think the PR is almost there. Two outstanding tasks are. *1. Solving tox errors (do you see these on your end?):
ERROR: py3-unit: commands failed
ERROR: py3-functional: commands failed
ERROR: py3-style: commands failed
Error: Process completed with exit code 1.
I see now, there must be some relationship to the commands in the toxini file:
make clean
./.install_neuron.sh {env:TOX_NRNDIR}/src {env:TOX_NRNDIR}/local {basepython}
make toxbinlinks
functional: make stochkv_prepare l5pc_prepare sc_prepare meta_prepare
style: pycodestyle --ignore=E402,W503,W504 bluepyopt
syntax: flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics
unit: nosetests -vx -a unit --with-coverage --cover-package bluepyopt --cover-xml --cover-xml-file=cov_reports/unit.coverage.xml --cover-html --cover-html-dir=cov_reports/html/unit []
functional: nosetests -vx -a !unit --with-coverage --cover-package bluepyopt --cover-xml --cover-xml-file=cov_reports/functional.coverage.xml --cover-html --cover-html-dir=cov_reports/html/functional []
*2. Making the neuronunit optimization branch pip installable. -- done. *3. Make jithub models pip installable --pending.
I can get this tox.ini file to execute cleanly on an isolated Continuous Integration job.
I am having trouble figuring out how to get the BluePyOpt@origin/master tox.ini file to run with these changes integrated into it.
When I succeed at that I think Github merging will no longer be blocked. It might take me another 2 weeks to figure it out in parallel with other work.
[tox]
envlist = py{3}-{unit}
[gh-actions]
python =
3.6: py3
3.7: py3
3.8: py3
3.9: py3
[testenv]
envdir =
py3{5,6,7,8,}{-unit,-syntax}: {toxworkdir}/py3
docs: {toxworkdir}/docs
deps =
coverage
flake8
mock
nose
sh
pathlib
download = true
whitelist_externals =
make
find
cd
pwd
passenv = https_proxy
commands =
pip install pynwb
pip install -e jit_hub
pip install git+https://github.com/russelljjarvis/neuronunit@optimization
pip install git+https://github.com/russelljjarvis/sciunit@dev
pip install .
pip install git+https://github.com/russelljjarvis/eFEL
syntax: flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics
unit: python bluepyopt/tests/test_numba_models.py
unit: python bluepyopt/tests/test_rheobase_model.py
unit: python bluepyopt/tests/test_scores_unit.py
unit: python bluepyopt/tests/test_adexp_opt.py
[testenv:docs]
basepython = python3.6
changedir = docs
deps =
sphinx
sphinx-bluebrain-theme
commands = make html SPHINXOPTS=-W
whitelist_externals = make