Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Neuronunit reduced cells #348

Open
wants to merge 132 commits into
base: master
Choose a base branch
from

Conversation

russelljjarvis
Copy link

@russelljjarvis russelljjarvis commented Jan 30, 2021

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

@russelljjarvis
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants