├── .coveragerc ├── .gitattributes ├── .github └── workflows │ ├── build.yml │ ├── keep-alive.yml │ ├── mirror-ebrains.yml │ └── test.yml ├── .gitignore ├── .readthedocs.yaml ├── .zenodo.json ├── AUTHORS.txt ├── COPYING ├── COPYING.lesser ├── Dockerfile ├── LICENSE.txt ├── MANIFEST.in ├── Makefile ├── README.rst ├── bluepyopt ├── __init__.py ├── api.py ├── deapext │ ├── CMA_MO.py │ ├── CMA_SO.py │ ├── __init__.py │ ├── algorithms.py │ ├── hype.py │ ├── optimisations.py │ ├── optimisationsCMA.py │ ├── stoppingCriteria.py │ ├── tools │ │ ├── __init__.py │ │ └── selIBEA.py │ └── utils.py ├── ephys │ ├── __init__.py │ ├── acc.py │ ├── base.py │ ├── create_acc.py │ ├── create_hoc.py │ ├── efeatures.py │ ├── evaluators.py │ ├── examples │ │ ├── __init__.py │ │ └── simplecell │ │ │ ├── __init__.py │ │ │ ├── simple.swc │ │ │ └── simplecell.py │ ├── extra_features_utils.py │ ├── locations.py │ ├── mechanisms.py │ ├── models.py │ ├── morphologies.py │ ├── objectives.py │ ├── objectivescalculators.py │ ├── parameters.py │ ├── parameterscalers │ │ ├── __init__.py │ │ ├── acc_iexpr.py │ │ └── parameterscalers.py │ ├── protocols.py │ ├── recordings.py │ ├── responses.py │ ├── serializer.py │ ├── simulators.py │ ├── static │ │ └── arbor_mechanisms.json │ ├── stimuli.py │ └── templates │ │ ├── acc │ │ ├── _json_template.jinja2 │ │ ├── decor_acc_template.jinja2 │ │ └── label_dict_acc_template.jinja2 │ │ └── cell_template.jinja2 ├── evaluators.py ├── ipyp │ ├── __init__.py │ └── bpopt_tasksdb.py ├── neuroml │ ├── NeuroML2_mechanisms │ │ ├── Ca.channel.nml │ │ ├── Ca_HVA.channel.nml │ │ ├── Ca_LVAst.channel.nml │ │ ├── Ih.channel.nml │ │ ├── Im.channel.nml │ │ ├── K_Pst.channel.nml │ │ ├── K_Tst.channel.nml │ │ ├── KdShu2007.channel.nml │ │ ├── NaTa_t.channel.nml │ │ ├── NaTs2_t.channel.nml │ │ ├── Nap_Et2.channel.nml │ │ ├── SK_E2.channel.nml │ │ ├── SKv3_1.channel.nml │ │ ├── StochKv_deterministic.channel.nml │ │ ├── baseCaDynamics_E2_NML2.nml │ │ └── pas.channel.nml │ ├── __init__.py │ ├── biophys.py │ ├── cell.py │ ├── morphology.py │ └── simulation.py ├── objectives.py ├── optimisations.py ├── parameters.py ├── stoppingCriteria.py ├── tests │ ├── .gitignore │ ├── __init__.py │ ├── disable_simplecell_scoop.py │ ├── expected_results.json │ ├── test_bluepyopt.py │ ├── test_deapext │ │ ├── __init__.py │ │ ├── deapext_test_utils.py │ │ ├── test_algorithms.py │ │ ├── test_hype.py │ │ ├── test_optimisations.py │ │ ├── test_optimisationsCMA.py │ │ ├── test_selIBEA.py │ │ ├── test_stoppingCriteria.py │ │ └── test_utils.py │ ├── test_ephys │ │ ├── __init__.py │ │ ├── test_acc.py │ │ ├── test_create_acc.py │ │ ├── test_create_hoc.py │ │ ├── test_evaluators.py │ │ ├── test_extra_features_utils.py │ │ ├── test_features.py │ │ ├── test_init.py │ │ ├── test_locations.py │ │ ├── test_mechanisms.py │ │ ├── test_models.py │ │ ├── test_morphologies.py │ │ ├── test_objectives.py │ │ ├── test_parameters.py │ │ ├── test_parameterscalers.py │ │ ├── test_protocols.py │ │ ├── test_recordings.py │ │ ├── test_serializer.py │ │ ├── test_simulators.py │ │ ├── test_stimuli.py │ │ ├── testdata │ │ │ ├── TimeVoltageResponse.csv │ │ │ ├── acc │ │ │ │ ├── CCell │ │ │ │ │ ├── CCell.json │ │ │ │ │ ├── CCell_decor.acc │ │ │ │ │ ├── CCell_label_dict.acc │ │ │ │ │ └── simple_axon_replacement.acc │ │ │ │ ├── expsyn │ │ │ │ │ ├── simple.swc │ │ │ │ │ ├── simple_cell.json │ │ │ │ │ ├── simple_cell_decor.acc │ │ │ │ │ └── simple_cell_label_dict.acc │ │ │ │ ├── l5pc │ │ │ │ │ ├── C060114A7.asc │ │ │ │ │ ├── C060114A7_axon_replacement.acc │ │ │ │ │ ├── C060114A7_modified.acc │ │ │ │ │ ├── l5pc.json │ │ │ │ │ ├── l5pc_decor.acc │ │ │ │ │ └── l5pc_label_dict.acc │ │ │ │ ├── l5pc_py37 │ │ │ │ │ └── l5pc_decor.acc │ │ │ │ ├── simplecell │ │ │ │ │ ├── simple.swc │ │ │ │ │ ├── simple_axon_replacement.acc │ │ │ │ │ ├── simple_cell.json │ │ │ │ │ ├── simple_cell_decor.acc │ │ │ │ │ ├── simple_cell_label_dict.acc │ │ │ │ │ └── simple_modified.acc │ │ │ │ └── templates │ │ │ │ │ ├── cell_json_template.jinja2 │ │ │ │ │ ├── decor_acc_template.jinja2 │ │ │ │ │ └── label_dict_acc_template.jinja2 │ │ │ ├── apic.swc │ │ │ ├── lfpy_soma_time.npy │ │ │ ├── lfpy_soma_voltage.npy │ │ │ ├── lfpy_time.npy │ │ │ ├── lfpy_voltage.npy │ │ │ ├── mean_waveforms.dat │ │ │ ├── simple.swc │ │ │ ├── simple.wrong │ │ │ ├── simple_ax1.swc │ │ │ ├── simple_ax2.asc │ │ │ ├── simple_ax2.swc │ │ │ └── test.jinja2 │ │ ├── testmodels │ │ │ ├── __init__.py │ │ │ └── dummycells.py │ │ └── utils.py │ ├── test_evaluators.py │ ├── test_l5pc.py │ ├── test_lfpy.py │ ├── test_neuroml_fcts.py │ ├── test_parameters.py │ ├── test_simplecell.py │ ├── test_stochkv.py │ ├── test_tools.py │ └── testdata │ │ └── l5pc_validate_neuron_arbor │ │ └── param_values.json └── tools.py ├── cloud-config ├── README.md ├── config │ ├── amazon │ │ ├── README.md │ │ ├── ansible.cfg │ │ ├── create_instance.yaml │ │ ├── gather_config.py │ │ ├── site.yaml │ │ └── vars.yaml │ ├── cluster-user │ │ ├── README.md │ │ ├── ansible.cfg │ │ ├── hosts │ │ ├── site.yaml │ │ └── vars.yaml │ └── vagrant │ │ ├── README.md │ │ ├── Vagrantfile │ │ ├── ansible.cfg │ │ ├── hosts │ │ ├── site.yaml │ │ └── vars.yaml └── roles │ ├── base │ └── tasks │ │ └── main.yaml │ ├── deap │ └── tasks │ │ └── main.yaml │ ├── granule-example │ └── tasks │ │ └── main.yaml │ ├── neuron │ └── tasks │ │ ├── main.yaml │ │ └── python27.yaml │ └── scoop-master │ └── tasks │ └── main.yaml ├── codecov.yml ├── docs ├── .gitignore ├── Makefile └── source │ ├── .gitignore │ ├── _static │ └── bbp.jpg │ ├── _templates │ └── module.rst │ ├── api.rst │ ├── conf.py │ ├── deapext.rst │ ├── ephys.rst │ ├── index.rst │ ├── logo │ ├── BluePyOptBanner.png │ └── BluePyOptLogo.png │ └── optimisations.rst ├── examples ├── BluePyOpt-ipyparallel.md ├── README.md ├── __init__.py ├── cma_strategy │ └── cma.ipynb ├── expsyn │ ├── .gitignore │ ├── ExpSyn.ipynb │ ├── ExpSyn_arbor.ipynb │ ├── expsyn.py │ ├── generate_acc.py │ └── simple.swc ├── graupnerbrunelstdp │ ├── checkpoints │ │ └── .gitignore │ ├── figures │ │ └── .gitignore │ ├── gbevaluator.py │ ├── graupnerbrunelstdp.ipynb │ ├── run_fit.py │ ├── stdputil.py │ └── test_stdputil.py ├── l5pc │ ├── .gitignore │ ├── L5PC.ipynb │ ├── L5PC_arbor.ipynb │ ├── benchmark │ │ ├── get_stats.py │ │ ├── l5pc_benchmark.sbatch │ │ ├── logs │ │ │ └── .gitignore │ │ ├── run_benchmark.sh │ │ ├── start.sh │ │ └── task_stats.py │ ├── cADpyr_76.hoc │ ├── checkpoints │ │ └── .gitignore │ ├── config │ │ ├── features.json │ │ ├── fixed_params.json │ │ ├── mechanisms.json │ │ ├── parameters.json │ │ ├── params.json │ │ └── protocols.json │ ├── convert_noise_exp.py │ ├── convert_params.py │ ├── create_tables.py │ ├── exp_data │ │ ├── .gitignore │ │ └── noise_i.txt │ ├── figures │ │ └── .gitignore │ ├── generate_acc.py │ ├── generate_hoc.py │ ├── hocmodel.py │ ├── l5_config.zip │ ├── l5pc_analysis.py │ ├── l5pc_evaluator.py │ ├── l5pc_model.py │ ├── l5pc_validate_neuron_arbor.ipynb │ ├── l5pc_validate_neuron_arbor_pm.py │ ├── mechanisms │ │ ├── CaDynamics_E2.mod │ │ ├── Ca_HVA.mod │ │ ├── Ca_LVAst.mod │ │ ├── Ih.mod │ │ ├── Im.mod │ │ ├── K_Pst.mod │ │ ├── K_Tst.mod │ │ ├── LICENSE │ │ ├── NaTa_t.mod │ │ ├── NaTs2_t.mod │ │ ├── Nap_Et2.mod │ │ ├── SK_E2.mod │ │ ├── SKv3_1.mod │ │ └── dummy.inc │ ├── morphology │ │ ├── C060114A7.asc │ │ └── LICENSE │ ├── nsg │ │ ├── .gitignore │ │ ├── Makefile │ │ └── init.py │ ├── opt_l5pc.py │ ├── opt_l5pc.sh │ ├── tables │ │ └── .gitignore │ └── tasks2dataframe.py ├── l5pc_lfpy │ ├── L5PC_LFPy.ipynb │ ├── __init__.py │ ├── extra_features.json │ ├── generate_extra_features.py │ ├── l5pc_lfpy_evaluator.py │ └── l5pc_lfpy_model.py ├── metaparameters │ ├── .gitignore │ ├── metaparameters.ipynb │ └── twocompartment.swc ├── neuroml │ └── neuroml.ipynb ├── simplecell │ ├── .gitignore │ ├── checkpoints │ │ └── .gitignore │ ├── figures │ │ ├── .gitignore │ │ └── landscape_example.png │ ├── generate_acc.py │ ├── generate_hoc.py │ ├── responses.pkl │ ├── simple.swc │ ├── simplecell-paperfig.ipynb │ ├── simplecell.ipynb │ ├── simplecell_arbor.ipynb │ └── simplecell_model.py ├── stochkv │ ├── .gitignore │ ├── mechanisms │ │ ├── StochKv.mod │ │ ├── StochKv3.mod │ │ └── dummy.inc │ ├── morphology │ │ └── simple.swc │ ├── stochkv3cell.hoc │ ├── stochkv3cell.py │ ├── stochkv3cell_det.hoc │ ├── stochkvcell.hoc │ ├── stochkvcell.py │ └── stochkvcell_det.hoc ├── thalamocortical-cell │ ├── CellEvalSetup │ │ ├── __init__.py │ │ ├── evaluator.py │ │ ├── protocols.py │ │ ├── template.py │ │ └── tools.py │ ├── LICENSE.txt │ ├── checkpoints │ │ └── checkpoint.pkl │ ├── config │ │ ├── features │ │ │ ├── cAD_ltb.json │ │ │ └── cNAD_ltb.json │ │ ├── params │ │ │ └── TC.json │ │ ├── protocols │ │ │ ├── cAD_ltb.json │ │ │ └── cNAD_ltb.json │ │ └── recipes.json │ ├── mechanisms │ │ ├── SK_E2.mod │ │ ├── TC_HH.mod │ │ ├── TC_ITGHK_Des98.mod │ │ ├── TC_Ih_Bud97.mod │ │ ├── TC_Nap_Et2.mod │ │ ├── TC_cadecay.mod │ │ ├── TC_iA.mod │ │ └── TC_iL.mod │ ├── morphologies │ │ ├── jy160728_A_idA.asc │ │ └── jy170517_A_idA.asc │ ├── results │ │ ├── cAD_ltb_params.csv │ │ └── cNAD_ltb_params.csv │ └── thalamocortical-cell_opt.ipynb └── tsodyksmarkramstp │ ├── AUTHORS.txt │ ├── README.md │ ├── amps.pkl │ ├── tmevaluator.py │ ├── tmevaluator_multiplefreqs.py │ ├── tmodeint.py │ ├── tmodesolve.py │ ├── trace.pkl │ ├── tsodyksmarkramstp.ipynb │ └── tsodyksmarkramstp_multiplefreqs.ipynb ├── misc ├── github_wiki │ ├── bibtex │ │ ├── mentions_BPO.bib │ │ ├── mentions_BPO_extra.bib │ │ ├── poster_uses_BPO.bib │ │ ├── thesis_mentions_BPO.bib │ │ ├── thesis_uses_BPO.bib │ │ ├── uses_BPO.bib │ │ └── uses_BPO_extra.bib │ └── creates_publication_list_markdown.py └── pytest_migration │ └── convert_pytest.sh ├── package.json ├── pyproject.toml ├── pytest.ini ├── requirements.txt ├── requirements_docs.txt └── tox.ini /.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | omit = */tests/*,bluepyopt/_version.py 3 | [report] 4 | omit=bluepyopt/_version.py 5 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | bluepyopt/_version.py export-subst 2 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | tags: 8 | - '[0-9]+.[0-9]+.[0-9]+' 9 | 10 | jobs: 11 | call-test-workflow: 12 | uses: BlueBrain/BluePyOpt/.github/workflows/test.yml@master 13 | 14 | build-tag-n-publish: 15 | name: Build, tag and publish on PyPI 16 | runs-on: ubuntu-latest 17 | needs: call-test-workflow 18 | permissions: 19 | contents: write 20 | steps: 21 | - uses: actions/checkout@v3 22 | 23 | - name: Set up Python 3.10 24 | uses: actions/setup-python@v4 25 | with: 26 | python-version: "3.10" 27 | 28 | - name: Bump version and push tag 29 | uses: anothrNick/github-tag-action@1.64.0 30 | if: ${{ !startsWith(github.ref, 'refs/tags/') }} 31 | id: tag 32 | env: 33 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 34 | WITH_V: false 35 | DEFAULT_BUMP: patch 36 | 37 | - name: Build a source tarball and wheel 38 | run: | 39 | pip install build 40 | python -m build 41 | 42 | - name: Get and store tag from 'Bump version and push tag' step 43 | if: ${{ !startsWith(github.ref, 'refs/tags/') }} 44 | run: echo "TAG_NAME=${{ steps.tag.outputs.new_tag }}" >> $GITHUB_ENV 45 | - name: Get and store tag from triggered tag push 46 | if: ${{ startsWith(github.ref, 'refs/tags/') }} 47 | run: echo "TAG_NAME=${{ github.ref_name }}" >> $GITHUB_ENV 48 | 49 | - name: Release 50 | uses: softprops/action-gh-release@v1 51 | with: 52 | tag_name: ${{ env.TAG_NAME }} 53 | name: ${{ env.TAG_NAME }} 54 | generate_release_notes: true 55 | 56 | - name: Publish package to PyPI 57 | uses: pypa/gh-action-pypi-publish@release/v1 58 | with: 59 | user: __token__ 60 | password: ${{ secrets.PYPI_PASSWORD }} 61 | -------------------------------------------------------------------------------- /.github/workflows/keep-alive.yml: -------------------------------------------------------------------------------- 1 | name: Keep-alive 2 | 3 | on: 4 | schedule: 5 | # Runs every sunday at 3 a.m. 6 | - cron: '0 3 * * SUN' 7 | 8 | jobs: 9 | call-test-workflow: 10 | uses: BlueBrain/BluePyOpt/.github/workflows/test.yml@master 11 | 12 | keep-workflow-alive: 13 | name: Keep workflow alive 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v2 17 | with: 18 | ref: master 19 | 20 | - name: Get date from 50 days ago 21 | run: | 22 | datethen=`date -d "-50 days" --utc +%FT%TZ` 23 | echo "datelimit=$datethen" >> $GITHUB_ENV 24 | 25 | - name: setup git config 26 | if: github.event.repository.pushed_at <= env.datelimit 27 | run: | 28 | # setup the username and email. 29 | git config user.name "Github Actions Keepalive Bot" 30 | git config user.email "<>" 31 | 32 | - name: commit IF last commit is older than 50 days 33 | if: github.event.repository.pushed_at <= env.datelimit 34 | run: | 35 | git commit -m "Empty commit to keep the gihub workflows alive" --allow-empty 36 | git push origin master -------------------------------------------------------------------------------- /.github/workflows/mirror-ebrains.yml: -------------------------------------------------------------------------------- 1 | name: Mirror to Ebrains 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | 7 | jobs: 8 | to_ebrains: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: syncmaster 12 | uses: wei/git-sync@v3 13 | with: 14 | source_repo: "BlueBrain/BluePyOpt" 15 | source_branch: "master" 16 | destination_repo: "https://ghpusher:${{ secrets.EBRAINS_GITLAB_ACCESS_TOKEN }}@gitlab.ebrains.eu/BlueBrain/bluepyopt.git" 17 | destination_branch: "master" 18 | - name: synctags 19 | uses: wei/git-sync@v3 20 | with: 21 | source_repo: "BlueBrain/BluePyOpt" 22 | source_branch: "refs/tags/*" 23 | destination_repo: "https://ghpusher:${{ secrets.EBRAINS_GITLAB_ACCESS_TOKEN }}@gitlab.ebrains.eu/BlueBrain/bluepyopt.git" 24 | destination_branch: "refs/tags/*" -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: 4 | pull_request: 5 | # allows this workflow to be reusable (e.g. by the build workflow) 6 | workflow_call: 7 | 8 | jobs: 9 | test: 10 | name: Test for python ${{ matrix.python-version }} on ${{ matrix.os }} 11 | runs-on: ${{ matrix.os }} 12 | strategy: 13 | matrix: 14 | os: [ubuntu-latest] 15 | python-version: ["3.9", "3.10", "3.11", "3.12"] 16 | include: 17 | - os: macos-12 18 | python-version: "3.10" 19 | 20 | steps: 21 | - uses: actions/checkout@v2 22 | 23 | - name: Set up Python ${{ matrix.python-version }} 24 | uses: actions/setup-python@v2 25 | with: 26 | python-version: ${{ matrix.python-version }} 27 | 28 | - name: Install dependencies 29 | run: | 30 | python -m pip install --upgrade pip setuptools 31 | pip install tox tox-gh-actions 32 | 33 | - name: Run tox 34 | run: tox 35 | 36 | - name: "Upload coverage to Codecov" 37 | uses: codecov/codecov-action@v4 38 | with: 39 | token: ${{ secrets.CODECOV_TOKEN }} 40 | fail_ci_if_error: false 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *.swp 3 | x86_64 4 | /bluepyopt.egg-info/ 5 | /build/ 6 | /dist/ 7 | .DS_Store 8 | /.tox 9 | .ipynb_checkpoints 10 | /.python-version 11 | /cov_reports 12 | .coverage 13 | coverage.xml 14 | .idea/ -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | # .readthedocs.yml 2 | # Read the Docs configuration file 3 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 4 | 5 | # Required 6 | version: 2 7 | 8 | sphinx: 9 | configuration: docs/source/conf.py 10 | fail_on_warning: true 11 | 12 | python: 13 | install: 14 | - method: pip 15 | path: . 16 | - requirements: requirements_docs.txt 17 | 18 | build: 19 | os: ubuntu-22.04 20 | tools: 21 | python: "3.10" 22 | -------------------------------------------------------------------------------- /.zenodo.json: -------------------------------------------------------------------------------- 1 | { 2 | "title" : "BluePyOpt", 3 | "license": "LGPL-3.0", 4 | "upload_type": "software", 5 | "description": "The Blue Brain Python Optimisation Library (BluePyOpt) is an extensible framework for data-driven model parameter optimisation that wraps and standardises several existing open-source tools. It simplifies the task of creating and sharing these optimisations, and the associated techniques and knowledge. This is achieved by abstracting the optimisation and evaluation tasks into various reusable and flexible discrete elements according to established best-practices. Further, BluePyOpt provides methods for setting up both small- and large-scale optimisations on a variety of platforms, ranging from laptops to Linux clusters and cloud-based compute infrastructures.", 6 | "creators": [ 7 | { 8 | "affiliation": "Blue Brain Project, EPFL", 9 | "name": "Van Geit, Werner", 10 | "orcid": "0000-0002-2915-720X" 11 | }, 12 | { 13 | "affiliation": "Blue Brain Project, EPFL", 14 | "name": "Gevaert, Michael", 15 | "orcid": "0000-0002-7547-3297" 16 | }, 17 | { 18 | "affiliation": "Blue Brain Project, EPFL", 19 | "name": "Damart, Tanguy", 20 | "orcid": "0000-0003-2175-7304" 21 | }, 22 | { 23 | "affiliation": "Blue Brain Project, EPFL", 24 | "name": "Rössert, Christian", 25 | "orcid": "0000-0002-4839-2424" 26 | }, 27 | { 28 | "affiliation": "Blue Brain Project, EPFL", 29 | "name": "Courcol, Jean-Denis", 30 | "orcid": "0000-0002-9351-1461" 31 | }, 32 | { 33 | "affiliation": "Blue Brain Project, EPFL", 34 | "name": "Chindemi, Guiseppe", 35 | "orcid": "0000-0001-6872-2366" 36 | }, 37 | { 38 | "affiliation": "Blue Brain Project, EPFL", 39 | "name": "Jaquier, Aurélien", 40 | "orcid": "0000-0001-6202-6175" 41 | }, 42 | { 43 | "affiliation": "Blue Brain Project, EPFL", 44 | "name": "Muller, Eilif", 45 | "orcid": "0000-0003-4309-8266" 46 | } 47 | ] 48 | } 49 | -------------------------------------------------------------------------------- /AUTHORS.txt: -------------------------------------------------------------------------------- 1 | Werner Van Geit @ BBP 2 | Christian Roessert @ BBP 3 | Mike Gevaert @ BBP 4 | Jean-Denis Courcol @ BBP 5 | Giuseppe Chindemi @ BBP 6 | Tanguy Damart @ BBP 7 | Elisabetta Iavarone @ BBP 8 | Anil Tuncel @ BBP 9 | Aurelien Jaquier @ BBP 10 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016-2022, EPFL/Blue Brain Project 2 | # 3 | # This file is part of BluePyOpt 4 | # 5 | # This library is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU Lesser General Public License version 3.0 as published 7 | # by the Free Software Foundation. 8 | # 9 | # This library is distributed in the hope that it will be useful, but WITHOUT 10 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | # details. 13 | # 14 | # You should have received a copy of the GNU Lesser General Public License 15 | # along with this library; if not, write to the Free Software Foundation, Inc., 16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | 18 | FROM andrewosh/binder-base 19 | MAINTAINER Werner Van Geit 20 | 21 | USER root 22 | 23 | RUN apt-get update 24 | RUN apt-get install -y wget libx11-6 python-dev git build-essential libncurses-dev 25 | RUN wget https://bootstrap.pypa.io/get-pip.py 26 | RUN python get-pip.py 27 | RUN wget http://www.neuron.yale.edu/ftp/neuron/versions/v7.4/nrn-7.4.x86_64.deb 28 | RUN dpkg -i nrn-7.4.x86_64.deb 29 | RUN rm nrn-7.4.x86_64.deb 30 | 31 | RUN pip install bluepyopt 32 | 33 | ENV PYTHONPATH /usr/local/nrn/lib/python:$PYTHONPATH 34 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | BluePyOpt - Bluebrain Python Optimisation Library 2 | 3 | BluePyOpt is licensed under the LGPL, unless noted otherwise, e.g., for external 4 | dependencies. See files COPYING and COPYING.lesser for the full license. 5 | Examples and test are BSD-licensed. 6 | External dependencies are either LGPL or BSD-licensed. 7 | See file ACKNOWLEDGEMENTS.txt and AUTHORS.txt for further details. 8 | 9 | Copyright (c) Blue Brain Project/EPFL 2016-2022. 10 | 11 | This program is free software: you can redistribute it and/or modify it under 12 | the terms of the GNU Lesser General Public License as published by the 13 | Free Software Foundation, either version 3 of the License, or (at your option) 14 | any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; 18 | without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 | 21 | See the GNU Lesser General Public License for more details. 22 | 23 | You should have received a copy of the GNU Lesser General Public License 24 | along with this program. If not, see . 25 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include versioneer.py 2 | include bluepyopt/_version.py 3 | include bluepyopt/ephys/static/arbor_mechanisms.json 4 | 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 8 | 9 | include.txt 10 | include AUTHORS.txt 11 | include COPYING 12 | include COPYING.lesser 13 | recursive-include bluepyopt/tests * 14 | -------------------------------------------------------------------------------- /bluepyopt/__init__.py: -------------------------------------------------------------------------------- 1 | """Init script""" 2 | 3 | """ 4 | Copyright (c) 2016-2022, EPFL/Blue Brain Project 5 | 6 | This file is part of BluePyOpt 7 | 8 | This library is free software; you can redistribute it and/or modify it under 9 | the terms of the GNU Lesser General Public License version 3.0 as published 10 | by the Free Software Foundation. 11 | 12 | This library is distributed in the hope that it will be useful, but WITHOUT 13 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 15 | details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with this library; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | """ 21 | 22 | # pylint: disable=W0611 23 | from importlib.metadata import version 24 | 25 | __version__ = version("bluepyopt") 26 | 27 | from . import tools # NOQA 28 | 29 | from .api import * # NOQA 30 | import bluepyopt.optimisations 31 | import bluepyopt.deapext.algorithms 32 | import bluepyopt.stoppingCriteria 33 | import bluepyopt.deapext.optimisations 34 | import bluepyopt.deapext.optimisationsCMA 35 | 36 | # Add some backward compatibility for the time when DEAPoptimisation not in 37 | # deapext yet 38 | # TODO deprecate this 39 | bluepyopt.optimisations.DEAPOptimisation = \ 40 | bluepyopt.deapext.optimisations.DEAPOptimisation 41 | 42 | import bluepyopt.evaluators 43 | import bluepyopt.objectives 44 | import bluepyopt.parameters # NOQA 45 | 46 | # TODO let objects read / write themselves using json 47 | # TODO create 'Variables' class 48 | # TODO use 'locations' instead of 'location' 49 | # TODO add island functionality to optimiser 50 | # TODO add plotting functionality 51 | # TODO show progress bar during optimisation 52 | -------------------------------------------------------------------------------- /bluepyopt/api.py: -------------------------------------------------------------------------------- 1 | """Common API functionality""" 2 | 3 | """ 4 | Copyright (c) 2016-2020, EPFL/Blue Brain Project 5 | 6 | This file is part of BluePyOpt 7 | 8 | This library is free software; you can redistribute it and/or modify it under 9 | the terms of the GNU Lesser General Public License version 3.0 as published 10 | by the Free Software Foundation. 11 | 12 | This library is distributed in the hope that it will be useful, but WITHOUT 13 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 15 | details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with this library; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | """ 21 | 22 | 23 | ''' 24 | import logging 25 | logger = logging.getLogger(__name__) 26 | 27 | 28 | def set_verboselevel(level): 29 | """Set verbose level""" 30 | logger.setLevel(level) 31 | ''' 32 | -------------------------------------------------------------------------------- /bluepyopt/deapext/__init__.py: -------------------------------------------------------------------------------- 1 | """Init script""" 2 | -------------------------------------------------------------------------------- /bluepyopt/deapext/tools/__init__.py: -------------------------------------------------------------------------------- 1 | """Init""" 2 | 3 | from .selIBEA import * # NOQA 4 | -------------------------------------------------------------------------------- /bluepyopt/ephys/__init__.py: -------------------------------------------------------------------------------- 1 | """Init script""" 2 | 3 | """ 4 | Copyright (c) 2016-2020, EPFL/Blue Brain Project 5 | 6 | This file is part of BluePyOpt 7 | 8 | This library is free software; you can redistribute it and/or modify it under 9 | the terms of the GNU Lesser General Public License version 3.0 as published 10 | by the Free Software Foundation. 11 | 12 | This library is distributed in the hope that it will be useful, but WITHOUT 13 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 15 | details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with this library; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | """ 21 | 22 | # pylint: disable=W0511 23 | 24 | from . import base # NOQA 25 | from . import simulators # NOQA 26 | from . import models # NOQA 27 | from . import evaluators # NOQA 28 | from . import mechanisms # NOQA 29 | from . import locations # NOQA 30 | from . import parameterscalers # NOQA 31 | from . import parameters # NOQA 32 | from . import morphologies # NOQA 33 | from . import efeatures # NOQA 34 | from . import objectives # NOQA 35 | from . import protocols # NOQA 36 | from . import responses # NOQA 37 | from . import recordings # NOQA 38 | from . import objectivescalculators # NOQA 39 | from . import stimuli # NOQA 40 | 41 | # TODO create all the necessary abstract methods 42 | # TODO check inheritance structure 43 | # TODO instantiate using 'simulation env' as parameter, instead of cell 44 | -------------------------------------------------------------------------------- /bluepyopt/ephys/acc.py: -------------------------------------------------------------------------------- 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 58 | -------------------------------------------------------------------------------- /bluepyopt/ephys/base.py: -------------------------------------------------------------------------------- 1 | '''Base class for ephys classes''' 2 | 3 | 4 | class BaseEPhys(object): 5 | '''Base class for ephys classes''' 6 | 7 | def __init__(self, name='', comment=''): 8 | self.name = name 9 | self.comment = comment 10 | 11 | def __str__(self): 12 | return '%s: %s (%s)' % (self.__class__.__name__, 13 | self.name, self.comment) 14 | -------------------------------------------------------------------------------- /bluepyopt/ephys/examples/__init__.py: -------------------------------------------------------------------------------- 1 | """Init""" 2 | 3 | from . import simplecell # NOQA 4 | -------------------------------------------------------------------------------- /bluepyopt/ephys/examples/simplecell/__init__.py: -------------------------------------------------------------------------------- 1 | """Init""" 2 | 3 | from .simplecell import * # NOQA 4 | -------------------------------------------------------------------------------- /bluepyopt/ephys/examples/simplecell/simple.swc: -------------------------------------------------------------------------------- 1 | # Dummy granule cell morphology 2 | 1 1 -5.0 0.0 0.0 5.0 -1 3 | 2 1 0.0 0.0 0.0 5.0 1 4 | 3 1 5.0 0.0 0.0 5.0 2 5 | -------------------------------------------------------------------------------- /bluepyopt/ephys/objectivescalculators.py: -------------------------------------------------------------------------------- 1 | """Score calculator classes""" 2 | 3 | """ 4 | Copyright (c) 2016-2020, EPFL/Blue Brain Project 5 | 6 | This file is part of BluePyOpt 7 | 8 | This library is free software; you can redistribute it and/or modify it under 9 | the terms of the GNU Lesser General Public License version 3.0 as published 10 | by the Free Software Foundation. 11 | 12 | This library is distributed in the hope that it will be useful, but WITHOUT 13 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 15 | details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with this library; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | """ 21 | 22 | 23 | class ObjectivesCalculator(object): 24 | 25 | """Score calculator""" 26 | 27 | def __init__( 28 | self, 29 | objectives=None): 30 | """Constructor 31 | 32 | Args: 33 | objectives (list of Objective): objectives over which to calculate 34 | """ 35 | 36 | self.objectives = objectives 37 | 38 | def calculate_scores(self, responses): 39 | """Calculator the score for every objective""" 40 | 41 | return {objective.name: objective.calculate_score(responses) 42 | for objective in self.objectives} 43 | 44 | def calculate_values(self, responses): 45 | """Calculator the value of each objective""" 46 | 47 | return {objective.name: objective.calculate_value(responses) 48 | for objective in self.objectives} 49 | 50 | def __str__(self): 51 | return 'objectives:\n %s' % '\n '.join( 52 | [str(obj) for obj in self.objectives]) \ 53 | if self.objectives is not None else 'objectives:\n' 54 | -------------------------------------------------------------------------------- /bluepyopt/ephys/parameterscalers/__init__.py: -------------------------------------------------------------------------------- 1 | from .parameterscalers import * 2 | -------------------------------------------------------------------------------- /bluepyopt/ephys/serializer.py: -------------------------------------------------------------------------------- 1 | '''Mixin class to make dictionaries''' 2 | 3 | # Disabling lines below, generate error when loading ephys.examples 4 | # from future import standard_library 5 | # standard_library.install_aliases() 6 | 7 | 8 | SENTINAL = 'class' 9 | 10 | 11 | class DictMixin(object): 12 | 13 | '''Mixin class to create dictionaries of selected elements''' 14 | SERIALIZED_FIELDS = () 15 | 16 | @staticmethod 17 | def _serializer(value): 18 | """_serializer""" 19 | if hasattr(value, 'to_dict'): 20 | return value.to_dict() 21 | elif isinstance(value, (list, tuple)) and \ 22 | value and hasattr(value[0], 'to_dict'): 23 | return [v.to_dict() for v in value] 24 | elif (isinstance(value, dict) and value and 25 | hasattr( 26 | next(iter(list(value.values()))), 'to_dict')): 27 | return {k: v.to_dict() for k, v in list(value.items())} 28 | return value 29 | 30 | @staticmethod 31 | def _deserializer(value): 32 | """_deserializer""" 33 | if (isinstance(value, list) and value and 34 | isinstance(value[0], dict) and SENTINAL in value[0]): 35 | return [instantiator(v) for v in value] 36 | elif isinstance(value, dict) and value: 37 | if SENTINAL in value: 38 | return instantiator(value) 39 | model_value = next(iter(list(value.values()))) 40 | if isinstance(model_value, dict) and SENTINAL in model_value: 41 | return {k: instantiator(v) for k, v in list(value.items())} 42 | return value 43 | 44 | def to_dict(self): 45 | '''create dictionary''' 46 | ret = {} 47 | for field in self.SERIALIZED_FIELDS: 48 | ret[field] = DictMixin._serializer(getattr(self, field)) 49 | ret['class'] = repr(self.__class__) 50 | return ret 51 | 52 | @classmethod 53 | def from_dict(cls, fields): 54 | '''create class from serialized values''' 55 | klass = fields[SENTINAL] 56 | assert klass == repr(cls), 'Class names much match %s != %s' % ( 57 | klass, repr(cls)) 58 | del fields['class'] 59 | for name in list(fields.keys()): 60 | fields[name] = DictMixin._deserializer(fields[name]) 61 | return cls(**fields) 62 | 63 | 64 | def instantiator(fields): 65 | """instantiator""" 66 | klass = fields[SENTINAL] 67 | for subclass in DictMixin.__subclasses__(): 68 | if repr(subclass) == klass: 69 | return subclass.from_dict(fields) 70 | raise Exception('Could not find class "%s" to instantiate' % klass) 71 | -------------------------------------------------------------------------------- /bluepyopt/ephys/templates/acc/_json_template.jinja2: -------------------------------------------------------------------------------- 1 | { 2 | "cell_model_name": "{{template_name}}", 3 | {%- if banner %} 4 | "produced_by": "{{banner}}", 5 | {%- endif %} 6 | {%- if morphology %} {# feed morphology separately as a SWC/ASC file #} 7 | {%- if replace_axon is not none %} 8 | "morphology": { 9 | "original": "{{morphology}}", 10 | "replace_axon": "{{replace_axon}}"{%- if modified_morphology is not none %}, 11 | "modified": "{{modified_morphology}}"{%- endif %} 12 | }, 13 | {%- else %} 14 | "morphology": { 15 | "original": "{{morphology}}" 16 | }, 17 | {%- endif %} 18 | {%- else %} 19 | execerror("Template {{template_name}} requires morphology name to instantiate") 20 | {%- endif %} 21 | "label_dict": "{{filenames['label_dict.acc']}}", 22 | "decor": "{{filenames['decor.acc']}}" 23 | } -------------------------------------------------------------------------------- /bluepyopt/ephys/templates/acc/decor_acc_template.jinja2: -------------------------------------------------------------------------------- 1 | (arbor-component 2 | (meta-data (version "0.9-dev")) 3 | (decor 4 | {%- for mech, params in global_mechs.items() %} 5 | {%- if mech is not none %} 6 | {%- if mech in global_scaled_mechs %} 7 | (default (scaled-mechanism (density (mechanism "{{ mech }}" {%- for param in params if param.value is not none %} ("{{ param.name }}" {{ param.value }}){%- endfor %})){%- for param in global_scaled_mechs[mech] %} ("{{ param.name }}" {{ param.scale }}){%- endfor %})) 8 | {%- else %} 9 | (default (density (mechanism "{{ mech }}" {%- for param in params %} ("{{ param.name }}" {{ param.value }}){%- endfor %}))) 10 | {%- endif %} 11 | {%- else %} 12 | {%- for param in params %} 13 | (default ({{ param.name }} {{ param.value }} (scalar 1.0))) 14 | {%- endfor %} 15 | {%- endif %} 16 | {%- endfor %} 17 | 18 | 19 | {%- for loc, mech_parameters in local_mechs.items() %}{# paint-to-region instead of default #} 20 | 21 | {%- for mech, params in mech_parameters.items() %} 22 | {%- if mech is not none %} 23 | {%- if mech in local_scaled_mechs[loc] %} 24 | (paint {{loc.ref}} (scaled-mechanism (density (mechanism "{{ mech }}" {%- for param in params if param.value is not none %} ("{{ param.name }}" {{ param.value }}){%- endfor %})){%- for param in local_scaled_mechs[loc][mech] %} ("{{ param.name }}" {{ param.scale }}){%- endfor %})) 25 | {%- else %} 26 | (paint {{loc.ref}} (density (mechanism "{{ mech }}" {%- for param in params %} ("{{ param.name }}" {{ param.value }}){%- endfor %}))) 27 | {%- endif %} 28 | {%- else %} 29 | {%- for param in params %} 30 | (paint {{loc.ref}} ({{ param.name }} {{ param.value }} (scalar 1.0))) 31 | {%- endfor %} 32 | {%- endif %} 33 | {%- endfor %} 34 | 35 | {%- for synapse_name, mech_params in pprocess_mechs[loc].items() %} 36 | (place {{loc.ref}} (synapse (mechanism "{{ mech_params.mech }}" {%- for param in mech_params.params %} ("{{ param.name }}" {{ param.value }} (scalar 1.0)){%- endfor %})) "{{ synapse_name }}") 37 | {%- endfor %} 38 | 39 | {%- endfor %})) 40 | -------------------------------------------------------------------------------- /bluepyopt/ephys/templates/acc/label_dict_acc_template.jinja2: -------------------------------------------------------------------------------- 1 | (arbor-component 2 | (meta-data (version "0.9-dev")) 3 | (label-dict 4 | {%- for loc, label in label_dict.items() %} 5 | {{ label.defn }} 6 | {%- endfor %})) 7 | -------------------------------------------------------------------------------- /bluepyopt/evaluators.py: -------------------------------------------------------------------------------- 1 | """Cell evaluator class""" 2 | 3 | """ 4 | Copyright (c) 2016-2020, EPFL/Blue Brain Project 5 | 6 | This file is part of BluePyOpt 7 | 8 | This library is free software; you can redistribute it and/or modify it under 9 | the terms of the GNU Lesser General Public License version 3.0 as published 10 | by the Free Software Foundation. 11 | 12 | This library is distributed in the hope that it will be useful, but WITHOUT 13 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 15 | details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with this library; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | """ 21 | 22 | from abc import abstractmethod 23 | 24 | 25 | class Evaluator(object): 26 | 27 | """Evaluator class 28 | 29 | An Evaluator maps a set of parameter values to objective values 30 | Args: 31 | objectives (Objectives): 32 | The objectives that will be the output of the evaluator. 33 | params (Parameters): 34 | The parameters that will be evaluated. 35 | 36 | Attributes: 37 | objectives (Objectives): 38 | Objective objects. 39 | params (Objectives): 40 | Parameter objects. 41 | """ 42 | 43 | def __init__(self, objectives=None, params=None): 44 | self.objectives = objectives 45 | self.params = params 46 | 47 | # TODO add evaluate_with_dicts 48 | @abstractmethod 49 | def evaluate_with_dicts(self, param_dict): 50 | """Evaluate parameter a parameter set (abstract). 51 | 52 | Args: 53 | params (dict with values Parameters, and keys parameter names): 54 | The parameter values to be evaluated. 55 | 56 | Returns: 57 | objectives (dict with values Parameters, and keys objective names): 58 | Dict of Objective with values calculated by the Evaluator. 59 | 60 | """ 61 | 62 | @abstractmethod 63 | def evaluate_with_lists(self, params): 64 | """Evaluate parameter a parameter set (abstract). 65 | 66 | Args: 67 | params (list of Parameters): 68 | The parameter values to be evaluated. 69 | 70 | Returns: 71 | objectives (list of Objectives): 72 | List of Objectives with values calculated by the Evaluator. 73 | 74 | """ 75 | -------------------------------------------------------------------------------- /bluepyopt/ipyp/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BluePyOpt/87325945d120bba99ea51953fe7f1c7f86d58414/bluepyopt/ipyp/__init__.py -------------------------------------------------------------------------------- /bluepyopt/neuroml/NeuroML2_mechanisms/Ca.channel.nml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | NeuroML file containing a single Channel description 5 | 6 | 7 | 8 | NeuroML file containing a single Channel description 9 | 10 | Note: was called Ca_HVA in Hay et al 2011: http://www.opensourcebrain.org/projects/l5bpyrcellhayetal2011 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | Models of Neocortical Layer 5b Pyramidal Cells Capturing a Wide Range of Dendritic and Perisomatic Active Properties, 21 | Etay Hay, Sean Hill, Felix Schürmann, Henry Markram and Idan Segev, PLoS Comp Biol 2011 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | Calcium channels 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /bluepyopt/neuroml/NeuroML2_mechanisms/Ca_HVA.channel.nml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | NeuroML file containing a single Channel description 5 | 6 | 7 | 8 | High voltage activated Ca2+ current. 9 | 10 | Comment from original mod file: 11 | Reuveni, Friedman, Amitai, and Gutnick, J.Neurosci. 1993 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | Models of Neocortical Layer 5b Pyramidal Cells Capturing a Wide Range of Dendritic and Perisomatic Active Properties, 20 | Etay Hay, Sean Hill, Felix Schürmann, Henry Markram and Idan Segev, PLoS Comp Biol 2011 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | Calcium channels 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /bluepyopt/neuroml/NeuroML2_mechanisms/Ih.channel.nml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | NeuroML file containing a single Channel description 5 | 6 | 7 | 8 | Non-specific cation current 9 | 10 | Comment from original mod file: 11 | Reference : : Kole,Hallermann,and Stuart, J. Neurosci. 2006 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | Models of Neocortical Layer 5b Pyramidal Cells Capturing a Wide Range of Dendritic and Perisomatic Active Properties, 20 | Etay Hay, Sean Hill, Felix Schürmann, Henry Markram and Idan Segev, PLoS Comp Biol 2011 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /bluepyopt/neuroml/NeuroML2_mechanisms/Im.channel.nml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | NeuroML file containing a single Channel description 5 | 6 | 7 | 8 | Muscarinic K+ current 9 | 10 | Comment from original mod file: 11 | :Reference : : Adams et al. 1982 - M-currents and other potassium currents in bullfrog sympathetic neurones 12 | :Comment: corrected rates using q10 = 2.3, target temperature 34, orginal 21 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | Models of Neocortical Layer 5b Pyramidal Cells Capturing a Wide Range of Dendritic and Perisomatic Active Properties, 21 | Etay Hay, Sean Hill, Felix Schürmann, Henry Markram and Idan Segev, PLoS Comp Biol 2011 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | K channels 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /bluepyopt/neuroml/NeuroML2_mechanisms/KdShu2007.channel.nml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | NeuroML file containing a single Channel description 8 | 9 | 10 | 11 | K-D current for prefrontal cortical neuron - Yuguo Yu 2007 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | K channels 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 31 | 32 | 33 | 34 | 35 | 36 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /bluepyopt/neuroml/NeuroML2_mechanisms/NaTa_t.channel.nml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | NeuroML file containing a single Channel description 5 | 6 | 7 | 8 | Fast inactivating Na+ current 9 | 10 | Comment from original mod file: 11 | :Reference :Colbert and Pan 2002 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | Models of Neocortical Layer 5b Pyramidal Cells Capturing a Wide Range of Dendritic and Perisomatic Active Properties, 20 | Etay Hay, Sean Hill, Felix Schürmann, Henry Markram and Idan Segev, PLoS Comp Biol 2011 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | Na channels 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /bluepyopt/neuroml/NeuroML2_mechanisms/NaTs2_t.channel.nml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | NeuroML file containing a single Channel description 5 | 6 | 7 | 8 | Fast inactivating Na+ current. Comment from mod file (NaTs2_t.mod): took the NaTa and shifted both activation/inactivation by 6 mv 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | Models of Neocortical Layer 5b Pyramidal Cells Capturing a Wide Range of Dendritic and Perisomatic Active Properties, 17 | Etay Hay, Sean Hill, Felix Schürmann, Henry Markram and Idan Segev, PLoS Comp Biol 2011 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | Na channels 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /bluepyopt/neuroml/NeuroML2_mechanisms/StochKv_deterministic.channel.nml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | NeuroML2 file containing a single Channel description 5 | 6 | 7 | 8 | Deterministic version of StochKv channel. See https://github.com/OpenSourceBrain/BlueBrainProjectShowcase/tree/master/NMC/NEURON/test 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | K channels 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /bluepyopt/neuroml/NeuroML2_mechanisms/pas.channel.nml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | NeuroML file containing a single Channel description 5 | 6 | 7 | 8 | Simple example of a leak/passive conductance. Note: for GENESIS cells with a single leak conductance, 9 | it is better to use the Rm and Em variables for a passive current. 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /bluepyopt/neuroml/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BluePyOpt/87325945d120bba99ea51953fe7f1c7f86d58414/bluepyopt/neuroml/__init__.py -------------------------------------------------------------------------------- /bluepyopt/objectives.py: -------------------------------------------------------------------------------- 1 | """Objective classes""" 2 | 3 | """ 4 | Copyright (c) 2016-2020, EPFL/Blue Brain Project 5 | 6 | This file is part of BluePyOpt 7 | 8 | This library is free software; you can redistribute it and/or modify it under 9 | the terms of the GNU Lesser General Public License version 3.0 as published 10 | by the Free Software Foundation. 11 | 12 | This library is distributed in the hope that it will be useful, but WITHOUT 13 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 15 | details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with this library; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | """ 21 | 22 | 23 | class Objective(object): 24 | 25 | """Objective of the optimisation algorithm""" 26 | 27 | def __init__(self, name, value=None): 28 | """Constructor""" 29 | 30 | self.name = name 31 | self.value = value 32 | -------------------------------------------------------------------------------- /bluepyopt/optimisations.py: -------------------------------------------------------------------------------- 1 | """Optimisation class""" 2 | 3 | """ 4 | Copyright (c) 2016-2020, EPFL/Blue Brain Project 5 | 6 | This file is part of BluePyOpt 7 | 8 | This library is free software; you can redistribute it and/or modify it under 9 | the terms of the GNU Lesser General Public License version 3.0 as published 10 | by the Free Software Foundation. 11 | 12 | This library is distributed in the hope that it will be useful, but WITHOUT 13 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 15 | details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with this library; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | """ 21 | 22 | 23 | class Optimisation(object): 24 | 25 | """Optimisation class""" 26 | 27 | _instance_counter = 0 28 | 29 | def __init__(self, evaluator=None): 30 | """Constructor""" 31 | 32 | self.evaluator = evaluator 33 | -------------------------------------------------------------------------------- /bluepyopt/stoppingCriteria.py: -------------------------------------------------------------------------------- 1 | """Stopping Criteria class""" 2 | 3 | """ 4 | Copyright (c) 2016-2020, EPFL/Blue Brain Project 5 | This file is part of BluePyOpt 6 | This library is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License version 3.0 as published 8 | by the Free Software Foundation. 9 | This library is distributed in the hope that it will be useful, but WITHOUT 10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | details. 13 | You should have received a copy of the GNU Lesser General Public License 14 | along with this library; if not, write to the Free Software Foundation, Inc., 15 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | """ 17 | 18 | 19 | class StoppingCriteria(object): 20 | """Stopping Criteria class""" 21 | 22 | def __init__(self): 23 | """Constructor""" 24 | self.criteria_met = False 25 | pass 26 | 27 | def check(self, kwargs): 28 | """Check if the stopping criteria is met""" 29 | pass 30 | 31 | def reset(self): 32 | self.criteria_met = False 33 | -------------------------------------------------------------------------------- /bluepyopt/tests/.gitignore: -------------------------------------------------------------------------------- 1 | /.coverage 2 | /coverage.xml 3 | /coverage_html/ 4 | -------------------------------------------------------------------------------- /bluepyopt/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BluePyOpt/87325945d120bba99ea51953fe7f1c7f86d58414/bluepyopt/tests/__init__.py -------------------------------------------------------------------------------- /bluepyopt/tests/expected_results.json: -------------------------------------------------------------------------------- 1 | { 2 | "TestL5PCEvaluator.test_eval": { 3 | "bAP.soma.AP_width": 1.9999999999995453, 4 | "bAP.soma.AP_height": 2.50384474984601, 5 | "bAP.soma.Spikecount": 0.0, 6 | "bAP.dend1.AP_amplitude_from_voltagebase": 0.8267263765251129, 7 | "bAP.dend2.AP_amplitude_from_voltagebase": 0.5795372919702172, 8 | "Step3.soma.AP_height": 0.9933359179333321, 9 | "Step3.soma.AHP_slow_time": 1.7605122073692951, 10 | "Step3.soma.ISI_CV": 0.8718173723988226, 11 | "Step3.soma.doublet_ISI": 0.39855072463652236, 12 | "Step3.soma.adaptation_index2": 1.1379787461057103, 13 | "Step3.soma.mean_frequency": 1.7684352065813025, 14 | "Step3.soma.AHP_depth_abs_slow": 2.24354209144176, 15 | "Step3.soma.AP_width": 3.044293354575099, 16 | "Step3.soma.time_to_first_spike": 0.07352941183310188, 17 | "Step3.soma.AHP_depth_abs": 0.8314513271562025, 18 | "Step2.soma.AP_height": 0.40331820266634766, 19 | "Step2.soma.AHP_slow_time": 0.5635329569575162, 20 | "Step2.soma.ISI_CV": 0.4167583130087039, 21 | "Step2.soma.doublet_ISI": 0.08411961809835558, 22 | "Step2.soma.adaptation_index2": 0.9608331502738571, 23 | "Step2.soma.mean_frequency": 0.3526065669686068, 24 | "Step2.soma.AHP_depth_abs_slow": 0.3002832227214548, 25 | "Step2.soma.AP_width": 2.5539797463199387, 26 | "Step2.soma.time_to_first_spike": 1.1294134000889067, 27 | "Step2.soma.AHP_depth_abs": 0.47825588583451795, 28 | "Step1.soma.AP_height": 1.193221084786481, 29 | "Step1.soma.AHP_slow_time": 0.4051335332920494, 30 | "Step1.soma.ISI_CV": 0.6241490491551318, 31 | "Step1.soma.doublet_ISI": 0.4396536563682781, 32 | "Step1.soma.adaptation_index2": 0.1682382448448352, 33 | "Step1.soma.mean_frequency": 0.9054156314648848, 34 | "Step1.soma.AHP_depth_abs_slow": 0.48627438571478304, 35 | "Step1.soma.AP_width": 3.062383612663639, 36 | "Step1.soma.time_to_first_spike": 1.0572856593789417, 37 | "Step1.soma.AHP_depth_abs": 0.770012863966287 38 | } 39 | } -------------------------------------------------------------------------------- /bluepyopt/tests/test_bluepyopt.py: -------------------------------------------------------------------------------- 1 | """Tests of the main bluepyopt module""" 2 | 3 | """ 4 | Copyright (c) 2016-2020, EPFL/Blue Brain Project 5 | 6 | This file is part of BluePyOpt 7 | 8 | This library is free software; you can redistribute it and/or modify it under 9 | the terms of the GNU Lesser General Public License version 3.0 as published 10 | by the Free Software Foundation. 11 | 12 | This library is distributed in the hope that it will be useful, but WITHOUT 13 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 15 | details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with this library; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | """ 21 | 22 | # pylint:disable=W0612 23 | 24 | import pytest 25 | import numpy 26 | 27 | 28 | @pytest.mark.unit 29 | def test_import(): 30 | """bluepyopt: test importing bluepyopt""" 31 | import bluepyopt # NOQA 32 | -------------------------------------------------------------------------------- /bluepyopt/tests/test_deapext/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BluePyOpt/87325945d120bba99ea51953fe7f1c7f86d58414/bluepyopt/tests/test_deapext/__init__.py -------------------------------------------------------------------------------- /bluepyopt/tests/test_deapext/deapext_test_utils.py: -------------------------------------------------------------------------------- 1 | import random 2 | import numpy as np 3 | 4 | from deap import base 5 | from deap import creator 6 | 7 | 8 | def make_mock_population(features_count=5, population_count=5): 9 | """Create pop of inds that we have full control over,creating a DEAP one""" 10 | # TODO: Use mock instead 11 | class Individual(object): 12 | class Fitness(object): 13 | def __init__(self, wvalues, valid): 14 | self.wvalues = wvalues 15 | self.valid = valid 16 | 17 | def __init__(self, wvalues, valid, ibea_fitness): 18 | self.fitness = Individual.Fitness(wvalues, valid) 19 | self.ibea_fitness = ibea_fitness 20 | 21 | MU, SIGMA = 0, 1 22 | np.random.seed(0) 23 | random.seed(0) 24 | 25 | # create individuals w/ a random weight values, and an ibea_fitness 26 | # according to their position 27 | return [Individual(np.random.normal(MU, SIGMA, features_count), bool( 28 | i % 2), i) for i in range(population_count)] 29 | 30 | 31 | def make_population(features_count=5, population_count=5): 32 | '''create population w/ DEAP Individuals 33 | ''' 34 | 35 | creator.create("FitnessMin", base.Fitness, weights=(-1.0, -1.0)) 36 | creator.create("Individual", list, fitness=creator.FitnessMin) 37 | 38 | random.seed(0) 39 | 40 | population = [creator.Individual(range(i * features_count, 41 | (i + 1) * features_count)) 42 | for i in range(population_count)] 43 | return population 44 | -------------------------------------------------------------------------------- /bluepyopt/tests/test_deapext/test_hype.py: -------------------------------------------------------------------------------- 1 | """bluepyopt.deapext.hype tests""" 2 | 3 | import numpy 4 | 5 | import bluepyopt.deapext.hype 6 | 7 | import pytest 8 | 9 | 10 | @pytest.mark.unit 11 | def test_hypeIndicatorExact(): 12 | """deapext.hype: Testing hypeIndicatorExact""" 13 | 14 | points = numpy.asarray([[250., 250.], [0., 0.], [240., 240.]]) 15 | bounds = numpy.asarray([250., 250.]) 16 | 17 | hv = bluepyopt.deapext.hype.hypeIndicatorExact(points, bounds, k=5) 18 | 19 | assert hv[0] == 0 20 | assert hv[1] == 62500 21 | assert hv[2] == 100 22 | 23 | 24 | @pytest.mark.unit 25 | def test_hypeIndicatorSampled(): 26 | """deapext.hype: Testing hypeIndicatorSampled""" 27 | 28 | points = numpy.asarray([[250., 250.], [0., 0.], [240., 240.]]) 29 | bounds = numpy.asarray([250., 250.]) 30 | 31 | numpy.random.seed(42) 32 | hv = bluepyopt.deapext.hype.hypeIndicatorSampled( 33 | points, bounds, nrOfSamples=1000000, k=5 34 | ) 35 | 36 | assert hv[0] == 0 37 | assert hv[1] == 62500 38 | assert numpy.abs((hv[2] / 100) - 1) < 0.05 39 | -------------------------------------------------------------------------------- /bluepyopt/tests/test_deapext/test_optimisationsCMA.py: -------------------------------------------------------------------------------- 1 | """bluepyopt.optimisationsCMA tests""" 2 | 3 | import pytest 4 | import bluepyopt 5 | import bluepyopt.ephys.examples.simplecell 6 | 7 | 8 | @pytest.mark.unit 9 | def test_optimisationsCMA_normspace(): 10 | """deapext.optimisationsCMA: Testing optimisationsCMA normspace""" 11 | 12 | simplecell = bluepyopt.ephys.examples.simplecell.SimpleCell() 13 | evaluator = simplecell.cell_evaluator 14 | optimisation = bluepyopt.deapext.optimisationsCMA.DEAPOptimisationCMA( 15 | evaluator=evaluator) 16 | 17 | x = [n * 0.1 for n in range(len(evaluator.params))] 18 | y = [f2(f1(p)) for p, f1, f2 in zip(x, optimisation.to_norm, 19 | optimisation.to_space)] 20 | 21 | for a, b in zip(x, y): 22 | assert b == pytest.approx(a, abs=1e-5) 23 | 24 | 25 | @pytest.mark.unit 26 | def test_optimisationsCMA_SO_run(): 27 | """deapext.optimisationsCMA: Testing optimisationsCMA run from centroid""" 28 | 29 | simplecell = bluepyopt.ephys.examples.simplecell.SimpleCell() 30 | evaluator = simplecell.cell_evaluator 31 | x = [n * 0.1 for n in range(len(evaluator.params))] 32 | 33 | optimiser = bluepyopt.deapext.optimisationsCMA.DEAPOptimisationCMA 34 | optimisation = optimiser(evaluator=evaluator, centroids=[x]) 35 | pop, hof, log, hist = optimisation.run(max_ngen=2) 36 | 37 | assert log.select("avg")[-1] == pytest.approx(53.3333, abs=1e-4) 38 | assert log.select("std")[-1] == pytest.approx(83.7987, abs=1e-4) 39 | assert pop[0][0] == pytest.approx(0.10525059698894745, abs=1e-6) 40 | assert pop[0][1] == pytest.approx(0.01000000003249999, abs=1e-6) 41 | 42 | 43 | @pytest.mark.unit 44 | def test_optimisationsCMA_MO_run(): 45 | """deapext.optimisationsCMA: Testing optimisationsCMA run from centroid""" 46 | 47 | simplecell = bluepyopt.ephys.examples.simplecell.SimpleCell() 48 | evaluator = simplecell.cell_evaluator 49 | 50 | optimiser = bluepyopt.deapext.optimisationsCMA.DEAPOptimisationCMA 51 | optimisation = optimiser( 52 | selector_name="multi_objective", 53 | offspring_size=3, 54 | evaluator=evaluator, 55 | seed=42 56 | ) 57 | pop, hof, log, hist = optimisation.run(max_ngen=2) 58 | 59 | assert log.select("avg")[-1] == pytest.approx(40., abs=1e-4) 60 | assert log.select("std")[-1] == pytest.approx(16.32993, abs=1e-4) 61 | assert pop[0][0] == pytest.approx(0.09601241274168831, abs=1e-6) 62 | assert pop[0][1] == pytest.approx(0.024646650865379722, abs=1e-6) 63 | -------------------------------------------------------------------------------- /bluepyopt/tests/test_deapext/test_selIBEA.py: -------------------------------------------------------------------------------- 1 | """selIBEA tests""" 2 | 3 | 4 | import deap 5 | import numpy 6 | 7 | import bluepyopt.deapext 8 | from bluepyopt.deapext.tools.selIBEA \ 9 | import (_calc_fitness_components, _mating_selection,) 10 | from .deapext_test_utils import make_mock_population 11 | 12 | import pytest 13 | 14 | 15 | @pytest.mark.unit 16 | def test_calc_fitness_components(): 17 | """deapext.selIBEA: test calc_fitness_components""" 18 | KAPPA = 0.05 19 | population = make_mock_population() 20 | 21 | components = _calc_fitness_components(population, kappa=KAPPA) 22 | 23 | expected = numpy.array( 24 | [ 25 | [1.00000000e+00, 4.30002298e-05, 4.26748513e-09, 2.06115362e-09, 26 | 9.71587289e-03], 27 | [5.11484499e-09, 1.00000000e+00, 2.02317572e-07, 4.79335491e-05, 28 | 3.52720088e-08], 29 | [6.75130710e-07, 1.23735078e+00, 1.00000000e+00, 2.77149617e-01, 30 | 8.37712763e-06], 31 | [2.06115362e-09, 3.04444453e-04, 8.15288827e-08, 1.00000000e+00, 32 | 2.06115362e-09], 33 | [2.06115362e-09, 6.75565231e-04, 4.39228177e-07, 2.12142918e-07, 34 | 1.00000000e+00] 35 | ]) 36 | 37 | assert numpy.allclose(expected, components) 38 | 39 | 40 | @pytest.mark.unit 41 | def test_mating_selection(): 42 | """deapext.selIBEA: test mating selection""" 43 | 44 | PARENT_COUNT = 10 45 | population = make_mock_population() 46 | parents = _mating_selection(population, PARENT_COUNT, 5) 47 | assert len(parents) == PARENT_COUNT 48 | expected = [1, 1, 1, 1, 1, 0, 1, 0, 0, 0] 49 | assert expected == [ind.ibea_fitness for ind in parents] 50 | 51 | 52 | @pytest.mark.unit 53 | def test_selibea_init(): 54 | """deapext.selIBEA: test selIBEA init""" 55 | 56 | deap.creator.create('fit', deap.base.Fitness, weights=(-1.0,)) 57 | deap.creator.create( 58 | 'ind', 59 | numpy.ndarray, 60 | fitness=deap.creator.__dict__['fit']) 61 | 62 | numpy.random.seed(1) 63 | 64 | population = [deap.creator.__dict__['ind'](x) 65 | for x in numpy.random.uniform(0, 1, 66 | (10, 2))] 67 | 68 | for ind in population: 69 | ind.fitness.values = (numpy.random.uniform(0, 1), ) 70 | 71 | mu = 5 72 | parents = bluepyopt.deapext.tools.selIBEA(population, mu) 73 | 74 | assert len(parents) == mu 75 | -------------------------------------------------------------------------------- /bluepyopt/tests/test_deapext/test_stoppingCriteria.py: -------------------------------------------------------------------------------- 1 | """bluepyopt.stoppingCriteria tests""" 2 | 3 | 4 | import bluepyopt.stoppingCriteria 5 | 6 | import pytest 7 | 8 | 9 | @pytest.mark.unit 10 | def test_MaxNGen(): 11 | """deapext.stoppingCriteria: Testing MaxNGen""" 12 | 13 | max_gen = 3 14 | criteria = bluepyopt.deapext.stoppingCriteria.MaxNGen(max_gen) 15 | 16 | assert criteria.criteria_met is False 17 | criteria.check({"gen": max_gen + 1}) 18 | assert criteria.criteria_met is True 19 | criteria.reset() 20 | criteria.check({"gen": max_gen}) 21 | assert criteria.criteria_met is False 22 | -------------------------------------------------------------------------------- /bluepyopt/tests/test_deapext/test_utils.py: -------------------------------------------------------------------------------- 1 | """bluepyopt.utils tests""" 2 | 3 | import multiprocessing 4 | import time 5 | 6 | import bluepyopt.deapext.utils as utils 7 | import pytest 8 | 9 | 10 | def flag(event): 11 | """Send a multiprocessing event.""" 12 | time.sleep(1) 13 | event.set() 14 | 15 | 16 | def catch_event(event): 17 | """Verify that run_next_gen changes when event is caught.""" 18 | # None case 19 | assert utils.run_next_gen(True, None) 20 | 21 | # event is not set case 22 | assert utils.run_next_gen(True, event) 23 | 24 | # event is set by another process case 25 | time.sleep(2) 26 | assert not (utils.run_next_gen(True, event)) 27 | 28 | 29 | @pytest.mark.unit 30 | def test_run_next_gen_condition(): 31 | """deapext.utils: Testing run_next_gen.""" 32 | event = multiprocessing.Event() 33 | p1 = multiprocessing.Process(target=catch_event, args=(event,)) 34 | p2 = multiprocessing.Process(target=flag, args=(event,)) 35 | 36 | p1.start() 37 | p2.start() 38 | 39 | p1.join() 40 | p2.join() 41 | -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BluePyOpt/87325945d120bba99ea51953fe7f1c7f86d58414/bluepyopt/tests/test_ephys/__init__.py -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/test_acc.py: -------------------------------------------------------------------------------- 1 | """Unit tests for acc.""" 2 | 3 | from bluepyopt.ephys.acc import arbor, ArbLabel 4 | 5 | 6 | import pytest 7 | 8 | 9 | @pytest.mark.unit 10 | def test_arbor_labels(): 11 | """Test Arbor labels.""" 12 | 13 | region_label = ArbLabel(type='region', 14 | name='first_branch', 15 | s_expr='(branch 0)') 16 | 17 | assert region_label.defn == '(region-def "first_branch" (branch 0))' 18 | assert region_label.ref == '(region "first_branch")' 19 | assert region_label.name == 'first_branch' 20 | assert region_label.loc == '(branch 0)' 21 | assert region_label == region_label 22 | assert region_label is not None 23 | 24 | locset_label = ArbLabel(type='locset', 25 | name='first_branch_center', 26 | s_expr='(location 0 0.5)') 27 | 28 | assert locset_label.defn == \ 29 | '(locset-def "first_branch_center" (location 0 0.5))' 30 | assert locset_label.ref == '(locset "first_branch_center")' 31 | assert locset_label.name == 'first_branch_center' 32 | assert locset_label.loc == '(location 0 0.5)' 33 | assert locset_label == locset_label 34 | assert locset_label is not None 35 | 36 | assert locset_label != region_label 37 | 38 | arbor.label_dict({region_label.name: region_label.loc, 39 | locset_label.name: locset_label.loc}) 40 | -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/test_init.py: -------------------------------------------------------------------------------- 1 | """bluepy.ephys test""" 2 | 3 | """ 4 | Copyright (c) 2016-2020, EPFL/Blue Brain Project 5 | 6 | This file is part of BluePyOpt 7 | 8 | This library is free software; you can redistribute it and/or modify it under 9 | the terms of the GNU Lesser General Public License version 3.0 as published 10 | by the Free Software Foundation. 11 | 12 | This library is distributed in the hope that it will be useful, but WITHOUT 13 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 15 | details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with this library; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | """ 21 | 22 | # pylint:disable=W0612 23 | 24 | 25 | import pytest 26 | import numpy 27 | 28 | 29 | @pytest.mark.unit 30 | def test_import(): 31 | """ephys: test importing bluepyopt.ephys""" 32 | import bluepyopt.ephys # NOQA 33 | 34 | 35 | @pytest.mark.unit 36 | def test_ephys_base(): 37 | """ephys: test ephys base class""" 38 | import bluepyopt.ephys as ephys 39 | base = ephys.base.BaseEPhys(name='test', comment='comm') 40 | 41 | assert str(base) == 'BaseEPhys: test (comm)' 42 | -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/test_parameters.py: -------------------------------------------------------------------------------- 1 | """ephys.parameters tests""" 2 | 3 | import json 4 | 5 | 6 | import pytest 7 | import numpy 8 | 9 | from . import utils 10 | from bluepyopt import ephys 11 | from bluepyopt.ephys.serializer import instantiator 12 | 13 | import bluepyopt.ephys.examples.simplecell 14 | 15 | 16 | @pytest.mark.unit 17 | def test_pprocessparam_instantiate(): 18 | """ephys.parameters: Testing point process parameter""" 19 | 20 | simplecell = bluepyopt.ephys.examples.simplecell.SimpleCell() 21 | simple_cell = simplecell.cell_model 22 | simple_cell.freeze(simplecell.default_param_values) 23 | sim = simplecell.nrn_sim 24 | 25 | expsyn_mech = ephys.mechanisms.NrnMODPointProcessMechanism( 26 | name='expsyn', 27 | suffix='ExpSyn', 28 | locations=[simplecell.somacenter_loc]) 29 | 30 | expsyn_loc = ephys.locations.NrnPointProcessLocation( 31 | 'expsyn_loc', 32 | pprocess_mech=expsyn_mech) 33 | 34 | expsyn_tau_param = ephys.parameters.NrnPointProcessParameter( 35 | name='expsyn_tau', 36 | param_name='tau', 37 | value=2, 38 | locations=[expsyn_loc]) 39 | 40 | simple_cell.mechanisms.append(expsyn_mech) 41 | simple_cell.params[expsyn_tau_param.name] = expsyn_tau_param 42 | simple_cell.instantiate(sim=sim) 43 | 44 | assert expsyn_mech.pprocesses[0].tau == 2 45 | 46 | simple_cell.destroy(sim=sim) 47 | 48 | 49 | @pytest.mark.unit 50 | def test_serialize(): 51 | """ephys.parameters: Test serialize""" 52 | parameters = utils.make_parameters() 53 | 54 | for param in parameters: 55 | serialized = param.to_dict() 56 | assert isinstance(json.dumps(serialized), str) 57 | deserialized = instantiator(serialized) 58 | assert isinstance(deserialized, param.__class__) 59 | assert deserialized.name == param.__class__.__name__ 60 | 61 | 62 | @pytest.mark.unit 63 | def test_metaparameter(): 64 | """ephys.parameters: Test MetaParameter""" 65 | 66 | dist = "({A} + {B} * math.exp({distance} * {C}) * {value}" 67 | 68 | scaler = ephys.parameterscalers.NrnSegmentSomaDistanceScaler( 69 | distribution=dist, dist_param_names=['A', 'B', 'C']) 70 | 71 | scaler.A = -0.9 72 | scaler.B = 2 73 | scaler.C = 0.003 74 | 75 | meta_param = ephys.parameters.MetaParameter('Param A', scaler, 'A', -1) 76 | 77 | assert meta_param.attr_name == 'A' 78 | assert meta_param.value == -1 79 | assert scaler.A == -1 80 | -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/test_serializer.py: -------------------------------------------------------------------------------- 1 | """Test for ephys.serializer""" 2 | 3 | import json 4 | 5 | import pytest 6 | import numpy 7 | 8 | import bluepyopt.ephys as ephys 9 | 10 | 11 | class ClassforTesting(ephys.serializer.DictMixin): 12 | 13 | """Test class for serializer""" 14 | SERIALIZED_FIELDS = ('string', 'boolean', 'float_', 'list_', 'dict_') 15 | 16 | def __init__(self, string, boolean, float_, list_, dict_): 17 | self.string = string 18 | self.boolean = boolean 19 | self.float_ = float_ 20 | self.list_ = list_ 21 | self.dict_ = dict_ 22 | 23 | 24 | class NestedClassforTesting(ephys.serializer.DictMixin): 25 | 26 | """Nested test class for serializer""" 27 | 28 | SERIALIZED_FIELDS = ('test', 'tuples', 'lists', 'dicts', ) 29 | 30 | def __init__(self, test, tuples, lists, dicts): 31 | self.test = test 32 | self.tuples = tuples 33 | self.lists = lists 34 | self.dicts = dicts 35 | 36 | 37 | @pytest.mark.unit 38 | def test_serializer(): 39 | """ephys.serializer: test serialization of test class""" 40 | tc = ClassforTesting('some string', False, 1.0, [1, 2, 3], {'0': 0}) 41 | serialized = tc.to_dict() 42 | assert isinstance(serialized, dict) 43 | json.dumps(serialized) 44 | 45 | 46 | @pytest.mark.unit 47 | def test_roundtrip_serializer(): 48 | """ephys.serializer: test round trip of serialization of test class""" 49 | 50 | tc = ClassforTesting('some string', False, 1.0, [1, 2, 3], {'0': 0}) 51 | serialized = tc.to_dict() 52 | instantiated = ephys.serializer.instantiator(serialized) 53 | assert isinstance(instantiated, ClassforTesting) 54 | 55 | 56 | @pytest.mark.unit 57 | def test_nested_serializer(): 58 | """ephys.serializer: test a nested serialization of test class""" 59 | 60 | tc = ClassforTesting('some string', False, 1.0, [1, 2, 3], {'0': 0}) 61 | ntc = NestedClassforTesting( 62 | test=tc, tuples=(tc,), 63 | lists=[tc] * 3, dicts={0: tc}) 64 | serialized = ntc.to_dict() 65 | json.dumps(serialized, indent=2) 66 | 67 | instantiated = ephys.serializer.instantiator(serialized) 68 | assert isinstance(instantiated, NestedClassforTesting) 69 | assert isinstance(instantiated.lists[0], ClassforTesting) 70 | assert isinstance(instantiated.dicts[0], ClassforTesting) 71 | 72 | 73 | @pytest.mark.unit 74 | def test_non_instantiable(): 75 | """ephys.serializer: test non instantiable class""" 76 | with pytest.raises(Exception): 77 | ephys.serializer.instantiator( 78 | {'some': 'fake', 'class': ephys.serializer.SENTINAL, }) 79 | -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testdata/acc/CCell/CCell.json: -------------------------------------------------------------------------------- 1 | { 2 | "cell_model_name": "CCell", 3 | "produced_by": "Created by BluePyOpt(1.12.62) at 2022-07-28 17:15:28.166082", 4 | "morphology": { 5 | "original": "CCell.swc" 6 | }, 7 | "label_dict": "CCell_label_dict.acc", 8 | "decor": "CCell_decor.acc" 9 | } -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testdata/acc/CCell/CCell_decor.acc: -------------------------------------------------------------------------------- 1 | (arbor-component 2 | (meta-data (version "0.9-dev")) 3 | (decor 4 | (default (gSKv3_1bar_SKv3_1 65 (scalar 1.0))) 5 | (paint (region "soma") (gSKv3_1bar_SKv3_1 65 (scalar 1.0))) 6 | (paint (region "soma") (gSKv3_1bar_SKv3_1 65 (scalar 1.0))) 7 | (paint (region "dend") (density (mechanism "BBP::Ih"))) 8 | (paint (region "apic") (gSKv3_1bar_SKv3_1 65 (scalar 1.0))) 9 | (paint (region "apic") (gSKv3_1bar_SKv3_1 65 (scalar 1.0))) 10 | (paint (region "apic") (density (mechanism "BBP::Ih"))))) -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testdata/acc/CCell/CCell_label_dict.acc: -------------------------------------------------------------------------------- 1 | (arbor-component 2 | (meta-data (version "0.9-dev")) 3 | (label-dict 4 | (region-def "all" (all)) 5 | (region-def "apic" (tag 4)) 6 | (region-def "axon" (tag 2)) 7 | (region-def "dend" (tag 3)) 8 | (region-def "soma" (tag 1)) 9 | (region-def "myelin" (tag 5)))) -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testdata/acc/CCell/simple_axon_replacement.acc: -------------------------------------------------------------------------------- 1 | (arbor-component 2 | (meta-data 3 | (version "0.9-dev")) 4 | (morphology 5 | (branch 0 -1 6 | (segment 0 7 | (point 5.000000 0.000000 0.000000 0.500000) 8 | (point 35.000000 0.000000 0.000000 0.500000) 9 | 2) 10 | (segment 1 11 | (point 35.000000 0.000000 0.000000 0.500000) 12 | (point 65.000000 0.000000 0.000000 0.500000) 13 | 2)))) -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testdata/acc/expsyn/simple.swc: -------------------------------------------------------------------------------- 1 | # Dummy granule cell morphology 2 | 1 1 -5.0 0.0 0.0 5.0 -1 3 | 2 1 0.0 0.0 0.0 5.0 1 4 | 3 1 5.0 0.0 0.0 5.0 2 5 | -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testdata/acc/expsyn/simple_cell.json: -------------------------------------------------------------------------------- 1 | { 2 | "cell_model_name": "simple_cell", 3 | "produced_by": "Created by BluePyOpt(1.12.113) at 2022-11-07 01:06:09.370611", 4 | "morphology": { 5 | "original": "simple.swc" 6 | }, 7 | "label_dict": "simple_cell_label_dict.acc", 8 | "decor": "simple_cell_decor.acc" 9 | } 10 | -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testdata/acc/expsyn/simple_cell_decor.acc: -------------------------------------------------------------------------------- 1 | (arbor-component 2 | (meta-data (version "0.9-dev")) 3 | (decor 4 | (paint (region "soma") (membrane-capacitance 0.01 (scalar 1.0))) 5 | (paint (region "soma") (density (mechanism "default::pas"))) 6 | (place (locset "somacenter") (synapse (mechanism "default::expsyn" ("tau" 10 (scalar 1.0)))) "expsyn"))) -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testdata/acc/expsyn/simple_cell_label_dict.acc: -------------------------------------------------------------------------------- 1 | (arbor-component 2 | (meta-data (version "0.9-dev")) 3 | (label-dict 4 | (region-def "all" (all)) 5 | (region-def "soma" (tag 1)) 6 | (region-def "axon" (tag 2)) 7 | (region-def "dend" (tag 3)) 8 | (region-def "apic" (tag 4)) 9 | (region-def "myelin" (tag 5)) 10 | (locset-def "somacenter" (location 0 0.5)))) -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testdata/acc/l5pc/C060114A7_axon_replacement.acc: -------------------------------------------------------------------------------- 1 | (arbor-component 2 | (meta-data 3 | (version "0.9-dev")) 4 | (morphology 5 | (branch 0 -1 6 | (segment 0 7 | (point 263.248016 5.356219 -3.380000 0.690000) 8 | (point 262.996735 -9.641676 -3.380000 0.690000) 9 | 2) 10 | (segment 1 11 | (point 262.996735 -9.641676 -3.380000 0.690000) 12 | (point 262.745453 -24.639572 -3.380000 0.690000) 13 | 2) 14 | (segment 2 15 | (point 262.745453 -24.639572 -3.380000 0.460000) 16 | (point 262.494171 -39.637466 -3.380000 0.460000) 17 | 2) 18 | (segment 3 19 | (point 262.494171 -39.637466 -3.380000 0.460000) 20 | (point 262.242889 -54.635365 -3.380000 0.460000) 21 | 2)))) -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testdata/acc/l5pc/l5pc.json: -------------------------------------------------------------------------------- 1 | { 2 | "cell_model_name": "l5pc", 3 | "produced_by": "Created by BluePyOpt(1.12.113) at 2022-11-06 18:21:20.822883", 4 | "morphology": { 5 | "original": "C060114A7.asc", 6 | "replace_axon": "C060114A7_axon_replacement.acc", 7 | "modified": "C060114A7_modified.acc" 8 | }, 9 | "label_dict": "l5pc_label_dict.acc", 10 | "decor": "l5pc_decor.acc" 11 | } 12 | -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testdata/acc/l5pc/l5pc_label_dict.acc: -------------------------------------------------------------------------------- 1 | (arbor-component 2 | (meta-data (version "0.9-dev")) 3 | (label-dict 4 | (region-def "all" (all)) 5 | (region-def "soma" (tag 1)) 6 | (region-def "axon" (tag 2)) 7 | (region-def "dend" (tag 3)) 8 | (region-def "apic" (tag 4)) 9 | (region-def "myelin" (tag 5)))) -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testdata/acc/simplecell/simple.swc: -------------------------------------------------------------------------------- 1 | # Dummy granule cell morphology 2 | 1 1 -5.0 0.0 0.0 5.0 -1 3 | 2 1 0.0 0.0 0.0 5.0 1 4 | 3 1 5.0 0.0 0.0 5.0 2 5 | -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testdata/acc/simplecell/simple_axon_replacement.acc: -------------------------------------------------------------------------------- 1 | (arbor-component 2 | (meta-data 3 | (version "0.9-dev")) 4 | (morphology 5 | (branch 0 -1 6 | (segment 0 7 | (point 5.000000 0.000000 0.000000 0.500000) 8 | (point 20.000000 0.000000 0.000000 0.500000) 9 | 2) 10 | (segment 1 11 | (point 20.000000 0.000000 0.000000 0.500000) 12 | (point 35.000000 0.000000 0.000000 0.500000) 13 | 2) 14 | (segment 2 15 | (point 35.000000 0.000000 0.000000 0.500000) 16 | (point 50.000000 0.000000 0.000000 0.500000) 17 | 2) 18 | (segment 3 19 | (point 50.000000 0.000000 0.000000 0.500000) 20 | (point 65.000000 0.000000 0.000000 0.500000) 21 | 2)))) -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testdata/acc/simplecell/simple_cell.json: -------------------------------------------------------------------------------- 1 | { 2 | "cell_model_name": "simple_cell", 3 | "produced_by": "Created by BluePyOpt(1.12.113) at 2022-11-06 18:29:03.845296", 4 | "morphology": { 5 | "original": "simple.swc", 6 | "replace_axon": "simple_axon_replacement.acc", 7 | "modified": "simple_modified.acc" 8 | }, 9 | "label_dict": "simple_cell_label_dict.acc", 10 | "decor": "simple_cell_decor.acc" 11 | } 12 | -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testdata/acc/simplecell/simple_cell_decor.acc: -------------------------------------------------------------------------------- 1 | (arbor-component 2 | (meta-data (version "0.9-dev")) 3 | (decor 4 | (paint (region "soma") (membrane-capacitance 0.01 (scalar 1.0))) 5 | (paint (region "soma") (density (mechanism "default::hh" ("gnabar" 0.10299326453483033) ("gkbar" 0.027124836082684685)))))) -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testdata/acc/simplecell/simple_cell_label_dict.acc: -------------------------------------------------------------------------------- 1 | (arbor-component 2 | (meta-data (version "0.9-dev")) 3 | (label-dict 4 | (region-def "all" (all)) 5 | (region-def "soma" (tag 1)) 6 | (region-def "axon" (tag 2)) 7 | (region-def "dend" (tag 3)) 8 | (region-def "apic" (tag 4)) 9 | (region-def "myelin" (tag 5)))) -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testdata/acc/simplecell/simple_modified.acc: -------------------------------------------------------------------------------- 1 | (arbor-component 2 | (meta-data 3 | (version "0.9-dev")) 4 | (morphology 5 | (branch 0 -1 6 | (segment 0 7 | (point -5.000000 0.000000 0.000000 5.000000) 8 | (point 0.000000 0.000000 0.000000 5.000000) 9 | 1) 10 | (segment 1 11 | (point 0.000000 0.000000 0.000000 5.000000) 12 | (point 5.000000 0.000000 0.000000 5.000000) 13 | 1)) 14 | (branch 1 -1 15 | (segment 2 16 | (point 5.000000 0.000000 0.000000 0.500000) 17 | (point 20.000000 0.000000 0.000000 0.500000) 18 | 2) 19 | (segment 3 20 | (point 20.000000 0.000000 0.000000 0.500000) 21 | (point 35.000000 0.000000 0.000000 0.500000) 22 | 2) 23 | (segment 4 24 | (point 35.000000 0.000000 0.000000 0.500000) 25 | (point 50.000000 0.000000 0.000000 0.500000) 26 | 2) 27 | (segment 5 28 | (point 50.000000 0.000000 0.000000 0.500000) 29 | (point 65.000000 0.000000 0.000000 0.500000) 30 | 2)))) -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testdata/acc/templates/cell_json_template.jinja2: -------------------------------------------------------------------------------- 1 | { 2 | "cell_model_name": "{{template_name}}", 3 | {%- if banner %} 4 | "produced_by": "{{banner}} (from {{ custom_param }})", 5 | {%- endif %} 6 | {%- if morphology %} {# feed morphology separately as a SWC/ASC file #} 7 | {%- if replace_axon is not none %} 8 | "morphology": { 9 | "original": "{{morphology}}", 10 | "replace_axon": {{replace_axon}}, 11 | "modified": "{{modified_morphology}}" 12 | }, 13 | {%- else %} 14 | "morphology": { 15 | "original": "{{morphology}}" 16 | }, 17 | {%- endif %} 18 | {%- else %} 19 | execerror("Template {{template_name}} requires morphology name to instantiate") 20 | {%- endif %} 21 | "label_dict": "{{filenames['label_dict.acc']}}", 22 | "decor": "{{filenames['decor.acc']}}" 23 | } -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testdata/acc/templates/decor_acc_template.jinja2: -------------------------------------------------------------------------------- 1 | (arbor-component 2 | (meta-data (version "0.9-dev")) 3 | (meta-data (info "test-decor")) 4 | (decor 5 | {%- for mech, params in global_mechs.items() %} 6 | {%- if mech is not none %} 7 | {%- if mech in global_scaled_mechs %} 8 | (default (scaled-mechanism (density (mechanism "{{ mech }}" {%- for param in params if param.value is not none %} ("{{ param.name }}" {{ param.value }}){%- endfor %})){%- for param in global_scaled_mechs[mech] %} ("{{ param.name }}" {{ param.scale }}){%- endfor %})) 9 | {%- else %} 10 | (default (density (mechanism "{{ mech }}" {%- for param in params %} ("{{ param.name }}" {{ param.value }}){%- endfor %}))) 11 | {%- endif %} 12 | {%- else %} 13 | {%- for param in params %} 14 | (default ({{ param.name }} {{ param.value }} (scalar 1.0))) 15 | {%- endfor %} 16 | {%- endif %} 17 | {%- endfor %} 18 | 19 | {%- for loc, mech_parameters in local_mechs.items() %}{# paint-to-region instead of default #} 20 | {%- for mech, params in mech_parameters.items() %} 21 | {%- if mech is not none %} 22 | {%- if mech in local_scaled_mechs[loc] %} 23 | (paint {{loc.ref}} (scaled-mechanism (density (mechanism "{{ mech }}" {%- for param in params if param.value is not none %} ("{{ param.name }}" {{ param.value }}){%- endfor %})){%- for param in local_scaled_mechs[loc][mech] %} ("{{ param.name }}" {{ param.scale }}){%- endfor %})) 24 | {%- else %} 25 | (paint {{loc.ref}} (density (mechanism "{{ mech }}" {%- for param in params %} ("{{ param.name }}" {{ param.value }}){%- endfor %}))) 26 | {%- endif %} 27 | {%- else %} 28 | {%- for param in params %} 29 | (paint {{loc.ref}} ({{ param.name }} {{ param.value }} (scalar 1.0))) 30 | {%- endfor %} 31 | {%- endif %} 32 | {%- endfor %} 33 | {%- endfor %})) 34 | -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testdata/acc/templates/label_dict_acc_template.jinja2: -------------------------------------------------------------------------------- 1 | (arbor-component 2 | (meta-data (version "0.9-dev")) 3 | (meta-data (info "test-label-dict")) 4 | (label-dict 5 | {%- for loc, label in label_dict.items() %}{# this is a comment #} 6 | {{ label.defn }} 7 | {%- endfor %})) 8 | -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testdata/apic.swc: -------------------------------------------------------------------------------- 1 | # Dummy cell morphology 2 | 1 1 -5.0 0.0 0.0 5.0 -1 3 | 2 1 0.0 0.0 0.0 5.0 1 4 | 3 1 5.0 0.0 0.0 5.0 2 5 | 4 4 5.0 0.0 0.0 1.0 3 6 | 5 4 20.0 0.0 0.0 1.0 4 7 | -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testdata/lfpy_soma_time.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BluePyOpt/87325945d120bba99ea51953fe7f1c7f86d58414/bluepyopt/tests/test_ephys/testdata/lfpy_soma_time.npy -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testdata/lfpy_soma_voltage.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BluePyOpt/87325945d120bba99ea51953fe7f1c7f86d58414/bluepyopt/tests/test_ephys/testdata/lfpy_soma_voltage.npy -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testdata/lfpy_time.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BluePyOpt/87325945d120bba99ea51953fe7f1c7f86d58414/bluepyopt/tests/test_ephys/testdata/lfpy_time.npy -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testdata/lfpy_voltage.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BluePyOpt/87325945d120bba99ea51953fe7f1c7f86d58414/bluepyopt/tests/test_ephys/testdata/lfpy_voltage.npy -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testdata/simple.swc: -------------------------------------------------------------------------------- 1 | # Dummy granule cell morphology 2 | 1 1 -5.0 0.0 0.0 5.0 -1 3 | 2 1 0.0 0.0 0.0 5.0 1 4 | 3 1 5.0 0.0 0.0 5.0 2 5 | -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testdata/simple.wrong: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BluePyOpt/87325945d120bba99ea51953fe7f1c7f86d58414/bluepyopt/tests/test_ephys/testdata/simple.wrong -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testdata/simple_ax1.swc: -------------------------------------------------------------------------------- 1 | # Dummy granule cell morphology 2 | 1 1 -5.0 0.0 0.0 5.0 -1 3 | 2 1 0.0 0.0 0.0 5.0 1 4 | 3 1 5.0 0.0 0.0 5.0 2 5 | 4 2 5.0 0.0 0.0 1.0 3 6 | 5 2 10.0 0.0 0.0 1.0 4 7 | -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testdata/simple_ax2.asc: -------------------------------------------------------------------------------- 1 | ; V3 text file written for MicroBrightField products. 2 | 3 | ("CellBody" 4 | (CellBody) 5 | ( -5 0 0 0) ; 1, 1 6 | ( 0 -5 0 0) ; 1, 2 7 | ( 5 0 0 0) ; 1, 3 8 | ( 0 5 0 0) ; 1, 4 9 | ) 10 | 11 | ( (Axon) 12 | ( 5 0 0 .5) ; Root 13 | ( 10 0 0 .5) ; 1, R 14 | ( 15 | ( 20 0 0 .5) ; 1, R-1 16 | ( 1000 0 0 .5) ; 2 17 | ) 18 | ) 19 | -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testdata/simple_ax2.swc: -------------------------------------------------------------------------------- 1 | # Dummy granule cell morphology 2 | 1 1 -5.0 0.0 0.0 5.0 -1 3 | 2 1 0.0 0.0 0.0 5.0 1 4 | 3 1 5.0 0.0 0.0 5.0 2 5 | 4 2 5.0 0.0 0.0 1.0 3 6 | 5 2 10.0 0.0 0.0 1.0 4 7 | 6 2 100.0 0.0 0.0 1.0 5 8 | -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/testmodels/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BluePyOpt/87325945d120bba99ea51953fe7f1c7f86d58414/bluepyopt/tests/test_ephys/testmodels/__init__.py -------------------------------------------------------------------------------- /bluepyopt/tests/test_ephys/utils.py: -------------------------------------------------------------------------------- 1 | """EPhys test utils""" 2 | 3 | from bluepyopt import ephys 4 | from bluepyopt.ephys.parameters import ( 5 | NrnGlobalParameter, NrnSectionParameter, NrnRangeParameter,) 6 | from bluepyopt.ephys.locations import NrnSeclistLocation 7 | 8 | 9 | def make_mech(): 10 | """Create mechanism""" 11 | basal = ephys.locations.NrnSeclistLocation('basal', seclist_name='basal') 12 | apical = ephys.locations.NrnSeclistLocation( 13 | 'apical', seclist_name='apical') 14 | return ephys.mechanisms.NrnMODMechanism( 15 | 'Ih', 16 | suffix='Ih', 17 | locations=[ 18 | basal, 19 | apical, 20 | ]) 21 | 22 | 23 | def make_parameters(): 24 | """Create parameters""" 25 | value, frozen, bounds, param_name = 65, False, [ 26 | 0, 100.0], 'gSKv3_1bar_SKv3_1' 27 | value_scaler = ephys.parameterscalers.NrnSegmentLinearScaler() 28 | locations = (NrnSeclistLocation('Location0', 'somatic'), 29 | NrnSeclistLocation('Location1', 'apical'),) 30 | parameters = ( 31 | NrnGlobalParameter( 32 | 'NrnGlobalParameter', 33 | value, 34 | frozen, 35 | bounds, 36 | param_name), 37 | NrnSectionParameter( 38 | 'NrnSectionParameter', 39 | value, 40 | frozen, 41 | bounds, 42 | param_name, 43 | value_scaler, 44 | locations), 45 | NrnRangeParameter( 46 | 'NrnRangeParameter', 47 | value, 48 | frozen, 49 | bounds, 50 | param_name, 51 | value_scaler, 52 | locations), 53 | ) 54 | return parameters 55 | -------------------------------------------------------------------------------- /bluepyopt/tests/test_evaluators.py: -------------------------------------------------------------------------------- 1 | """bluepyopt.evaluators tests""" 2 | 3 | """ 4 | Copyright (c) 2016-2020, EPFL/Blue Brain Project 5 | 6 | This file is part of BluePyOpt 7 | 8 | This library is free software; you can redistribute it and/or modify it under 9 | the terms of the GNU Lesser General Public License version 3.0 as published 10 | by the Free Software Foundation. 11 | 12 | This library is distributed in the hope that it will be useful, but WITHOUT 13 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 15 | details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with this library; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | """ 21 | 22 | # pylint:disable=W0612 23 | 24 | 25 | import pytest 26 | import numpy 27 | import bluepyopt 28 | 29 | 30 | @pytest.mark.unit 31 | def test_evaluator_init(): 32 | """bluepyopt.evaluators: test Evaluator init""" 33 | 34 | evaluator = bluepyopt.evaluators.Evaluator() 35 | assert isinstance(evaluator, bluepyopt.evaluators.Evaluator) 36 | -------------------------------------------------------------------------------- /bluepyopt/tests/test_lfpy.py: -------------------------------------------------------------------------------- 1 | """Functional LFPy test""" 2 | 3 | import os 4 | import sys 5 | 6 | import pytest 7 | 8 | L5PC_LFPY_PATH = os.path.abspath( 9 | os.path.join(os.path.dirname(__file__), "../../examples/l5pc_lfpy") 10 | ) 11 | SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) 12 | 13 | sys.path.insert(0, L5PC_LFPY_PATH) 14 | 15 | import l5pc_lfpy_evaluator 16 | from generate_extra_features import release_params 17 | 18 | 19 | @pytest.mark.slow 20 | def test_lfpy_evaluator(): 21 | """Test CellEvaluator with an LFPy cell and LFPy simulator""" 22 | 23 | evaluator = l5pc_lfpy_evaluator.create( 24 | feature_file=L5PC_LFPY_PATH + "/extra_features.json", 25 | cvode_active=False, 26 | dt=0.025, 27 | ) 28 | 29 | responses = evaluator.run_protocols( 30 | protocols=evaluator.fitness_protocols.values(), 31 | param_values=release_params, 32 | ) 33 | values = evaluator.fitness_calculator.calculate_values(responses) 34 | 35 | assert len(values) == 21 36 | assert abs(values["Step1.soma.AP_height"] - 27.85963902931001) < 1e-5 37 | assert len(responses["Step1.MEA.v"]["voltage"]) == 40 38 | -------------------------------------------------------------------------------- /bluepyopt/tests/test_simplecell.py: -------------------------------------------------------------------------------- 1 | """Simple cell example test class""" 2 | 3 | import os 4 | import sys 5 | 6 | SIMPLECELL_PATH = os.path.abspath( 7 | os.path.join(os.path.dirname(__file__), "../../examples/simplecell") 8 | ) 9 | 10 | # sys.path.insert(0, SIMPLECELL_PATH) 11 | 12 | 13 | class TestSimpleCellClass(object): 14 | """Simple cell example test class for NEURON""" 15 | 16 | def setup_method(self): 17 | """Setup""" 18 | self.old_cwd = os.getcwd() 19 | self.old_stdout = sys.stdout 20 | 21 | os.chdir(SIMPLECELL_PATH) 22 | sys.stdout = open(os.devnull, "w") 23 | 24 | def test_exec(self): 25 | """Simplecell NEURON: test execution""" 26 | # When using import instead of execfile this doesn't work 27 | # Probably because multiprocessing doesn't work correctly during 28 | # import 29 | if sys.version_info[0] < 3: 30 | execfile("simplecell.py") # NOQA 31 | else: 32 | with open("simplecell.py") as sc_file: 33 | exec(compile(sc_file.read(), "simplecell.py", "exec")) # NOQA 34 | 35 | def teardown_method(self): 36 | """Tear down""" 37 | 38 | sys.stdout = self.old_stdout 39 | os.chdir(self.old_cwd) 40 | 41 | 42 | class TestSimpleCellArborClass(object): 43 | """Simple cell example test class for Arbor""" 44 | 45 | def setup_method(self): 46 | """Setup""" 47 | self.old_cwd = os.getcwd() 48 | self.old_stdout = sys.stdout 49 | 50 | os.chdir(SIMPLECELL_PATH) 51 | sys.stdout = open(os.devnull, "w") 52 | 53 | def test_exec(self): 54 | """Simplecell Arbor: test execution""" 55 | # When using import instead of execfile this doesn't work 56 | # Probably because multiprocessing doesn't work correctly during 57 | # import 58 | if sys.version_info[0] < 3: 59 | execfile("simplecell_arbor.py") # NOQA 60 | else: 61 | with open("simplecell_arbor.py") as sc_file: 62 | exec(compile(sc_file.read(), "simplecell_arbor.py", "exec")) # NOQA 63 | 64 | def teardown_method(self): 65 | """Tear down""" 66 | 67 | sys.stdout = self.old_stdout 68 | os.chdir(self.old_cwd) 69 | -------------------------------------------------------------------------------- /bluepyopt/tests/test_tools.py: -------------------------------------------------------------------------------- 1 | """Test bluepyopt.tools""" 2 | 3 | import pytest 4 | 5 | 6 | @pytest.mark.unit 7 | def test_load(): 8 | """bluepyopt.tools: test import""" 9 | 10 | import bluepyopt.tools # NOQA 11 | 12 | 13 | @pytest.mark.unit 14 | def test_uint32_seed(): 15 | """bluepyopt.tools: test uint32_seed""" 16 | 17 | import bluepyopt.tools as bpoptools 18 | 19 | assert bpoptools.uint32_seed("test") == 640136438 20 | 21 | import random 22 | random.seed(1) 23 | 24 | hashes = [] 25 | strings = [] 26 | for _ in range(1000): 27 | string = ''.join( 28 | (chr(random.randint(0, 127)) for x in 29 | range(random.randint(10, 255)))) 30 | strings.append(string) 31 | hashes.append(bpoptools.uint32_seed(string)) 32 | 33 | assert len(strings) == len(set(strings)) 34 | assert len(hashes) == len(set(hashes)) 35 | 36 | import numpy 37 | for hash_value in hashes: 38 | assert hash_value == numpy.uint32(hash_value) 39 | -------------------------------------------------------------------------------- /bluepyopt/tools.py: -------------------------------------------------------------------------------- 1 | """BluePyOpt tools""" 2 | 3 | import hashlib 4 | 5 | 6 | def uint32_seed(string): 7 | """Get unsigned int seed of a string""" 8 | 9 | hex_value = hashlib.md5(string.encode('utf-8')).hexdigest() 10 | 11 | return int(hex_value, 16) & 0xFFFFFFFF 12 | -------------------------------------------------------------------------------- /cloud-config/config/amazon/ansible.cfg: -------------------------------------------------------------------------------- 1 | [defaults] 2 | inventory = ./hosts 3 | private_key_file = single_cell_opt.pem 4 | remote_user = ubuntu 5 | host_key_checking = False 6 | 7 | [ssh_connection] 8 | ssh_args = -F amazon_ssh_config 9 | -------------------------------------------------------------------------------- /cloud-config/config/amazon/site.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Install Neuron Optimizer Framework Head 4 | hosts: neuron-optimizer-head 5 | sudo: true 6 | 7 | vars_files: 8 | - vars.yaml 9 | 10 | roles: 11 | - scoop-master 12 | 13 | - name: Install Neuron Optimizer Framework Worker 14 | hosts: neuron-optimizer-worker 15 | sudo: true 16 | 17 | vars_files: 18 | - vars.yaml 19 | 20 | roles: 21 | - base 22 | 23 | - name: Install Neuron Optimizer Framework Worker 24 | hosts: neuron-optimizer-worker 25 | become: yes 26 | become_user: "{{ user_name }}" 27 | 28 | vars_files: 29 | - vars.yaml 30 | 31 | roles: 32 | - neuron 33 | - deap 34 | 35 | #- name: Granule Example 36 | # hosts: neuron-optimizer-worker-granule 37 | # sudo: true 38 | # 39 | # vars_files: 40 | # - vars.yaml 41 | # 42 | # roles: 43 | # - granule-example 44 | -------------------------------------------------------------------------------- /cloud-config/config/amazon/vars.yaml: -------------------------------------------------------------------------------- 1 | user_name: neuron 2 | workspace: ~/workspace 3 | venv: "{{workspace}}/venv" 4 | build_dir: "{{workspace}}/build" 5 | install_dir: "{{workspace}}/install" 6 | add_bin_path: true 7 | 8 | using_headnode: true 9 | 10 | neuron_build: "{{workspace}}/build/neuron" 11 | neuron_url: http://www.neuron.yale.edu/ftp/neuron/versions/v7.4/nrn-7.4.tar.gz 12 | neuron_version: 7.4 13 | neuron_config: >- 14 | ./configure 15 | --prefix=`readlink -f {{ install_dir }}`/nrnpython 16 | --with-nrnpython 17 | --without-paranrn 18 | --without-x 19 | --without-iv 20 | have_cython=no 21 | BUILD_RX3D=0 22 | 23 | # if only an old version of python is available, you may need to set this true: 24 | python27_build: false 25 | python27_url: https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz 26 | python27_version: 2.7.11 27 | 28 | pip_version: 7.1.2 29 | numpy_version: 1.10.4 30 | efel_version: 2.10.7 31 | scoop_version: 0.7.1.1 32 | jupyter_version: 1.0.0 33 | matplotlib_version: 1.5.1 34 | -------------------------------------------------------------------------------- /cloud-config/config/cluster-user/README.md: -------------------------------------------------------------------------------- 1 | # Cluster User 2 | 3 | If you are not the administrator of a cluster, but have access to one, this 4 | document outlines how to setup a working environment that can be used for 5 | optimization. 6 | 7 | Note: It is assumed that on this cluster, there is a shared file-system where the 8 | software can be installed once and then used by all allocation of resources. 9 | 10 | ## Basic Configuration 11 | 12 | 1. Make sure that there is a virtual environment from which you will run 13 | `Ansible`, read the documentation [here](../../README.md) to set one up. 14 | 15 | 2. In the cluster-user directory, modify the `hosts` file to include the cluster head node, 16 | the contents should be a single stanza with a single line: 17 | ``` 18 | [neuron-optimizer-worker] 19 | dns.name.of.head.node 20 | ``` 21 | 22 | 3. If the username is different for the cluster from on the host it's being 23 | configured from, the `user_name` in `vars.yaml` will have to be changed to 24 | this new name. One can also set an absolute path in for `workspace` in 25 | `vars.yaml` to modify the installation path. 26 | 27 | 4. If the python version available on the cluster isn't at least 2.7, then it 28 | is recommended to modify `python27_build` in `vars.yaml` to be 'true' such 29 | that a local version of Python will be compiled. 30 | 31 | ## Installation Information 32 | 33 | Run the installation by issuing: 34 | ``` 35 | $ source ./venv-ansible/bin/activate 36 | $ ansible-playbook site.yaml 37 | ``` 38 | 39 | Once it has run, there should be a `~/workspace` directory on the cluster with 40 | all the required software as described [here](../README.md) under 41 | 'Installation Information'. 42 | -------------------------------------------------------------------------------- /cloud-config/config/cluster-user/ansible.cfg: -------------------------------------------------------------------------------- 1 | [defaults] 2 | inventory = ./hosts 3 | -------------------------------------------------------------------------------- /cloud-config/config/cluster-user/hosts: -------------------------------------------------------------------------------- 1 | [neuron-optimizer-worker] 2 | viz1 3 | -------------------------------------------------------------------------------- /cloud-config/config/cluster-user/site.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Install Neuron Optimizer Framework Worker 3 | hosts: neuron-optimizer-worker 4 | 5 | vars_files: 6 | - vars.yaml 7 | 8 | roles: 9 | - neuron 10 | - deap 11 | 12 | #- name: Granule Example 13 | # hosts: neuron-optimizer-worker-granule 14 | # sudo: true 15 | # 16 | # vars_files: 17 | # - vars.yaml 18 | # 19 | # roles: 20 | # - granule-example 21 | -------------------------------------------------------------------------------- /cloud-config/config/cluster-user/vars.yaml: -------------------------------------------------------------------------------- 1 | #Note: you may need to change this 2 | user_name: "{{ ansible_user_id }}" 3 | workspace: ~/workspace 4 | venv: "{{workspace}}/venv" 5 | build_dir: "{{workspace}}/build" 6 | install_dir: "{{workspace}}/install" 7 | add_bin_path: false 8 | 9 | using_headnode: false 10 | 11 | neuron_build: "{{workspace}}/build/neuron" 12 | neuron_url: http://www.neuron.yale.edu/ftp/neuron/versions/v7.4/nrn-7.4.tar.gz 13 | neuron_version: 7.4 14 | neuron_config: >- 15 | ./configure 16 | --prefix=`readlink -f {{ install_dir }}`/nrnpython 17 | --with-nrnpython 18 | --without-paranrn 19 | --without-x 20 | --without-iv 21 | have_cython=no 22 | BUILD_RX3D=0 23 | 24 | # if only an old version of python is available, you may need to set this true: 25 | python27_build: false 26 | python27_url: https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz 27 | python27_version: 2.7.11 28 | 29 | pip_version: 7.1.2 30 | numpy_version: 1.10.4 31 | efel_version: 2.10.7 32 | scoop_version: 0.7.1.1 33 | jupyter_version: 1.0.0 34 | matplotlib_version: 1.5.1 35 | -------------------------------------------------------------------------------- /cloud-config/config/vagrant/README.md: -------------------------------------------------------------------------------- 1 | # Vagrant Setup 2 | 3 | 1. Install vagrant 4 | 5 | 2. Get the trusty64 box: 6 | 7 | `$ vagrant box add ubuntu/trusty64` 8 | 9 | 3. Use the included `Vagrantfile` to bring up 4 machines: 10 | This includes: 11 | - *head*: 192.168.61.10 12 | - *worker0*: 192.168.61.20 13 | - *worker1*: 192.168.61.21 14 | - *worker2*: 192.168.61.22 15 | 16 | 4. Boot the vagrant instances: 17 | 18 | `$ vagrant up` 19 | 20 | ## Configure with Ansible 21 | 22 | Note: Make sure that there is a virtual environment from which you will run 23 | `Ansible`, read the documentation [here](../../README.md) to set one up. 24 | 25 | ``` 26 | $ source ./venv-ansible/activate 27 | $ ansible-playbook site.yaml 28 | ``` 29 | 30 | Notes: 31 | - `hosts.example` defines the host groups, and uses the running Vagrant instances. 32 | - `ansible.cfg` defines some defaults (like `hosts.example` and which ssh key to use) 33 | - One can `vagrant destroy` and then `vagrant up` to start from a clean slate 34 | -------------------------------------------------------------------------------- /cloud-config/config/vagrant/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! 5 | VAGRANTFILE_API_VERSION = "2" 6 | 7 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 8 | config.vm.define "head" do |inventory| 9 | inventory.vm.box = "ubuntu/trusty64" 10 | inventory.vm.network "private_network", ip: "192.168.61.10" 11 | end 12 | 13 | config.vm.define "worker0" do |inventory| 14 | inventory.vm.box = "ubuntu/trusty64" 15 | inventory.vm.network "private_network", ip: "192.168.61.20" 16 | end 17 | config.vm.define "worker1" do |inventory| 18 | inventory.vm.box = "ubuntu/trusty64" 19 | inventory.vm.network "private_network", ip: "192.168.61.21" 20 | end 21 | config.vm.define "worker2" do |inventory| 22 | inventory.vm.box = "ubuntu/trusty64" 23 | inventory.vm.network "private_network", ip: "192.168.61.22" 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /cloud-config/config/vagrant/ansible.cfg: -------------------------------------------------------------------------------- 1 | [defaults] 2 | inventory = ./hosts 3 | private_key_file = ~/.vagrant.d/insecure_private_key 4 | remote_user = vagrant 5 | host_key_checking = False 6 | -------------------------------------------------------------------------------- /cloud-config/config/vagrant/hosts: -------------------------------------------------------------------------------- 1 | [neuron-optimizer-head] 2 | 192.168.61.10 3 | 4 | [neuron-optimizer-worker] 5 | 192.168.61.10 6 | 192.168.61.20 7 | 192.168.61.21 8 | 192.168.61.22 9 | 10 | [neuron-optimizer-worker-granule] 11 | 192.168.61.10 12 | 192.168.61.20 13 | 192.168.61.21 14 | 192.168.61.22 15 | -------------------------------------------------------------------------------- /cloud-config/config/vagrant/site.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Install Neuron Optimizer Framework Head 4 | hosts: neuron-optimizer-head 5 | sudo: true 6 | 7 | vars_files: 8 | - vars.yaml 9 | 10 | roles: 11 | - scoop-master 12 | 13 | - name: Install Neuron Optimizer Framework Worker 14 | hosts: neuron-optimizer-worker 15 | sudo: true 16 | 17 | vars_files: 18 | - vars.yaml 19 | 20 | roles: 21 | - base 22 | 23 | - name: Install Neuron Optimizer Framework Worker 24 | hosts: neuron-optimizer-worker 25 | become: yes 26 | become_user: "{{ user_name }}" 27 | 28 | vars_files: 29 | - vars.yaml 30 | 31 | roles: 32 | - neuron 33 | - deap 34 | 35 | #- name: Granule Example 36 | # hosts: neuron-optimizer-worker-granule 37 | # sudo: true 38 | # 39 | # vars_files: 40 | # - vars.yaml 41 | # 42 | # roles: 43 | # - granule-example 44 | -------------------------------------------------------------------------------- /cloud-config/config/vagrant/vars.yaml: -------------------------------------------------------------------------------- 1 | user_name: neuron 2 | workspace: ~/workspace 3 | venv: "{{workspace}}/venv" 4 | build_dir: "{{workspace}}/build" 5 | install_dir: "{{workspace}}/install" 6 | add_bin_path: true 7 | 8 | using_headnode: true 9 | 10 | neuron_build: "{{workspace}}/build/neuron" 11 | neuron_url: http://www.neuron.yale.edu/ftp/neuron/versions/v7.4/nrn-7.4.tar.gz 12 | neuron_version: 7.4 13 | neuron_config: >- 14 | ./configure 15 | --prefix=`readlink -f {{ install_dir }}`/nrnpython 16 | --with-nrnpython 17 | --without-paranrn 18 | --without-x 19 | --without-iv 20 | have_cython=no 21 | BUILD_RX3D=0 22 | 23 | # if only an old version of python is available, you may need to set this true: 24 | python27_build: true 25 | python27_url: https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz 26 | python27_version: 2.7.11 27 | 28 | pip_version: 7.1.2 29 | numpy_version: 1.10.4 30 | efel_version: 2.10.7 31 | scoop_version: 0.7.1.1 32 | jupyter_version: 1.0.0 33 | matplotlib_version: 1.5.1 34 | -------------------------------------------------------------------------------- /cloud-config/roles/base/tasks/main.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | #note: this is for debian and ubuntu distributions 3 | - name: update apt cache 4 | apt: update_cache=yes 5 | 6 | - name: Install base packages 7 | apt: name={{ item }} force=yes state=installed 8 | with_items: 9 | - build-essential 10 | - git 11 | - htop 12 | - libreadline-dev 13 | - libzmq3-dev 14 | - ntp 15 | - python-dev 16 | - python-pip 17 | - python-virtualenv 18 | - unzip 19 | #for matplotlib 20 | - pkg-config 21 | - libfreetype6-dev 22 | tags: packages 23 | 24 | - name: Configure User 25 | user: name={{ user_name }} 26 | -------------------------------------------------------------------------------- /cloud-config/roles/deap/tasks/main.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Upgrade pip 4 | pip: name=pip version="{{ pip_version }}" virtualenv={{ venv }} 5 | 6 | - name: Install numpy 7 | pip: name=numpy version="{{ numpy_version }}" virtualenv={{ venv }} 8 | 9 | - name: Install Jupyter 10 | pip: name=jupyter version="{{ jupyter_version }}" virtualenv={{ venv }} 11 | 12 | - name: Install matplotlib 13 | pip: name=matplotlib version="{{ matplotlib_version }}" virtualenv={{ venv }} 14 | 15 | #Note: using the BBP version of DEAP, as it includes the updated IBEA tools 16 | - name: Install deap 17 | pip: name='git+https://github.com/BlueBrain/deap#egg=deap' virtualenv={{ venv }} 18 | 19 | - name: Install efel 20 | pip: name=efel version="{{ efel_version }}" virtualenv={{ venv }} 21 | 22 | - name: Install scoop 23 | pip: name=scoop version="{{ scoop_version }}" virtualenv={{ venv }} 24 | 25 | #Use the latest version 26 | - name: Install BluePyOpt 27 | pip: name=bluepyopt virtualenv={{ venv }} 28 | 29 | - name: Add virtualenv to setup.sh file 30 | lineinfile: 31 | dest="{{ workspace }}/setup.sh" 32 | create=yes 33 | line="source {{ venv }}/bin/activate" 34 | 35 | - name: Install ssh key 36 | authorized_key: 37 | user: "{{ user_name }}" 38 | key: "{{ lookup('file', 'id_rsa.tmp') }}" 39 | when: "{{ using_headnode }}" 40 | -------------------------------------------------------------------------------- /cloud-config/roles/granule-example/tasks/main.yaml: -------------------------------------------------------------------------------- 1 | - name: Get eFEL Source 2 | git: repo=https://github.com/BlueBrain/eFEL.git dest=~/workspace/eFEL 3 | 4 | - name: Compile models 5 | shell: "{{ install_dir }}/nrnpython/x86_64/bin/nrnivmodl mechanisms" 6 | args: 7 | chdir: "{{ workspace }}/eFEL/examples/deap/GranuleCell1" 8 | creates: "{{ workspace }}/eFEL/examples/deap/GranuleCell1/x86_64" 9 | -------------------------------------------------------------------------------- /cloud-config/roles/neuron/tasks/main.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - include: python27.yaml 3 | when: "{{ python27_build }}" 4 | 5 | - set_fact: extra_path="{{ pythonbin.stdout + ':' }}" 6 | when: python27_build 7 | 8 | - set_fact: extra_path="" 9 | when: not python27_build 10 | 11 | - name: Create directories 12 | file: path={{ item }} state=directory 13 | with_items: 14 | - "{{ workspace }}" 15 | - "{{ neuron_build }}" 16 | 17 | - name: Get Source 18 | get_url: url={{ neuron_url }} dest={{ neuron_build }}/nrn-{{ neuron_version }}.tar.gz 19 | 20 | - name: Untar source 21 | unarchive: copy=no src={{ neuron_build }}/nrn-{{ neuron_version }}.tar.gz dest={{ neuron_build }} 22 | args: 23 | creates: "{{ neuron_build }}/nrn-{{ neuron_version }}/configure" 24 | 25 | - name: Configure Neuron 26 | shell: "{{ neuron_config }}" 27 | environment: 28 | PATH: "{{ extra_path }}{{ ansible_env.PATH }}" 29 | args: 30 | chdir: "{{ neuron_build }}/nrn-{{ neuron_version }}" 31 | creates: "{{ neuron_build }}/nrn-{{ neuron_version }}/config.log" 32 | 33 | - name: Build Neuron 34 | #Note: could use -j here, but this gets oom-killed often 35 | shell: make install 36 | args: 37 | chdir: "{{ neuron_build }}/nrn-{{ neuron_version }}" 38 | creates: "{{ install_dir }}/nrnpython" 39 | 40 | - name: Install numpy 41 | pip: name=numpy version="{{ numpy_version }}" virtualenv="{{ venv }}" 42 | 43 | - name: Install nrnpython 44 | shell: "{{ venv }}/bin/python setup.py install" 45 | args: 46 | chdir: "{{ neuron_build }}/nrn-{{ neuron_version }}/src/nrnpython" 47 | creates: "{{ venv }}/lib/python2.7/site-packages/neuron" 48 | 49 | - name: Add neuron and python virtualenv to path 50 | lineinfile: > 51 | dest=~/.bashrc 52 | state=present 53 | line="export PATH={{ venv }}/bin:{{ install_dir }}/nrnpython/x86_64/bin/:$PATH" 54 | when: "{{ add_bin_path }}" 55 | 56 | - name: Add paths to setup.sh file 57 | lineinfile: 58 | dest="{{ workspace }}/setup.sh" 59 | create=yes 60 | line="export PATH={{ venv }}/bin:{{ install_dir }}/nrnpython/x86_64/bin/:$PATH" 61 | -------------------------------------------------------------------------------- /cloud-config/roles/neuron/tasks/python27.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | #NOTE: need zlib1g-dev, libssl-dev package on ubuntu/debian 3 | 4 | - name: Create directories 5 | file: path={{ item }} state=directory 6 | with_items: 7 | - "{{ workspace }}" 8 | - "{{ build_dir }}/python27" 9 | 10 | - name: Get Source 11 | get_url: url={{ python27_url }} dest="{{ build_dir }}/python27/python-{{ python27_version }}.tar.gz" 12 | 13 | - name: Untar source 14 | unarchive: copy=no src="{{ build_dir }}/python27/python-{{ python27_version }}.tar.gz" dest="{{ build_dir }}/python27" 15 | args: 16 | creates: "{{ build_dir }}/python27/Python-{{ python27_version }}/configure" 17 | 18 | - name: Configure Python 19 | shell: ./configure --prefix=`readlink -f {{ install_dir }}` 20 | args: 21 | chdir: "{{ build_dir }}/python27/Python-{{ python27_version }}" 22 | creates: "{{ build_dir }}/python27/Python-{{ python27_version }}/config.log" 23 | 24 | - name: Build & Install Python 25 | #Note: could use -j here, but this gets oom-killed often 26 | shell: make install 27 | args: 28 | chdir: "{{ build_dir }}/python27/Python-{{ python27_version }}" 29 | creates: "{{ install_dir }}/bin/python2.7" 30 | 31 | - name: Create virtualenv 32 | shell: "/usr/bin/virtualenv -p {{ install_dir }}/bin/python {{ venv }}" 33 | args: 34 | creates: "{{ venv }}/bin/python2.7" 35 | 36 | - name: Register pythonbin 37 | shell: readlink -f {{ install_dir }}/bin/ 38 | register: pythonbin 39 | -------------------------------------------------------------------------------- /cloud-config/roles/scoop-master/tasks/main.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Configure User 3 | user: name={{ user_name }} generate_ssh_key=yes 4 | 5 | - name: Downloading pub key 6 | fetch: src=/home/{{ user_name }}/.ssh/id_rsa.pub dest=id_rsa.tmp flat=yes 7 | 8 | - name: Save SCOOP hostlist 9 | become: yes 10 | become_user: "{{ user_name }}" 11 | copy: content="{{ groups['neuron-optimizer-worker'] | join('\n') }}" dest=/home/{{ user_name }}/scoop_workers 12 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | range: "90...100" 3 | 4 | status: 5 | project: 6 | default: 7 | target: "90%" 8 | threshold: "5%" 9 | patch: false 10 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /docs/source/.gitignore: -------------------------------------------------------------------------------- 1 | /ephys/ 2 | /optimisations/ 3 | /deapext/ 4 | -------------------------------------------------------------------------------- /docs/source/_static/bbp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BluePyOpt/87325945d120bba99ea51953fe7f1c7f86d58414/docs/source/_static/bbp.jpg -------------------------------------------------------------------------------- /docs/source/_templates/module.rst: -------------------------------------------------------------------------------- 1 | {{ fullname }} 2 | {{ underline }} 3 | 4 | .. automodule:: {{ fullname }} 5 | :members: 6 | -------------------------------------------------------------------------------- /docs/source/api.rst: -------------------------------------------------------------------------------- 1 | .. BluePyOpt documentation master file, created by 2 | sphinx-quickstart on Mon May 11 14:40:15 2015. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Python API 7 | ========== 8 | 9 | .. toctree:: 10 | :maxdepth: 3 11 | 12 | optimisations 13 | ephys 14 | deapext 15 | -------------------------------------------------------------------------------- /docs/source/deapext.rst: -------------------------------------------------------------------------------- 1 | Deap extension API 2 | ================== 3 | 4 | .. autosummary:: 5 | :toctree: deapext 6 | :template: module.rst 7 | 8 | bluepyopt.deapext.optimisations 9 | -------------------------------------------------------------------------------- /docs/source/ephys.rst: -------------------------------------------------------------------------------- 1 | EPhys model API 2 | =============== 3 | 4 | .. autosummary:: 5 | :toctree: ephys 6 | :template: module.rst 7 | 8 | bluepyopt.ephys.evaluators 9 | bluepyopt.ephys.models 10 | bluepyopt.ephys.efeatures 11 | bluepyopt.ephys.locations 12 | bluepyopt.ephys.mechanisms 13 | bluepyopt.ephys.morphologies 14 | bluepyopt.ephys.objectives 15 | bluepyopt.ephys.parameters 16 | bluepyopt.ephys.parameterscalers 17 | bluepyopt.ephys.protocols 18 | bluepyopt.ephys.recordings 19 | bluepyopt.ephys.responses 20 | bluepyopt.ephys.objectivescalculators 21 | bluepyopt.ephys.stimuli 22 | -------------------------------------------------------------------------------- /docs/source/index.rst: -------------------------------------------------------------------------------- 1 | .. BluePyOpt documentation master file, created by 2 | sphinx-quickstart on Mon May 11 14:40:15 2015. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | 7 | 8 | .. include:: ../../README.rst 9 | :end-before: .. substitutions 10 | 11 | .. toctree:: 12 | :maxdepth: 3 13 | 14 | Home 15 | api.rst 16 | 17 | Indices and tables 18 | ================== 19 | 20 | * :ref:`genindex` 21 | * :ref:`modindex` 22 | * :ref:`search` 23 | 24 | .. |banner| image:: /logo/BluePyOptBanner.png 25 | .. |landscape_example| image:: ../../examples/simplecell/figures/landscape_example.png 26 | -------------------------------------------------------------------------------- /docs/source/logo/BluePyOptBanner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BluePyOpt/87325945d120bba99ea51953fe7f1c7f86d58414/docs/source/logo/BluePyOptBanner.png -------------------------------------------------------------------------------- /docs/source/logo/BluePyOptLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BluePyOpt/87325945d120bba99ea51953fe7f1c7f86d58414/docs/source/logo/BluePyOptLogo.png -------------------------------------------------------------------------------- /docs/source/optimisations.rst: -------------------------------------------------------------------------------- 1 | General optimisation API 2 | ======================== 3 | 4 | .. autosummary:: 5 | :toctree: optimisations 6 | :template: module.rst 7 | 8 | bluepyopt.optimisations 9 | bluepyopt.parameters 10 | bluepyopt.objectives 11 | bluepyopt.evaluators 12 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # BluePyOpt Examples 2 | 3 | This directory contains examples of optimizations that can be performed with `BluePyOpt`. 4 | They can be used to learn the concepts behind the package, and also as a starting point for other optimizations 5 | 6 | * expsyn: Example optimization of a synapse (a point process) in NEURON 7 | 8 | * graupnerbrunelstdp: Graupner-Brunel STDP model fitting 9 | 10 | * l5pc: Layer 5 pyramidal neuron parameter optimization 11 | 12 | * simplecell: optimisation of simple single compartmental cell with two free parameters 13 | 14 | * stochkv: simple cell optimization with stochastic channels 15 | 16 | * tsodyksmarkramstp: optimizing parameters of the Tsodyks-Markram model of short-term synaptic plasticity 17 | 18 | The expsyn, l5pc and simplecell examples contain an implementation for [Arbor](https://arbor-sim.org/) as an alternative simulator backend to NEURON. 19 | 20 | # Documentation 21 | 22 | [Parallelization with ipyparallel](BluePyOpt-ipyparallel.md) 23 | -------------------------------------------------------------------------------- /examples/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2016-2020, EPFL/Blue Brain Project 3 | 4 | This file is part of BluePyOpt 5 | 6 | This library is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License version 3.0 as published 8 | by the Free Software Foundation. 9 | 10 | This library is distributed in the hope that it will be useful, but WITHOUT 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 13 | details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with this library; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | """ 19 | -------------------------------------------------------------------------------- /examples/expsyn/.gitignore: -------------------------------------------------------------------------------- 1 | .ipynb_checkpoints/ 2 | -------------------------------------------------------------------------------- /examples/expsyn/generate_acc.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | '''Example for generating a mixed JSON/ACC Arbor cable cell description (with optional axon-replacement) 4 | 5 | $ python generate_acc.py --output-dir test_acc/ --replace-axon 6 | 7 | Will save 'simple_cell.json', 'simple_cell_label_dict.acc' and 'simple_cell_decor.acc' 8 | into the folder 'test_acc' that can be loaded in Arbor with: 9 | 'cell_json, morpho, decor, labels = \ 10 | ephys.create_acc.read_acc("test_acc/simple_cell_cell.json")' 11 | An Arbor cable cell can then be created with 12 | 'cell = arbor.cable_cell(morphology=morpho, decor=decor, labels=labels)' 13 | The resulting cable cell can be output to ACC for visual inspection 14 | and e.g. validating/deriving custom Arbor locset/region/iexpr 15 | expressions in the Arbor GUI (File > Cable cell > Load) using 16 | 'arbor.write_component(cell, "simple_cell_cable_cell.acc")' 17 | ''' 18 | import argparse 19 | 20 | from bluepyopt import ephys 21 | 22 | import expsyn 23 | 24 | 25 | def main(): 26 | '''main''' 27 | parser = argparse.ArgumentParser( 28 | formatter_class=argparse.RawDescriptionHelpFormatter, 29 | description=__doc__) 30 | parser.add_argument('-o', '--output-dir', dest='output_dir', 31 | help='Output directory for JSON/ACC files') 32 | parser.add_argument('-ra', '--replace-axon', action='store_true', 33 | help='Replace axon with Neuron-dependent policy') 34 | args = parser.parse_args() 35 | 36 | cell = expsyn.create_model(sim='arb', do_replace_axon=args.replace_axon) 37 | if args.replace_axon: 38 | nrn_sim = ephys.simulators.NrnSimulator() 39 | cell.instantiate_morphology_3d(nrn_sim) 40 | 41 | param_values = {'expsyn_tau': 10.0} 42 | 43 | # Add modcc-compiled external mechanisms catalogues here 44 | # ext_catalogues = {'cat-name': 'path/to/nmodl-dir', ...} 45 | 46 | if args.output_dir is not None: 47 | cell.write_acc(args.output_dir, 48 | param_values, 49 | # ext_catalogues=ext_catalogues, 50 | create_mod_morph=True) 51 | else: 52 | output = cell.create_acc( 53 | param_values, 54 | template='acc/*_template.jinja2', 55 | # ext_catalogues=ext_catalogues, 56 | create_mod_morph=True) 57 | for el, val in output.items(): 58 | print("%s:\n%s\n" % (el, val)) 59 | 60 | 61 | if __name__ == '__main__': 62 | main() 63 | -------------------------------------------------------------------------------- /examples/expsyn/simple.swc: -------------------------------------------------------------------------------- 1 | # Dummy granule cell morphology 2 | 1 1 -5.0 0.0 0.0 5.0 -1 3 | 2 1 0.0 0.0 0.0 5.0 1 4 | 3 1 5.0 0.0 0.0 5.0 2 5 | -------------------------------------------------------------------------------- /examples/graupnerbrunelstdp/checkpoints/.gitignore: -------------------------------------------------------------------------------- 1 | /*.pkl 2 | /checkpoint.* 3 | -------------------------------------------------------------------------------- /examples/graupnerbrunelstdp/figures/.gitignore: -------------------------------------------------------------------------------- 1 | /*.eps 2 | -------------------------------------------------------------------------------- /examples/graupnerbrunelstdp/test_stdputil.py: -------------------------------------------------------------------------------- 1 | import stdputil 2 | import numpy as np 3 | import numpy.testing as npt 4 | 5 | try: 6 | xrange 7 | except NameError: 8 | xrange = range 9 | 10 | 11 | def test_protocol_outcome(): 12 | """ 13 | Test against Fig. 3 of Graupner and Brunel (2012). 14 | TODO, Ask permission to Michael to add testing files. 15 | 16 | Notes 17 | ----- 18 | Data used for the test were kindly provprot_ided by Dr. M. Graupner. 19 | Fig. 3F cannot be reproduced because generated using an approximate 20 | solution. 21 | """ 22 | # Case 1: Fig. 3B 23 | mgspike = np.loadtxt( 24 | '/gpfs/bbp.cscs.ch/home/chindemi/proj32/graupner/data/post_spike.dat') 25 | dt = mgspike[:, 0] 26 | outcome = np.zeros(len(dt)) 27 | for i in xrange(len(dt)): 28 | p = stdputil.Protocol(['pre', 'post'], [dt[i] * 1e-3], 5.0, 200.0) 29 | outcome[i] = stdputil.protocol_outcome(p, stdputil.param_hippocampal) 30 | npt.assert_allclose(outcome, mgspike[:, 1], rtol=1e-05) 31 | 32 | # Case 2: Fig. 3D 33 | mgspike = np.loadtxt( 34 | '/gpfs/bbp.cscs.ch/home/chindemi/proj32/graupner/data/' 35 | 'post_burst_100.dat') 36 | dt = mgspike[:, 0] 37 | outcome = np.zeros(len(dt)) 38 | for i in xrange(len(dt)): 39 | p = stdputil.Protocol( 40 | ['post', 'post', 'pre'], 41 | [11.5e-3, -dt[i] * 1e-3], 42 | 5.0, 100.0) 43 | outcome[i] = stdputil.protocol_outcome(p, stdputil.param_hippocampal) 44 | npt.assert_allclose(outcome, mgspike[:, 1], rtol=1e-05) 45 | 46 | # Case 3: Fig. 3E 47 | mgspike = np.loadtxt( 48 | '/gpfs/bbp.cscs.ch/home/chindemi/proj32/graupner/data/' 49 | 'post_burst_30.dat') 50 | dt = mgspike[:, 0] 51 | outcome = np.zeros(len(dt)) 52 | for i in xrange(len(dt)): 53 | p = stdputil.Protocol( 54 | ['post', 'post', 'pre'], 55 | [11.5e-3, -dt[i] * 1e-3], 56 | 5.0, 30.0) 57 | outcome[i] = stdputil.protocol_outcome(p, stdputil.param_hippocampal) 58 | npt.assert_allclose(outcome, mgspike[:, 1], rtol=1e-05) 59 | -------------------------------------------------------------------------------- /examples/l5pc/.gitignore: -------------------------------------------------------------------------------- 1 | /*.pkl 2 | /.ipynb_checkpoints/ 3 | /L5PC.py 4 | /.ipython 5 | -------------------------------------------------------------------------------- /examples/l5pc/benchmark/get_stats.py: -------------------------------------------------------------------------------- 1 | 2 | import datetime 3 | from ipyparallel import Client 4 | rc = Client() 5 | # rc.get_result('77cdf201-5925-4199-bdd8-0eae0d833d2a') 6 | # incomplete = rc.db_query({'completed' : None}, keys=['msg_id', 'started']) 7 | completed = rc.db_query( 8 | {'completed': {'$ne': None}}, keys=['msg_id', 'started', 'completed', 9 | 'engine_uuid']) 10 | total_time = datetime.timedelta() 11 | for task in completed: 12 | # print task['started'], task['completed'] - task['started'] 13 | total_time += task['completed'] - task['started'] 14 | print(total_time, total_time / len(completed)) 15 | print(len(set(task['engine_uuid'] for task in completed)), len(completed)) 16 | -------------------------------------------------------------------------------- /examples/l5pc/benchmark/l5pc_benchmark.sbatch: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #SBATCH --ntasks=50 4 | #SBATCH --partition=prod 5 | #SBATCH --job-name=l5pc_benchmark 6 | #SBATCH --time=1-00:00:00 7 | #SBATCH --error=logs/l5pc_benchmark.stdout 8 | #SBATCH --output=logs/l5pc_benchmark.stdout 9 | 10 | set -e 11 | set -x 12 | 13 | ./start.sh 14 | -------------------------------------------------------------------------------- /examples/l5pc/benchmark/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /examples/l5pc/benchmark/run_benchmark.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Script to run a benchmark optimisation on CSCS viz cluster 4 | 5 | LOGFILENAME=logs/l5pc_benchmark.stdout 6 | 7 | rm -rf ${LOGFILENAME} 8 | 9 | sbatch -A proj37 l5pc_benchmark.sbatch 10 | 11 | tail -f --retry ${LOGFILENAME} 12 | -------------------------------------------------------------------------------- /examples/l5pc/benchmark/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | set -x 5 | 6 | PWD=$(pwd) 7 | LOGS=$PWD/logs 8 | mkdir -p $LOGS 9 | 10 | cd .. 11 | 12 | OFFSPRING_SIZE=100 13 | MAX_NGEN=100 14 | 15 | export IPYTHONDIR=${PWD}/.ipython 16 | export IPYTHON_PROFILE=benchmark.${SLURM_JOBID} 17 | 18 | ipcontroller --init --ip='*' --sqlitedb --ping=30000 --profile=${IPYTHON_PROFILE} & 19 | sleep 10 20 | srun --output="${LOGS}/engine_%j_%2t.out" ipengine --timeout=300 --profile=${IPYTHON_PROFILE} & 21 | sleep 10 22 | 23 | CHECKPOINTS_DIR="checkpoints/run.${SLURM_JOBID}" 24 | mkdir -p ${CHECKPOINTS_DIR} 25 | 26 | pids="" 27 | for seed in {1..4}; do 28 | python opt_l5pc.py \ 29 | -vv \ 30 | --offspring_size=${OFFSPRING_SIZE} \ 31 | --max_ngen=${MAX_NGEN} \ 32 | --seed=${seed} \ 33 | --ipyparallel \ 34 | --start \ 35 | --checkpoint "${CHECKPOINTS_DIR}/seed${seed}.pkl" & 36 | pids+="$! " 37 | done 38 | 39 | wait $pids 40 | -------------------------------------------------------------------------------- /examples/l5pc/checkpoints/.gitignore: -------------------------------------------------------------------------------- 1 | /* 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /examples/l5pc/config/fixed_params.json: -------------------------------------------------------------------------------- 1 | { 2 | "global": [ 3 | [ 4 | "v_init", 5 | -65 6 | ], 7 | [ 8 | "celsius", 9 | 34 10 | ] 11 | ], 12 | "all": [ 13 | [ 14 | "g_pas", 15 | 3e-05, 16 | "uniform" 17 | ], 18 | [ 19 | "e_pas", 20 | -75, 21 | "uniform" 22 | ], 23 | [ 24 | "cm", 25 | 1, 26 | "uniform" 27 | ], 28 | [ 29 | "Ra", 30 | 100, 31 | "uniform" 32 | ] 33 | ], 34 | "apical": [ 35 | [ 36 | "ena", 37 | 50, 38 | "uniform" 39 | ], 40 | [ 41 | "ek", 42 | -85, 43 | "uniform" 44 | ], 45 | [ 46 | "cm", 47 | 2, 48 | "uniform" 49 | ] 50 | ], 51 | "somatic": [ 52 | [ 53 | "ena", 54 | 50, 55 | "uniform" 56 | ], 57 | [ 58 | "ek", 59 | -85, 60 | "uniform" 61 | ] 62 | ], 63 | "basal": [ 64 | [ 65 | "cm", 66 | 2, 67 | "uniform" 68 | ] 69 | ], 70 | "axonal": [ 71 | [ 72 | "ena", 73 | 50, 74 | "uniform" 75 | ], 76 | [ 77 | "ek", 78 | -85, 79 | "uniform" 80 | ] 81 | ] 82 | } 83 | -------------------------------------------------------------------------------- /examples/l5pc/config/mechanisms.json: -------------------------------------------------------------------------------- 1 | { 2 | "basal": [ 3 | "Ih" 4 | ], 5 | "all": [ 6 | "pas" 7 | ], 8 | "apical": [ 9 | "Ih", 10 | "Im", 11 | "SKv3_1", 12 | "NaTs2_t" 13 | ], 14 | "axonal": [ 15 | "Ca_LVAst", 16 | "Ca_HVA", 17 | "CaDynamics_E2", 18 | "SKv3_1", 19 | "SK_E2", 20 | "K_Tst", 21 | "K_Pst", 22 | "Nap_Et2", 23 | "NaTa_t" 24 | ], 25 | "somatic": [ 26 | "NaTs2_t", 27 | "SKv3_1", 28 | "SK_E2", 29 | "CaDynamics_E2", 30 | "Ca_HVA", 31 | "Ca_LVAst", 32 | "Ih" 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /examples/l5pc/config/protocols.json: -------------------------------------------------------------------------------- 1 | { 2 | "bAP": { 3 | "stimuli": [ 4 | { 5 | "delay": 295, 6 | "amp": 1.9, 7 | "duration": 5, 8 | "totduration": 600 9 | } 10 | ], 11 | "extra_recordings": [ 12 | { 13 | "var": "v", 14 | "somadistance": 660, 15 | "type": "somadistance", 16 | "name": "dend1", 17 | "seclist_name": "apical", 18 | "arbor_branch_index": 251, 19 | "arbor_branch_index_with_replaced_axon": 123 20 | }, 21 | { 22 | "var": "v", 23 | "somadistance": 800, 24 | "type": "somadistance", 25 | "name": "dend2", 26 | "seclist_name": "apical", 27 | "arbor_branch_index": 251, 28 | "arbor_branch_index_with_replaced_axon": 123 29 | } 30 | ] 31 | }, 32 | "Step3": { 33 | "stimuli": [ 34 | { 35 | "delay": 700, 36 | "amp": 0.95, 37 | "duration": 2000, 38 | "totduration": 3000 39 | }, 40 | { 41 | "delay": 0, 42 | "amp": -0.126, 43 | "duration": 3000, 44 | "totduration": 3000 45 | } 46 | ] 47 | }, 48 | "Step2": { 49 | "stimuli": [ 50 | { 51 | "delay": 700, 52 | "amp": 0.562, 53 | "duration": 2000, 54 | "totduration": 3000 55 | }, 56 | { 57 | "delay": 0, 58 | "amp": -0.126, 59 | "duration": 3000, 60 | "totduration": 3000 61 | } 62 | ] 63 | }, 64 | "Step1": { 65 | "stimuli": [ 66 | { 67 | "delay": 700, 68 | "amp": 0.458, 69 | "duration": 2000, 70 | "totduration": 3000 71 | }, 72 | { 73 | "delay": 0, 74 | "amp": -0.126, 75 | "duration": 3000, 76 | "totduration": 3000 77 | } 78 | ] 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /examples/l5pc/convert_noise_exp.py: -------------------------------------------------------------------------------- 1 | """Read exp data for validation""" 2 | 3 | import igorpy 4 | import numpy 5 | 6 | voltages = [] 7 | 8 | # import matplotlib.pyplot as plt 9 | # fig, axes = plt.subplots(11) 10 | 11 | for i in range(436, 447): 12 | # header, voltage = igorpy.read('exp_data/X_NoiseSpiking_ch1_%d.ibw' % i) 13 | header, current = igorpy.read('exp_data/X_NoiseSpiking_ch0_%d.ibw' % i) 14 | # axes[i - 436].plot(voltage) 15 | # header, voltage = igorpy.read('exp_data/X_APThreshold_ch1_262.ibw') 16 | # header, current = igorpy.read('exp_data/X_APThreshold_ch0_262.ibw') 17 | # plt.show() 18 | # voltage *= 1000 19 | # voltage -= 14.0 20 | current *= 1e9 21 | 22 | time = numpy.arange(len(current)) * header.dx * 1000 23 | 24 | numpy.savetxt('exp_data/noise_i.txt', numpy.vstack((time, current)).T) 25 | 26 | # import matplotlib.pyplot as plt 27 | 28 | # fig, ax = plt.subplots(2) 29 | # ax[0].plot(time, current) 30 | # ax[1].plot(time, voltage) 31 | 32 | # plt.show() 33 | -------------------------------------------------------------------------------- /examples/l5pc/convert_params.py: -------------------------------------------------------------------------------- 1 | """Convert params.json and fixed_params.json to parameters.json format""" 2 | 3 | import json 4 | 5 | 6 | def main(): 7 | """Main""" 8 | 9 | fixed_params = json.load(open('fixed_params.json')) 10 | params = json.load(open('params.json')) 11 | 12 | parameters = [] 13 | 14 | for sectionlist in fixed_params: 15 | if sectionlist == 'global': 16 | for param_name, value in fixed_params[sectionlist]: 17 | param = { 18 | 'value': value, 19 | 'param_name': param_name, 20 | 'type': 'global'} 21 | parameters.append(param) 22 | else: 23 | for param_name, value, dist_type in fixed_params[sectionlist]: 24 | param = { 25 | 'value': value, 26 | 'param_name': param_name, 27 | 'type': 'section', 28 | 'dist_type': dist_type, 29 | 'sectionlist': sectionlist 30 | } 31 | parameters.append(param) 32 | 33 | for sectionlist in params: 34 | for mech, param_name, min_bound, max_bound, dist_type in \ 35 | params[sectionlist]: 36 | param = { 37 | 'bounds': [min_bound, max_bound], 38 | 'mech': mech, 39 | 'mech_param': param_name, 40 | 'param_name': '%s_%s' % (param_name, mech), 41 | 'type': 'range', 42 | 'dist_type': dist_type, 43 | 'sectionlist': sectionlist 44 | } 45 | 46 | if mech == 'Ih': 47 | del param['bounds'] 48 | param['value'] = 8e-5 49 | 50 | if dist_type == 'exp': 51 | param['dist'] = \ 52 | '(-0.8696 + 2.087*math.exp(({distance})*0.0031))*{value}' 53 | 54 | parameters.append(param) 55 | 56 | json.dump(parameters, open('parameters.json', 'w'), 57 | indent=4, 58 | separators=(',', ': ')) 59 | 60 | if __name__ == '__main__': 61 | main() 62 | -------------------------------------------------------------------------------- /examples/l5pc/exp_data/.gitignore: -------------------------------------------------------------------------------- 1 | /*.ibw 2 | -------------------------------------------------------------------------------- /examples/l5pc/figures/.gitignore: -------------------------------------------------------------------------------- 1 | /*.eps 2 | -------------------------------------------------------------------------------- /examples/l5pc/generate_acc.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | '''Example for generating a mixed JSON/ACC Arbor cable cell description (with optional axon-replacement) 4 | 5 | $ python generate_acc.py --output-dir test_acc/ --replace-axon 6 | 7 | Will save 'l5pc.json', 'l5pc_label_dict.acc' and 'l5pc_decor.acc' 8 | into the folder 'test_acc' that can be loaded in Arbor with: 9 | 'cell_json, morpho, decor, labels = \ 10 | ephys.create_acc.read_acc("test_acc/l5pc_cell.json")' 11 | An Arbor cable cell can then be created with 12 | 'cell = arbor.cable_cell(morphology=morpho, decor=decor, labels=labels)' 13 | The resulting cable cell can be output to ACC for visual inspection 14 | and e.g. validating/deriving custom Arbor locset/region/iexpr 15 | expressions in the Arbor GUI (File > Cable cell > Load) using 16 | 'arbor.write_component(cell, "l5pc_cable_cell.acc")' 17 | ''' 18 | import argparse 19 | 20 | from bluepyopt import ephys 21 | 22 | import l5pc_model 23 | from generate_hoc import param_values 24 | 25 | 26 | def main(): 27 | '''main''' 28 | parser = argparse.ArgumentParser( 29 | formatter_class=argparse.RawDescriptionHelpFormatter, 30 | description=__doc__) 31 | parser.add_argument('-o', '--output-dir', dest='output_dir', 32 | help='Output directory for JSON/ACC files') 33 | parser.add_argument('-ra', '--replace-axon', action='store_true', 34 | help='Replace axon with Neuron-dependent policy') 35 | args = parser.parse_args() 36 | 37 | cell = l5pc_model.create(do_replace_axon=args.replace_axon) 38 | if args.replace_axon: 39 | nrn_sim = ephys.simulators.NrnSimulator() 40 | cell.instantiate_morphology_3d(nrn_sim) 41 | 42 | # Add modcc-compiled external mechanisms catalogues here 43 | # ext_catalogues = {'cat-name': 'path/to/nmodl-dir', ...} 44 | 45 | if args.output_dir is not None: 46 | cell.write_acc(args.output_dir, 47 | param_values, 48 | # ext_catalogues=ext_catalogues, 49 | create_mod_morph=True) 50 | else: 51 | output = cell.create_acc( 52 | param_values, 53 | template='acc/*_template.jinja2', 54 | # ext_catalogues=ext_catalogues, 55 | create_mod_morph=True) 56 | for el, val in output.items(): 57 | print("%s:\n%s\n" % (el, val)) 58 | 59 | 60 | if __name__ == '__main__': 61 | main() 62 | -------------------------------------------------------------------------------- /examples/l5pc/generate_hoc.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | '''Example for generating a hoc template 4 | 5 | $ python generate_hoc.py > test.hoc 6 | 7 | Will save 'test.hoc' file, which can be loaded in neuron with: 8 | 'load_file("test.hoc")' 9 | Then the hoc template needs to be instantiated with a morphology 10 | CCell("ignored", "path/to/morphology.asc") 11 | ''' 12 | import sys 13 | 14 | import l5pc_model 15 | 16 | param_values = { 17 | 'gNaTs2_tbar_NaTs2_t.apical': 0.026145, 18 | 'gSKv3_1bar_SKv3_1.apical': 0.004226, 19 | 'gImbar_Im.apical': 0.000143, 20 | 'gNaTa_tbar_NaTa_t.axonal': 3.137968, 21 | 'gK_Tstbar_K_Tst.axonal': 0.089259, 22 | 'gamma_CaDynamics_E2.axonal': 0.002910, 23 | 'gNap_Et2bar_Nap_Et2.axonal': 0.006827, 24 | 'gSK_E2bar_SK_E2.axonal': 0.007104, 25 | 'gCa_HVAbar_Ca_HVA.axonal': 0.000990, 26 | 'gK_Pstbar_K_Pst.axonal': 0.973538, 27 | 'gSKv3_1bar_SKv3_1.axonal': 1.021945, 28 | 'decay_CaDynamics_E2.axonal': 287.198731, 29 | 'gCa_LVAstbar_Ca_LVAst.axonal': 0.008752, 30 | 'gamma_CaDynamics_E2.somatic': 0.000609, 31 | 'gSKv3_1bar_SKv3_1.somatic': 0.303472, 32 | 'gSK_E2bar_SK_E2.somatic': 0.008407, 33 | 'gCa_HVAbar_Ca_HVA.somatic': 0.000994, 34 | 'gNaTs2_tbar_NaTs2_t.somatic': 0.983955, 35 | 'decay_CaDynamics_E2.somatic': 210.485284, 36 | 'gCa_LVAstbar_Ca_LVAst.somatic': 0.000333, 37 | } 38 | 39 | 40 | def main(): 41 | '''main''' 42 | cell = l5pc_model.create() 43 | print(cell.create_hoc(param_values)) 44 | 45 | 46 | if __name__ == '__main__': 47 | if '-h' in sys.argv or '--help' in sys.argv: 48 | print(__doc__) 49 | else: 50 | main() 51 | -------------------------------------------------------------------------------- /examples/l5pc/l5_config.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BluePyOpt/87325945d120bba99ea51953fe7f1c7f86d58414/examples/l5pc/l5_config.zip -------------------------------------------------------------------------------- /examples/l5pc/mechanisms/CaDynamics_E2.mod: -------------------------------------------------------------------------------- 1 | : Dynamics that track inside calcium concentration 2 | : modified from Destexhe et al. 1994 3 | 4 | NEURON { 5 | SUFFIX CaDynamics_E2 6 | USEION ca READ ica WRITE cai 7 | RANGE decay, gamma, minCai, depth 8 | } 9 | 10 | UNITS { 11 | (mV) = (millivolt) 12 | (mA) = (milliamp) 13 | FARADAY = (faraday) (coulombs) 14 | (molar) = (1/liter) 15 | (mM) = (millimolar) 16 | (um) = (micron) 17 | } 18 | 19 | PARAMETER { 20 | gamma = 0.05 : percent of free calcium (not buffered) 21 | decay = 80 (ms) : rate of removal of calcium 22 | depth = 0.1 (um) : depth of shell 23 | minCai = 1e-4 (mM) 24 | } 25 | 26 | ASSIGNED {ica (mA/cm2)} 27 | 28 | STATE { 29 | cai (mM) 30 | } 31 | 32 | BREAKPOINT { SOLVE states METHOD cnexp } 33 | 34 | DERIVATIVE states { 35 | cai' = -(10000)*(ica*gamma/(2*FARADAY*depth)) - (cai - minCai)/decay 36 | } 37 | -------------------------------------------------------------------------------- /examples/l5pc/mechanisms/Ca_HVA.mod: -------------------------------------------------------------------------------- 1 | :Comment : 2 | :Reference : : Reuveni, Friedman, Amitai, and Gutnick, J.Neurosci. 1993 3 | 4 | NEURON { 5 | SUFFIX Ca_HVA 6 | USEION ca READ eca WRITE ica 7 | RANGE gCa_HVAbar, gCa_HVA, ica 8 | } 9 | 10 | UNITS { 11 | (S) = (siemens) 12 | (mV) = (millivolt) 13 | (mA) = (milliamp) 14 | } 15 | 16 | PARAMETER { 17 | gCa_HVAbar = 0.00001 (S/cm2) 18 | } 19 | 20 | ASSIGNED { 21 | v (mV) 22 | eca (mV) 23 | ica (mA/cm2) 24 | gCa (S/cm2) 25 | mInf 26 | mTau 27 | mAlpha 28 | mBeta 29 | hInf 30 | hTau 31 | hAlpha 32 | hBeta 33 | } 34 | 35 | STATE { 36 | m 37 | h 38 | } 39 | 40 | BREAKPOINT { 41 | SOLVE states METHOD cnexp 42 | gCa = gCa_HVAbar*m*m*h 43 | ica = gCa*(v-eca) 44 | } 45 | 46 | DERIVATIVE states { 47 | rates() 48 | m' = (mInf-m)/mTau 49 | h' = (hInf-h)/hTau 50 | } 51 | 52 | INITIAL{ 53 | rates() 54 | m = mInf 55 | h = hInf 56 | } 57 | 58 | PROCEDURE rates(){ 59 | UNITSOFF 60 | if((v == -27) ){ 61 | v = v+0.0001 62 | } 63 | mAlpha = (0.055*(-27-v))/(exp((-27-v)/3.8) - 1) 64 | mBeta = (0.94*exp((-75-v)/17)) 65 | mInf = mAlpha/(mAlpha + mBeta) 66 | mTau = 1/(mAlpha + mBeta) 67 | hAlpha = (0.000457*exp((-13-v)/50)) 68 | hBeta = (0.0065/(exp((-v-15)/28)+1)) 69 | hInf = hAlpha/(hAlpha + hBeta) 70 | hTau = 1/(hAlpha + hBeta) 71 | UNITSON 72 | } 73 | -------------------------------------------------------------------------------- /examples/l5pc/mechanisms/Ca_LVAst.mod: -------------------------------------------------------------------------------- 1 | :Comment : LVA ca channel. Note: mtau is an approximation from the plots 2 | :Reference : : Avery and Johnston 1996, tau from Randall 1997 3 | :Comment: shifted by -10 mv to correct for junction potential 4 | :Comment: corrected rates using q10 = 2.3, target temperature 34, orginal 21 5 | 6 | NEURON { 7 | SUFFIX Ca_LVAst 8 | USEION ca READ eca WRITE ica 9 | RANGE gCa_LVAstbar, gCa_LVAst, ica 10 | } 11 | 12 | UNITS { 13 | (S) = (siemens) 14 | (mV) = (millivolt) 15 | (mA) = (milliamp) 16 | } 17 | 18 | PARAMETER { 19 | gCa_LVAstbar = 0.00001 (S/cm2) 20 | } 21 | 22 | ASSIGNED { 23 | v (mV) 24 | eca (mV) 25 | ica (mA/cm2) 26 | gCa_LVAst (S/cm2) 27 | mInf 28 | mTau 29 | hInf 30 | hTau 31 | } 32 | 33 | STATE { 34 | m 35 | h 36 | } 37 | 38 | BREAKPOINT { 39 | SOLVE states METHOD cnexp 40 | gCa_LVAst = gCa_LVAstbar*m*m*h 41 | ica = gCa_LVAst*(v-eca) 42 | } 43 | 44 | DERIVATIVE states { 45 | rates() 46 | m' = (mInf-m)/mTau 47 | h' = (hInf-h)/hTau 48 | } 49 | 50 | INITIAL{ 51 | rates() 52 | m = mInf 53 | h = hInf 54 | } 55 | 56 | PROCEDURE rates(){ 57 | LOCAL qt 58 | qt = 2.3^((34-21)/10) 59 | 60 | UNITSOFF 61 | v = v + 10 62 | mInf = 1.0000/(1+ exp((v - -30.000)/-6)) 63 | mTau = (5.0000 + 20.0000/(1+exp((v - -25.000)/5)))/qt 64 | hInf = 1.0000/(1+ exp((v - -80.000)/6.4)) 65 | hTau = (20.0000 + 50.0000/(1+exp((v - -40.000)/7)))/qt 66 | v = v - 10 67 | UNITSON 68 | } 69 | -------------------------------------------------------------------------------- /examples/l5pc/mechanisms/Ih.mod: -------------------------------------------------------------------------------- 1 | :Comment : 2 | :Reference : : Kole,Hallermann,and Stuart, J. Neurosci. 2006 3 | 4 | NEURON { 5 | SUFFIX Ih 6 | NONSPECIFIC_CURRENT ihcn 7 | RANGE gIhbar, gIh, ihcn 8 | } 9 | 10 | UNITS { 11 | (S) = (siemens) 12 | (mV) = (millivolt) 13 | (mA) = (milliamp) 14 | } 15 | 16 | PARAMETER { 17 | gIhbar = 0.00001 (S/cm2) 18 | ehcn = -45.0 (mV) 19 | } 20 | 21 | ASSIGNED { 22 | v (mV) 23 | ihcn (mA/cm2) 24 | gIh (S/cm2) 25 | mInf 26 | mTau 27 | mAlpha 28 | mBeta 29 | } 30 | 31 | STATE { 32 | m 33 | } 34 | 35 | BREAKPOINT { 36 | SOLVE states METHOD cnexp 37 | gIh = gIhbar*m 38 | ihcn = gIh*(v-ehcn) 39 | } 40 | 41 | DERIVATIVE states { 42 | rates() 43 | m' = (mInf-m)/mTau 44 | } 45 | 46 | INITIAL{ 47 | rates() 48 | m = mInf 49 | } 50 | 51 | PROCEDURE rates(){ 52 | UNITSOFF 53 | if(v == -154.9){ 54 | v = v + 0.0001 55 | } 56 | mAlpha = 0.001*6.43*(v+154.9)/(exp((v+154.9)/11.9)-1) 57 | mBeta = 0.001*193*exp(v/33.1) 58 | mInf = mAlpha/(mAlpha + mBeta) 59 | mTau = 1/(mAlpha + mBeta) 60 | UNITSON 61 | } 62 | -------------------------------------------------------------------------------- /examples/l5pc/mechanisms/Im.mod: -------------------------------------------------------------------------------- 1 | :Reference : : Adams et al. 1982 - M-currents and other potassium currents in bullfrog sympathetic neurones 2 | :Comment: corrected rates using q10 = 2.3, target temperature 34, orginal 21 3 | 4 | NEURON { 5 | SUFFIX Im 6 | USEION k READ ek WRITE ik 7 | RANGE gImbar, gIm, ik 8 | } 9 | 10 | UNITS { 11 | (S) = (siemens) 12 | (mV) = (millivolt) 13 | (mA) = (milliamp) 14 | } 15 | 16 | PARAMETER { 17 | gImbar = 0.00001 (S/cm2) 18 | } 19 | 20 | ASSIGNED { 21 | v (mV) 22 | ek (mV) 23 | ik (mA/cm2) 24 | gIm (S/cm2) 25 | mInf 26 | mTau 27 | mAlpha 28 | mBeta 29 | } 30 | 31 | STATE { 32 | m 33 | } 34 | 35 | BREAKPOINT { 36 | SOLVE states METHOD cnexp 37 | gIm = gImbar*m 38 | ik = gIm*(v-ek) 39 | } 40 | 41 | DERIVATIVE states { 42 | rates() 43 | m' = (mInf-m)/mTau 44 | } 45 | 46 | INITIAL{ 47 | rates() 48 | m = mInf 49 | } 50 | 51 | PROCEDURE rates(){ 52 | LOCAL qt 53 | qt = 2.3^((34-21)/10) 54 | 55 | UNITSOFF 56 | mAlpha = 3.3e-3*exp(2.5*0.04*(v - -35)) 57 | mBeta = 3.3e-3*exp(-2.5*0.04*(v - -35)) 58 | mInf = mAlpha/(mAlpha + mBeta) 59 | mTau = (1/(mAlpha + mBeta))/qt 60 | UNITSON 61 | } 62 | -------------------------------------------------------------------------------- /examples/l5pc/mechanisms/K_Pst.mod: -------------------------------------------------------------------------------- 1 | :Comment : The persistent component of the K current 2 | :Reference : : Voltage-gated K+ channels in layer 5 neocortical pyramidal neurones from young rats:subtypes and gradients,Korngreen and Sakmann, J. Physiology, 2000 3 | :Comment : shifted -10 mv to correct for junction potential 4 | :Comment: corrected rates using q10 = 2.3, target temperature 34, orginal 21 5 | 6 | 7 | NEURON { 8 | SUFFIX K_Pst 9 | USEION k READ ek WRITE ik 10 | RANGE gK_Pstbar, gK_Pst, ik 11 | } 12 | 13 | UNITS { 14 | (S) = (siemens) 15 | (mV) = (millivolt) 16 | (mA) = (milliamp) 17 | } 18 | 19 | PARAMETER { 20 | gK_Pstbar = 0.00001 (S/cm2) 21 | } 22 | 23 | ASSIGNED { 24 | v (mV) 25 | ek (mV) 26 | ik (mA/cm2) 27 | gK_Pst (S/cm2) 28 | mInf 29 | mTau 30 | hInf 31 | hTau 32 | } 33 | 34 | STATE { 35 | m 36 | h 37 | } 38 | 39 | BREAKPOINT { 40 | SOLVE states METHOD cnexp 41 | gK_Pst = gK_Pstbar*m*m*h 42 | ik = gK_Pst*(v-ek) 43 | } 44 | 45 | DERIVATIVE states { 46 | rates() 47 | m' = (mInf-m)/mTau 48 | h' = (hInf-h)/hTau 49 | } 50 | 51 | INITIAL{ 52 | rates() 53 | m = mInf 54 | h = hInf 55 | } 56 | 57 | PROCEDURE rates(){ 58 | LOCAL qt 59 | qt = 2.3^((34-21)/10) 60 | UNITSOFF 61 | v = v + 10 62 | mInf = (1/(1 + exp(-(v+1)/12))) 63 | if(v<-50){ 64 | mTau = (1.25+175.03*exp(-v * -0.026))/qt 65 | }else{ 66 | mTau = ((1.25+13*exp(-v*0.026)))/qt 67 | } 68 | hInf = 1/(1 + exp(-(v+54)/-11)) 69 | hTau = (360+(1010+24*(v+55))*exp(-((v+75)/48)^2))/qt 70 | v = v - 10 71 | UNITSON 72 | } 73 | -------------------------------------------------------------------------------- /examples/l5pc/mechanisms/K_Tst.mod: -------------------------------------------------------------------------------- 1 | :Comment : The transient component of the K current 2 | :Reference : : Voltage-gated K+ channels in layer 5 neocortical pyramidal neurones from young rats:subtypes and gradients,Korngreen and Sakmann, J. Physiology, 2000 3 | :Comment : shifted -10 mv to correct for junction potential 4 | :Comment: corrected rates using q10 = 2.3, target temperature 34, orginal 21 5 | 6 | NEURON { 7 | SUFFIX K_Tst 8 | USEION k READ ek WRITE ik 9 | RANGE gK_Tstbar, gK_Tst, ik 10 | } 11 | 12 | UNITS { 13 | (S) = (siemens) 14 | (mV) = (millivolt) 15 | (mA) = (milliamp) 16 | } 17 | 18 | PARAMETER { 19 | gK_Tstbar = 0.00001 (S/cm2) 20 | } 21 | 22 | ASSIGNED { 23 | v (mV) 24 | ek (mV) 25 | ik (mA/cm2) 26 | gK_Tst (S/cm2) 27 | mInf 28 | mTau 29 | hInf 30 | hTau 31 | } 32 | 33 | STATE { 34 | m 35 | h 36 | } 37 | 38 | BREAKPOINT { 39 | SOLVE states METHOD cnexp 40 | gK_Tst = gK_Tstbar*(m^4)*h 41 | ik = gK_Tst*(v-ek) 42 | } 43 | 44 | DERIVATIVE states { 45 | rates() 46 | m' = (mInf-m)/mTau 47 | h' = (hInf-h)/hTau 48 | } 49 | 50 | INITIAL{ 51 | rates() 52 | m = mInf 53 | h = hInf 54 | } 55 | 56 | PROCEDURE rates(){ 57 | LOCAL qt 58 | qt = 2.3^((34-21)/10) 59 | 60 | UNITSOFF 61 | v = v + 10 62 | mInf = 1/(1 + exp(-(v+0)/19)) 63 | mTau = (0.34+0.92*exp(-((v+71)/59)^2))/qt 64 | hInf = 1/(1 + exp(-(v+66)/-10)) 65 | hTau = (8+49*exp(-((v+73)/23)^2))/qt 66 | v = v - 10 67 | UNITSON 68 | } 69 | -------------------------------------------------------------------------------- /examples/l5pc/mechanisms/LICENSE: -------------------------------------------------------------------------------- 1 | The CC-BY-NC-SA license applies, as indicated by headers in the 2 | respective source files. 3 | 4 | https://creativecommons.org/licenses/by-nc-sa/4.0/ 5 | 6 | The detailed text is available here 7 | https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode 8 | 9 | or in this tarball in the seperate file LICENSE_CC-BY-CA-SA-4.0 10 | 11 | 12 | The HOC code, Python code, synapse MOD code and cell morphology are licensed with the above mentioned CC-BY-NC-SA license. 13 | 14 | 15 | For models for which the original source is available on ModelDB, any 16 | specific licenses on mentioned on ModelDB, or the generic License of ModelDB 17 | apply: 18 | 19 | 1) Ih model 20 | Author: Stefan Hallermann 21 | Original URL: http://senselab.med.yale.edu/ModelDB/ShowModel.cshtml?model=144526&file=\HallermannEtAl2012\h.mod 22 | 23 | 2) StochKv model 24 | Authors: Zach Mainen Adaptations: Kamran Diba, Mickey London, Peter N. Steinmetz, Werner Van Geit 25 | Original URL: http://senselab.med.yale.edu/ModelDB/ShowModel.cshtml?model=125385&file=\Sbpap_code\mod\skm.mod 26 | 27 | 3) D-type K current model 28 | Authors: Yuguo Yu 29 | Original URL: https://senselab.med.yale.edu/ModelDB/ShowModel.cshtml?model=135898&file=\YuEtAlPNAS2007\kd.mod 30 | 31 | 4) Internal calcium concentration model 32 | Author: Alain Destexhe 33 | Original URL: http://senselab.med.yale.edu/ModelDB/ShowModel.cshtml?model=3670&file=\NTW_NEW\capump.mod 34 | 35 | 5) Ca_LVAst, Im, K_Tst, NaTa_t, SK_E2, Ca_HVA, Ih, K_Pst, Nap_Et2, NaTs2_t, SKv3_1 36 | Author: Etay Hay, Shaul Druckmann, Srikanth Ramaswamy, James King, Werner Van Geit 37 | Original URL: https://senselab.med.yale.edu/ModelDB/ShowModel.cshtml?model=139653&file=\L5bPCmodelsEH\mod\ 38 | -------------------------------------------------------------------------------- /examples/l5pc/mechanisms/NaTa_t.mod: -------------------------------------------------------------------------------- 1 | :Reference :Colbert and Pan 2002 2 | 3 | NEURON { 4 | SUFFIX NaTa_t 5 | USEION na READ ena WRITE ina 6 | RANGE gNaTa_tbar, gNaTa_t, ina 7 | } 8 | 9 | UNITS { 10 | (S) = (siemens) 11 | (mV) = (millivolt) 12 | (mA) = (milliamp) 13 | } 14 | 15 | PARAMETER { 16 | gNaTa_tbar = 0.00001 (S/cm2) 17 | } 18 | 19 | ASSIGNED { 20 | v (mV) 21 | ena (mV) 22 | ina (mA/cm2) 23 | gNaTa_t (S/cm2) 24 | mInf 25 | mTau 26 | mAlpha 27 | mBeta 28 | hInf 29 | hTau 30 | hAlpha 31 | hBeta 32 | } 33 | 34 | STATE { 35 | m 36 | h 37 | } 38 | 39 | BREAKPOINT { 40 | SOLVE states METHOD cnexp 41 | gNaTa_t = gNaTa_tbar*m*m*m*h 42 | ina = gNaTa_t*(v-ena) 43 | } 44 | 45 | DERIVATIVE states { 46 | rates() 47 | m' = (mInf-m)/mTau 48 | h' = (hInf-h)/hTau 49 | } 50 | 51 | INITIAL{ 52 | rates() 53 | m = mInf 54 | h = hInf 55 | } 56 | 57 | PROCEDURE rates(){ 58 | LOCAL qt 59 | qt = 2.3^((34-21)/10) 60 | 61 | UNITSOFF 62 | if(v == -38){ 63 | v = v+0.0001 64 | } 65 | mAlpha = (0.182 * (v- -38))/(1-(exp(-(v- -38)/6))) 66 | mBeta = (0.124 * (-v -38))/(1-(exp(-(-v -38)/6))) 67 | mTau = (1/(mAlpha + mBeta))/qt 68 | mInf = mAlpha/(mAlpha + mBeta) 69 | 70 | if(v == -66){ 71 | v = v + 0.0001 72 | } 73 | 74 | hAlpha = (-0.015 * (v- -66))/(1-(exp((v- -66)/6))) 75 | hBeta = (-0.015 * (-v -66))/(1-(exp((-v -66)/6))) 76 | hTau = (1/(hAlpha + hBeta))/qt 77 | hInf = hAlpha/(hAlpha + hBeta) 78 | UNITSON 79 | } 80 | -------------------------------------------------------------------------------- /examples/l5pc/mechanisms/NaTs2_t.mod: -------------------------------------------------------------------------------- 1 | :Reference :Colbert and Pan 2002 2 | :comment: took the NaTa and shifted both activation/inactivation by 6 mv 3 | 4 | NEURON { 5 | SUFFIX NaTs2_t 6 | USEION na READ ena WRITE ina 7 | RANGE gNaTs2_tbar, gNaTs2_t, ina 8 | } 9 | 10 | UNITS { 11 | (S) = (siemens) 12 | (mV) = (millivolt) 13 | (mA) = (milliamp) 14 | } 15 | 16 | PARAMETER { 17 | gNaTs2_tbar = 0.00001 (S/cm2) 18 | } 19 | 20 | ASSIGNED { 21 | v (mV) 22 | ena (mV) 23 | ina (mA/cm2) 24 | gNaTs2_t (S/cm2) 25 | mInf 26 | mTau 27 | mAlpha 28 | mBeta 29 | hInf 30 | hTau 31 | hAlpha 32 | hBeta 33 | } 34 | 35 | STATE { 36 | m 37 | h 38 | } 39 | 40 | BREAKPOINT { 41 | SOLVE states METHOD cnexp 42 | gNaTs2_t = gNaTs2_tbar*m*m*m*h 43 | ina = gNaTs2_t*(v-ena) 44 | } 45 | 46 | DERIVATIVE states { 47 | rates() 48 | m' = (mInf-m)/mTau 49 | h' = (hInf-h)/hTau 50 | } 51 | 52 | INITIAL{ 53 | rates() 54 | m = mInf 55 | h = hInf 56 | } 57 | 58 | PROCEDURE rates(){ 59 | LOCAL qt 60 | qt = 2.3^((34-21)/10) 61 | 62 | UNITSOFF 63 | if(v == -32){ 64 | v = v+0.0001 65 | } 66 | mAlpha = (0.182 * (v- -32))/(1-(exp(-(v- -32)/6))) 67 | mBeta = (0.124 * (-v -32))/(1-(exp(-(-v -32)/6))) 68 | mInf = mAlpha/(mAlpha + mBeta) 69 | mTau = (1/(mAlpha + mBeta))/qt 70 | 71 | if(v == -60){ 72 | v = v + 0.0001 73 | } 74 | hAlpha = (-0.015 * (v- -60))/(1-(exp((v- -60)/6))) 75 | hBeta = (-0.015 * (-v -60))/(1-(exp((-v -60)/6))) 76 | hInf = hAlpha/(hAlpha + hBeta) 77 | hTau = (1/(hAlpha + hBeta))/qt 78 | UNITSON 79 | } 80 | -------------------------------------------------------------------------------- /examples/l5pc/mechanisms/Nap_Et2.mod: -------------------------------------------------------------------------------- 1 | :Comment : mtau deduced from text (said to be 6 times faster than for NaTa) 2 | :Comment : so I used the equations from NaT and multiplied by 6 3 | :Reference : Modeled according to kinetics derived from Magistretti & Alonso 1999 4 | :Comment: corrected rates using q10 = 2.3, target temperature 34, orginal 21 5 | 6 | NEURON { 7 | SUFFIX Nap_Et2 8 | USEION na READ ena WRITE ina 9 | RANGE gNap_Et2bar, gNap_Et2, ina 10 | } 11 | 12 | UNITS { 13 | (S) = (siemens) 14 | (mV) = (millivolt) 15 | (mA) = (milliamp) 16 | } 17 | 18 | PARAMETER { 19 | gNap_Et2bar = 0.00001 (S/cm2) 20 | } 21 | 22 | ASSIGNED { 23 | v (mV) 24 | ena (mV) 25 | ina (mA/cm2) 26 | gNap_Et2 (S/cm2) 27 | mInf 28 | mTau 29 | mAlpha 30 | mBeta 31 | hInf 32 | hTau 33 | hAlpha 34 | hBeta 35 | } 36 | 37 | STATE { 38 | m 39 | h 40 | } 41 | 42 | BREAKPOINT { 43 | SOLVE states METHOD cnexp 44 | gNap_Et2 = gNap_Et2bar*m*m*m*h 45 | ina = gNap_Et2*(v-ena) 46 | } 47 | 48 | DERIVATIVE states { 49 | rates() 50 | m' = (mInf-m)/mTau 51 | h' = (hInf-h)/hTau 52 | } 53 | 54 | INITIAL{ 55 | rates() 56 | m = mInf 57 | h = hInf 58 | } 59 | 60 | PROCEDURE rates(){ 61 | LOCAL qt 62 | qt = 2.3^((34-21)/10) 63 | 64 | UNITSOFF 65 | mInf = 1.0/(1+exp((v- -52.6)/-4.6)) 66 | if(v == -38){ 67 | v = v+0.0001 68 | } 69 | mAlpha = (0.182 * (v- -38))/(1-(exp(-(v- -38)/6))) 70 | mBeta = (0.124 * (-v -38))/(1-(exp(-(-v -38)/6))) 71 | mTau = 6*(1/(mAlpha + mBeta))/qt 72 | 73 | if(v == -17){ 74 | v = v + 0.0001 75 | } 76 | if(v == -64.4){ 77 | v = v+0.0001 78 | } 79 | 80 | hInf = 1.0/(1+exp((v- -48.8)/10)) 81 | hAlpha = -2.88e-6 * (v + 17) / (1 - exp((v + 17)/4.63)) 82 | hBeta = 6.94e-6 * (v + 64.4) / (1 - exp(-(v + 64.4)/2.63)) 83 | hTau = (1/(hAlpha + hBeta))/qt 84 | UNITSON 85 | } 86 | -------------------------------------------------------------------------------- /examples/l5pc/mechanisms/SK_E2.mod: -------------------------------------------------------------------------------- 1 | : SK-type calcium-activated potassium current 2 | : Reference : Kohler et al. 1996 3 | 4 | NEURON { 5 | SUFFIX SK_E2 6 | USEION k READ ek WRITE ik 7 | USEION ca READ cai 8 | RANGE gSK_E2bar, gSK_E2, ik 9 | } 10 | 11 | UNITS { 12 | (mV) = (millivolt) 13 | (mA) = (milliamp) 14 | (mM) = (milli/liter) 15 | } 16 | 17 | PARAMETER { 18 | v (mV) 19 | gSK_E2bar = .000001 (mho/cm2) 20 | zTau = 1 (ms) 21 | ek (mV) 22 | cai (mM) 23 | } 24 | 25 | ASSIGNED { 26 | zInf 27 | ik (mA/cm2) 28 | gSK_E2 (S/cm2) 29 | } 30 | 31 | STATE { 32 | z FROM 0 TO 1 33 | } 34 | 35 | BREAKPOINT { 36 | SOLVE states METHOD cnexp 37 | gSK_E2 = gSK_E2bar * z 38 | ik = gSK_E2 * (v - ek) 39 | } 40 | 41 | DERIVATIVE states { 42 | rates(cai) 43 | z' = (zInf - z) / zTau 44 | } 45 | 46 | PROCEDURE rates(ca(mM)) { 47 | if(ca < 1e-7){ 48 | ca = ca + 1e-07 49 | } 50 | zInf = 1/(1 + (0.00043 / ca)^4.8) 51 | } 52 | 53 | INITIAL { 54 | rates(cai) 55 | z = zInf 56 | } 57 | -------------------------------------------------------------------------------- /examples/l5pc/mechanisms/SKv3_1.mod: -------------------------------------------------------------------------------- 1 | :Comment : 2 | :Reference : : Characterization of a Shaw-related potassium channel family in rat brain, The EMBO Journal, vol.11, no.7,2473-2486 (1992) 3 | 4 | NEURON { 5 | SUFFIX SKv3_1 6 | USEION k READ ek WRITE ik 7 | RANGE gSKv3_1bar, gSKv3_1, ik 8 | } 9 | 10 | UNITS { 11 | (S) = (siemens) 12 | (mV) = (millivolt) 13 | (mA) = (milliamp) 14 | } 15 | 16 | PARAMETER { 17 | gSKv3_1bar = 0.00001 (S/cm2) 18 | } 19 | 20 | ASSIGNED { 21 | v (mV) 22 | ek (mV) 23 | ik (mA/cm2) 24 | gSKv3_1 (S/cm2) 25 | mInf 26 | mTau 27 | } 28 | 29 | STATE { 30 | m 31 | } 32 | 33 | BREAKPOINT { 34 | SOLVE states METHOD cnexp 35 | gSKv3_1 = gSKv3_1bar*m 36 | ik = gSKv3_1*(v-ek) 37 | } 38 | 39 | DERIVATIVE states { 40 | rates() 41 | m' = (mInf-m)/mTau 42 | } 43 | 44 | INITIAL{ 45 | rates() 46 | m = mInf 47 | } 48 | 49 | PROCEDURE rates(){ 50 | UNITSOFF 51 | mInf = 1/(1+exp(((v -(18.700))/(-9.700)))) 52 | mTau = 0.2*20.000/(1+exp(((v -(-46.560))/(-44.140)))) 53 | UNITSON 54 | } 55 | 56 | -------------------------------------------------------------------------------- /examples/l5pc/mechanisms/dummy.inc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BluePyOpt/87325945d120bba99ea51953fe7f1c7f86d58414/examples/l5pc/mechanisms/dummy.inc -------------------------------------------------------------------------------- /examples/l5pc/morphology/LICENSE: -------------------------------------------------------------------------------- 1 | The CC-BY-NC-SA license applies, as indicated by headers in the 2 | respective source files. 3 | 4 | https://creativecommons.org/licenses/by-nc-sa/4.0/ 5 | 6 | The detailed text is available here 7 | https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode 8 | 9 | or in this tarball in the seperate file LICENSE_CC-BY-CA-SA-4.0 10 | 11 | 12 | The HOC code, Python code, synapse MOD code and cell morphology are licensed with the above mentioned CC-BY-NC-SA license. 13 | 14 | 15 | For models for which the original source is available on ModelDB, any 16 | specific licenses on mentioned on ModelDB, or the generic License of ModelDB 17 | apply: 18 | 19 | 1) Ih model 20 | Author: Stefan Hallermann 21 | Original URL: http://senselab.med.yale.edu/ModelDB/ShowModel.cshtml?model=144526&file=\HallermannEtAl2012\h.mod 22 | 23 | 2) StochKv model 24 | Authors: Zach Mainen Adaptations: Kamran Diba, Mickey London, Peter N. Steinmetz, Werner Van Geit 25 | Original URL: http://senselab.med.yale.edu/ModelDB/ShowModel.cshtml?model=125385&file=\Sbpap_code\mod\skm.mod 26 | 27 | 3) D-type K current model 28 | Authors: Yuguo Yu 29 | Original URL: https://senselab.med.yale.edu/ModelDB/ShowModel.cshtml?model=135898&file=\YuEtAlPNAS2007\kd.mod 30 | 31 | 4) Internal calcium concentration model 32 | Author: Alain Destexhe 33 | Original URL: http://senselab.med.yale.edu/ModelDB/ShowModel.cshtml?model=3670&file=\NTW_NEW\capump.mod 34 | 35 | 5) Ca_LVAst, Im, K_Tst, NaTa_t, SK_E2, Ca_HVA, Ih, K_Pst, Nap_Et2, NaTs2_t, SKv3_1 36 | Author: Etay Hay, Shaul Druckmann, Srikanth Ramaswamy, James King, Werner Van Geit 37 | Original URL: https://senselab.med.yale.edu/ModelDB/ShowModel.cshtml?model=139653&file=\L5bPCmodelsEH\mod\ 38 | -------------------------------------------------------------------------------- /examples/l5pc/nsg/.gitignore: -------------------------------------------------------------------------------- 1 | /l5pc_nsg.zip 2 | /zipcontent 3 | -------------------------------------------------------------------------------- /examples/l5pc/nsg/Makefile: -------------------------------------------------------------------------------- 1 | zip: 2 | rm -f l5pc_nsg.zip 3 | rm -rf zipcontent 4 | mkdir -p zipcontent 5 | cp init.py zipcontent 6 | cp -r ../config ../morphology ../opt_l5pc.py ../l5pc_model.py ../l5pc_evaluator.py ../checkpoints/checkpoint.pkl zipcontent 7 | cp ../mechanisms/*.mod zipcontent 8 | zip -r l5pc_nsg.zip zipcontent 9 | -------------------------------------------------------------------------------- /examples/l5pc/nsg/init.py: -------------------------------------------------------------------------------- 1 | """Run BluePyOpt on Neuroscience Gateway""" 2 | 3 | import os 4 | 5 | os.system('python opt_l5pc.py --start --max_ngen=100 ' 6 | '--offspring_size=50 --checkpoint checkpoint.pkl') 7 | -------------------------------------------------------------------------------- /examples/l5pc/opt_l5pc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | nrnivmodl ./mechanisms 4 | python opt_l5pc.py --start 5 | -------------------------------------------------------------------------------- /examples/l5pc/tables/.gitignore: -------------------------------------------------------------------------------- 1 | /*.tex 2 | -------------------------------------------------------------------------------- /examples/l5pc_lfpy/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BluePyOpt/87325945d120bba99ea51953fe7f1c7f86d58414/examples/l5pc_lfpy/__init__.py -------------------------------------------------------------------------------- /examples/l5pc_lfpy/l5pc_lfpy_model.py: -------------------------------------------------------------------------------- 1 | """Create l5pc model with MEA""" 2 | 3 | """ 4 | Copyright (c) 2016-2022, EPFL/Blue Brain Project 5 | 6 | This file is part of BluePyOpt 7 | 8 | This library is free software; you can redistribute it and/or modify it under 9 | the terms of the GNU Lesser General Public License version 3.0 as published 10 | by the Free Software Foundation. 11 | 12 | This library is distributed in the hope that it will be useful, but WITHOUT 13 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 15 | details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with this library; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | """ 21 | 22 | import sys 23 | import os 24 | import MEAutility as mu 25 | 26 | import bluepyopt 27 | import bluepyopt.ephys as ephys 28 | 29 | L5PC_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '../l5pc')) 30 | sys.path.insert(0, L5PC_PATH) 31 | 32 | import l5pc_model 33 | 34 | 35 | def define_electrode( 36 | probe_center=[0, 300, 20], 37 | mea_dim=[10, 4], 38 | mea_pitch=[300, 300], 39 | ): 40 | """ 41 | Defines LFPy electrode object 42 | Parameters 43 | ---------- 44 | probe_center: 3d array 45 | The center of the probe 46 | mea_dim: 2d array 47 | Dimensions of planar probe (nrows, ncols) 48 | mea_pitch: 3d arraay 49 | The pitch of the planar probe (row pitch, column pitch) 50 | Returns 51 | ------- 52 | electrode: MEAutility.MEA object 53 | The MEAutility electrode object 54 | """ 55 | 56 | mea_info = { 57 | 'dim': mea_dim, 58 | 'electrode_name': 'hd-mea', 59 | 'pitch': mea_pitch, 60 | 'shape': 'square', 61 | 'size': 5, 62 | 'type': 'mea', 63 | 'plane': 'xy' 64 | } 65 | probe = mu.return_mea(info=mea_info) 66 | 67 | # Move the MEA out of the neuron plane (yz) 68 | probe.move(probe_center) 69 | 70 | return probe 71 | 72 | 73 | def create(): 74 | 75 | l5pc_cell = ephys.models.LFPyCellModel( 76 | "l5pc_lfpy", 77 | morph=l5pc_model.define_morphology(do_replace_axon=True), 78 | mechs=l5pc_model.define_mechanisms(), 79 | params=l5pc_model.define_parameters(), 80 | electrode=define_electrode() 81 | ) 82 | 83 | return l5pc_cell 84 | -------------------------------------------------------------------------------- /examples/metaparameters/.gitignore: -------------------------------------------------------------------------------- 1 | /metaparameters.py 2 | -------------------------------------------------------------------------------- /examples/metaparameters/twocompartment.swc: -------------------------------------------------------------------------------- 1 | # Dummy granule cell morphology 2 | 1 1 -5.0 0.0 0.0 5.0 -1 3 | 2 1 0.0 0.0 0.0 5.0 1 4 | 3 1 5.0 0.0 0.0 5.0 2 5 | 4 2 5.0 0.0 0.0 1.0 3 6 | 5 2 10.0 0.0 0.0 1.0 4 7 | -------------------------------------------------------------------------------- /examples/simplecell/.gitignore: -------------------------------------------------------------------------------- 1 | /.ipynb_checkpoints/ 2 | /simplecell.py 3 | /simplecell_arbor.py 4 | -------------------------------------------------------------------------------- /examples/simplecell/checkpoints/.gitignore: -------------------------------------------------------------------------------- 1 | /*.pkl 2 | -------------------------------------------------------------------------------- /examples/simplecell/figures/.gitignore: -------------------------------------------------------------------------------- 1 | /*.eps 2 | -------------------------------------------------------------------------------- /examples/simplecell/figures/landscape_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BluePyOpt/87325945d120bba99ea51953fe7f1c7f86d58414/examples/simplecell/figures/landscape_example.png -------------------------------------------------------------------------------- /examples/simplecell/generate_acc.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | '''Example for generating a mixed JSON/ACC Arbor cable cell description (with optional axon-replacement) 4 | 5 | $ python generate_acc.py --output-dir test_acc/ --replace-axon 6 | 7 | Will save 'simple_cell.json', 'simple_cell_label_dict.acc' and 'simple_cell_decor.acc' 8 | into the folder 'test_acc' that can be loaded in Arbor with: 9 | 'cell_json, morpho, decor, labels = \ 10 | ephys.create_acc.read_acc("test_acc/simple_cell_cell.json")' 11 | An Arbor cable cell is then created with 12 | 'cell = arbor.cable_cell(morphology=morpho, decor=decor, labels=labels)' 13 | The resulting cable cell can be output to ACC for visual inspection 14 | and e.g. validating/deriving custom Arbor locset/region/iexpr 15 | expressions in the Arbor GUI (File > Cable cell > Load) using 16 | 'arbor.write_component(cell, "simple_cell_cable_cell.acc")' 17 | ''' 18 | import argparse 19 | 20 | from bluepyopt import ephys 21 | 22 | import simplecell_model 23 | from generate_hoc import param_values 24 | 25 | 26 | def main(): 27 | '''main''' 28 | parser = argparse.ArgumentParser( 29 | formatter_class=argparse.RawDescriptionHelpFormatter, 30 | description=__doc__) 31 | parser.add_argument('-o', '--output-dir', dest='output_dir', 32 | help='Output directory for JSON/ACC files') 33 | parser.add_argument('-ra', '--replace-axon', action='store_true', 34 | help='Replace axon with Neuron-dependent policy') 35 | args = parser.parse_args() 36 | 37 | cell = simplecell_model.create(do_replace_axon=args.replace_axon) 38 | if args.replace_axon: 39 | nrn_sim = ephys.simulators.NrnSimulator() 40 | cell.instantiate_morphology_3d(nrn_sim) 41 | 42 | # Add modcc-compiled external mechanisms catalogues here 43 | # ext_catalogues = {'cat-name': 'path/to/nmodl-dir', ...} 44 | 45 | if args.output_dir is not None: 46 | cell.write_acc(args.output_dir, 47 | param_values, 48 | # ext_catalogues=ext_catalogues, 49 | create_mod_morph=True) 50 | else: 51 | output = cell.create_acc( 52 | param_values, 53 | template='acc/*_template.jinja2', 54 | # ext_catalogues=ext_catalogues, 55 | create_mod_morph=True) 56 | for el, val in output.items(): 57 | print("%s:\n%s\n" % (el, val)) 58 | 59 | 60 | if __name__ == '__main__': 61 | main() 62 | -------------------------------------------------------------------------------- /examples/simplecell/generate_hoc.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | '''Example for generating a hoc template 4 | 5 | $ python generate_hoc.py > test.hoc 6 | 7 | Will save 'test.hoc' file, which can be loaded in neuron with: 8 | 'load_file("test.hoc")' 9 | Then the hoc template needs to be instantiated with a morphology 10 | CCell("ignored", "path/to/morphology.swc") 11 | ''' 12 | import sys 13 | 14 | import simplecell_model 15 | 16 | 17 | param_values = { 18 | 'gnabar_hh': 0.10299326453483033, 19 | 'gkbar_hh': 0.027124836082684685 20 | } 21 | 22 | 23 | def main(): 24 | '''main''' 25 | cell = simplecell_model.create(do_replace_axon=True) 26 | 27 | output = cell.create_hoc(param_values, template='cell_template.jinja2') 28 | print(output) 29 | 30 | 31 | if __name__ == '__main__': 32 | if '-h' in sys.argv or '--help' in sys.argv: 33 | print(__doc__) 34 | else: 35 | main() 36 | -------------------------------------------------------------------------------- /examples/simplecell/responses.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BluePyOpt/87325945d120bba99ea51953fe7f1c7f86d58414/examples/simplecell/responses.pkl -------------------------------------------------------------------------------- /examples/simplecell/simple.swc: -------------------------------------------------------------------------------- 1 | # Dummy granule cell morphology 2 | 1 1 -5.0 0.0 0.0 5.0 -1 3 | 2 1 0.0 0.0 0.0 5.0 1 4 | 3 1 5.0 0.0 0.0 5.0 2 5 | -------------------------------------------------------------------------------- /examples/simplecell/simplecell_model.py: -------------------------------------------------------------------------------- 1 | """Run simple cell optimisation""" 2 | 3 | """ 4 | Copyright (c) 2016-2020, EPFL/Blue Brain Project 5 | 6 | This file is part of BluePyOpt 7 | 8 | This library is free software; you can redistribute it and/or modify it under 9 | the terms of the GNU Lesser General Public License version 3.0 as published 10 | by the Free Software Foundation. 11 | 12 | This library is distributed in the hope that it will be useful, but WITHOUT 13 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 15 | details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with this library; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | """ 21 | # pylint: disable=R0914 22 | 23 | import bluepyopt.ephys as ephys 24 | 25 | 26 | def define_morphology(do_replace_axon): 27 | 28 | return ephys.morphologies.NrnFileMorphology('simple.swc', 29 | do_replace_axon=do_replace_axon) 30 | 31 | def define_mechanisms(): 32 | somatic_loc = ephys.locations.NrnSeclistLocation('somatic', seclist_name='somatic') 33 | 34 | hh_mech = ephys.mechanisms.NrnMODMechanism( 35 | name='hh', 36 | suffix='hh', 37 | locations=[somatic_loc]) 38 | return [hh_mech] 39 | 40 | 41 | def define_parameters(): 42 | somatic_loc = ephys.locations.NrnSeclistLocation('somatic', seclist_name='somatic') 43 | 44 | cm_param = ephys.parameters.NrnSectionParameter( 45 | name='cm', 46 | param_name='cm', 47 | value=1.0, 48 | locations=[somatic_loc], 49 | frozen=True) 50 | 51 | gnabar_param = ephys.parameters.NrnSectionParameter( 52 | name='gnabar_hh', 53 | param_name='gnabar_hh', 54 | locations=[somatic_loc], 55 | bounds=[0.05, 0.125], 56 | frozen=False) 57 | gkbar_param = ephys.parameters.NrnSectionParameter( 58 | name='gkbar_hh', 59 | param_name='gkbar_hh', 60 | bounds=[0.01, 0.075], 61 | locations=[somatic_loc], 62 | frozen=False) 63 | return [cm_param, gnabar_param, gkbar_param] 64 | 65 | 66 | def create(do_replace_axon): 67 | """Create cell model (identical to simplecell.ipynb)""" 68 | 69 | cell = ephys.models.CellModel( 70 | 'simple_cell', 71 | morph=define_morphology(do_replace_axon), 72 | mechs=define_mechanisms(), 73 | params=define_parameters()) 74 | 75 | return cell 76 | -------------------------------------------------------------------------------- /examples/stochkv/.gitignore: -------------------------------------------------------------------------------- 1 | /x86_64 2 | -------------------------------------------------------------------------------- /examples/stochkv/mechanisms/dummy.inc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BluePyOpt/87325945d120bba99ea51953fe7f1c7f86d58414/examples/stochkv/mechanisms/dummy.inc -------------------------------------------------------------------------------- /examples/stochkv/morphology/simple.swc: -------------------------------------------------------------------------------- 1 | # Dummy granule cell morphology 2 | 1 1 -5.0 0.0 0.0 5.0 -1 3 | 2 1 0.0 0.0 0.0 5.0 1 4 | 3 1 5.0 0.0 0.0 5.0 2 5 | -------------------------------------------------------------------------------- /examples/thalamocortical-cell/CellEvalSetup/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2016-2020, EPFL/Blue Brain Project 3 | 4 | This file is part of BluePyOpt 5 | 6 | This library is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License version 3.0 as published 8 | by the Free Software Foundation. 9 | 10 | This library is distributed in the hope that it will be useful, but WITHOUT 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 13 | details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with this library; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | """ 19 | import evaluator 20 | import template 21 | import tools 22 | -------------------------------------------------------------------------------- /examples/thalamocortical-cell/CellEvalSetup/tools.py: -------------------------------------------------------------------------------- 1 | def rename_prot(name): 2 | if 'RMP' in name: 3 | name = "(No stim)" 4 | elif 'Rin_dep' in name: 5 | #name = name.replace('.Rin','Hyp_-40') 6 | name = "($-$40%)" #"R_{input} - tonic" 7 | elif 'Rin_hyp' in name: 8 | #name = name.replace('.Rin','Hyp_-40') 9 | name = "($-$40% - b)" 10 | elif 'hyp' in name and "Step" in name: 11 | name = '(150% - burst)' 12 | name = '(225% - burst)' 13 | name = '(200% - burst)' 14 | elif 'Step_150' in name: 15 | name = '(150% - tonic)' 16 | elif 'Step_200' in name: 17 | name = '(200% - tonic)' 18 | elif 'Step_250' in name: 19 | name = '(250% - tonic)' 20 | elif 'IV_-140' in name: 21 | name = "($-$140%)" 22 | elif 'ThresholdDetection_dep' in name: 23 | name = '' 24 | elif 'ThresholdDetection_hyp' in name: 25 | name = '' 26 | elif 'hold_dep' in name: 27 | name = "(I$_{hold}$ - tonic)" 28 | elif 'hold_hyp' in name: 29 | name = "(I$_{hold}$ - burst)" 30 | 31 | #name = name.replace("soma.v.", "") 32 | return name 33 | 34 | def rename_featpart(name): 35 | import json 36 | namemap = { 37 | "steady_state_voltage_stimend": "V$_{rest}$", 38 | "sag_amplitude": "Sag amp.", 39 | "ohmic_input_resistance_vb_ssse": "R$_{input}$", 40 | "voltage_base": "Baseline V$_m$", 41 | "Spikecount": "Num. of APs", 42 | "voltage_after_stim": "V$_m$ after stim.", 43 | "inv_first_ISI": "Inv. 1$^{st}$ ISI", 44 | "inv_last_ISI": "Inv. last ISI", 45 | "inv_second_ISI": "Inv. 2$^{nd}$ ISI", 46 | "time_to_first_spike": "Latency 1$^{st}$ AP", 47 | "AP1_amp": "Amp. 1$^{st}$ AP ", 48 | "AP2_amp": "Amp. 2$^{nd}$ AP ", 49 | "AHP_depth": "AHP depth", 50 | "AHP_depth_abs": "AHP depth", 51 | "AP_amplitude": "AP amp.", 52 | "AP_width": "AP width", 53 | "AP_duration_half_width": "AP half-width", 54 | "Spikecount_stimint": "Num. of APs", 55 | "bpo_threshold_current_dep": "I$_{thr}$ - tonic", 56 | "bpo_threshold_current_hyp": "I$_{thr}$ - burst", 57 | "time_to_last_spike": "Latency last AP", 58 | "adaptation_index2": "Adaptation idx", 59 | "mean_frequency": "Frequency" 60 | } 61 | return namemap[name] 62 | 63 | def rename_feat(name, sep = " "): 64 | prot_name = name.split(".")[1] 65 | feat_name = name.split(".")[-1] 66 | new_prot = rename_prot(prot_name) 67 | new_feat = rename_featpart(feat_name) 68 | 69 | return new_feat + sep + new_prot 70 | 71 | -------------------------------------------------------------------------------- /examples/thalamocortical-cell/config/params/TC.json: -------------------------------------------------------------------------------- 1 | { 2 | "mechanisms": { 3 | "all": 4 | {"mech":["pas", 5 | "TC_cad"]}, 6 | "somatic": 7 | {"mech":["TC_ih_Bud97", "TC_Nap_Et2", 8 | "TC_iA","TC_iL", "SK_E2", "TC_HH"]}, 9 | "alldend": 10 | {"mech":["TC_ih_Bud97", "TC_Nap_Et2", 11 | "TC_iA","TC_iL", "SK_E2", "TC_HH"]}, 12 | "axonal": 13 | {"mech":["TC_HH"]}, 14 | 15 | "somadend": 16 | {"mech":["TC_iT_Des98"]} 17 | 18 | }, 19 | "distributions": { 20 | }, 21 | "parameters": { 22 | "__comment": "define constants as single values and params to optimize as tuples of bounds: [lower, upper]", 23 | "global": [ 24 | {"name":"v_init", "val":-79}, 25 | {"name":"celsius", "val":34} 26 | ], 27 | "all": [ 28 | {"name":"cm", "val":1}, 29 | {"name":"Ra", "val":100}, 30 | {"name":"ena", "val":50}, 31 | {"name":"ek", "val":-90}, 32 | {"name":"e_pas", "val":-80}, 33 | {"name":"g_pas", "val":[1e-06, 1e-04]} 34 | ], 35 | "axonal": [ 36 | {"name":"gk_max_TC_HH", "val":[0, 0.2]}, 37 | {"name":"gna_max_TC_HH", "val":[0, 0.8]} 38 | ], 39 | "somadend": [ 40 | {"name":"pcabar_TC_iT_Des98", "val":[0, 1e-4]} 41 | ], 42 | 43 | "somatic": [ 44 | {"name":"gh_max_TC_ih_Bud97", "val":[0, 1e-4]}, 45 | {"name":"gNap_Et2bar_TC_Nap_Et2", "val":[0, 0.0001]}, 46 | {"name":"gk_max_TC_iA", "val":[0, 0.07]}, 47 | {"name":"gk_max_TC_HH", "val":[0, 0.2]}, 48 | {"name":"gna_max_TC_HH", "val":[0, 0.2]}, 49 | {"name":"pcabar_TC_iL", "val":[0, 0.001]}, 50 | {"name":"gSK_E2bar_SK_E2", "val":[0, 0.005]}, 51 | {"name":"taur_TC_cad", "val":[1.0, 15.0]}, 52 | {"name":"gamma_TC_cad", "val":[0.0005, 1]} 53 | ], 54 | "alldend": [ 55 | {"name":"gh_max_TC_ih_Bud97", "val":[0, 1e-4]}, 56 | {"name":"gNap_Et2bar_TC_Nap_Et2", "val":[0, 0.0001]}, 57 | {"name":"gk_max_TC_iA", "val":[0, 0.008]}, 58 | {"name":"gk_max_TC_HH", "val":[0, 0.01]}, 59 | {"name":"gna_max_TC_HH", "val":[0, 0.006]}, 60 | {"name":"pcabar_TC_iL", "val":[0, 0.001]}, 61 | {"name":"gSK_E2bar_SK_E2", "val":[0, 0.005]}, 62 | {"name":"taur_TC_cad", "val":[1.0, 15.0]}, 63 | {"name":"gamma_TC_cad", "val":[0.0005, 1]} 64 | 65 | ] 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /examples/thalamocortical-cell/config/protocols/cAD_ltb.json: -------------------------------------------------------------------------------- 1 | { 2 | "Step_150": { 3 | "type": "StepProtocol", 4 | "stimuli": { 5 | "step": {"delay": 800.0, "amp": 0.089041, "thresh_perc": 150.0271, "duration": 1350.0, "totduration": 2400.0}, 6 | "holding": {"delay": 0.0, "amp": 0.134445, "duration": 2400.0, "totduration": 2400.0} 7 | } 8 | }, 9 | "Step_250": { 10 | "type": "StepProtocol", 11 | "stimuli": { 12 | "step": {"delay": 800.0, "amp": 0.14832, "thresh_perc": 249.961, "duration": 1350.0, "totduration": 2400.0}, 13 | "holding": {"delay": 0.0, "amp": 0.134943, "duration": 2400.0, "totduration": 2400.0} 14 | } 15 | }, 16 | "Step_200": { 17 | "type": "StepProtocol", 18 | "stimuli": { 19 | "step": {"delay": 800.0, "amp": 0.118859, "thresh_perc": 200.2936, "duration": 1350.0, "totduration": 2400.0}, 20 | "holding": {"delay": 0.0, "amp": 0.134536, "duration": 2400.0, "totduration": 2400.0} 21 | } 22 | }, 23 | "Step_200_hyp": { 24 | "type": "StepProtocol", 25 | "stimuli": { 26 | "step": {"delay": 800.0, "amp": 0.14673, "thresh_perc": 200.2118, "duration": 1350.0, "totduration": 2400.0}, 27 | "holding": {"delay": 0.0, "amp": -0.121695, "duration": 2400.0, "totduration": 2400.0} 28 | } 29 | }, 30 | "IV_-140": { 31 | "type": "StepProtocol", 32 | "stimuli": { 33 | "step": {"delay": 800.0, "amp": -0.07745, "thresh_perc": -134.8425, "duration": 3000.0, "totduration": 4050.0}, 34 | "holding": {"delay": 0.0, "amp": 0.135615, "duration": 4050.0, "totduration": 4050.0} 35 | } 36 | }, 37 | "RMP": { 38 | "type": "StepProtocol", 39 | "stimuli": { 40 | "step": {"delay": 300, "amp": 0, "duration": 900.0, "totduration": 1200.0} 41 | } 42 | }, 43 | "hold_dep": { 44 | "type": "StepProtocol", 45 | "stimuli": { 46 | "step": {"delay": 300.0, "amp": 0.0, "thresh_perc": 0.0, "duration": 900.0, "totduration": 1200.0}, 47 | "holding": {"delay": 0.0, "amp": 0.134051, "duration": 1200.0, "totduration": 1200.0} 48 | } 49 | }, 50 | "hold_hyp": { 51 | "type": "StepProtocol", 52 | "stimuli": { 53 | "step": {"delay": 300.0, "amp": 0.0, "thresh_perc": 0.0, "duration": 900.0, "totduration": 1200.0}, 54 | "holding": {"delay": 0.0, "amp": -0.129995, "duration": 1200.0, "totduration": 1200.0} 55 | } 56 | }, 57 | "Rin_dep": { 58 | "type": "StepProtocol", 59 | "stimuli": { 60 | "step": {"delay": 800.0, "amp": -0.023425, "thresh_perc": -40.1228, "duration": 3000.0, "totduration": 4050.0}, 61 | "holding": {"delay": 0.0, "amp": 0.135101, "duration": 4050.0, "totduration": 4050.0} 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /examples/thalamocortical-cell/config/protocols/cNAD_ltb.json: -------------------------------------------------------------------------------- 1 | { 2 | "Step_150": { 3 | "type": "StepProtocol", 4 | "stimuli": { 5 | "step": {"delay": 800.0, "amp": 0.106854, "thresh_perc": 149.9653, "duration": 1350.0, "totduration": 2400.0}, 6 | "holding": {"delay": 0.0, "amp": 0.150141, "duration": 2400.0, "totduration": 2400.0} 7 | } 8 | }, 9 | "Step_250": { 10 | "type": "StepProtocol", 11 | "stimuli": { 12 | "step": {"delay": 800.0, "amp": 0.18113, "thresh_perc": 249.9147, "duration": 1350.0, "totduration": 2400.0}, 13 | "holding": {"delay": 0.0, "amp": 0.154962, "duration": 2400.0, "totduration": 2400.0} 14 | } 15 | }, 16 | "Step_200": { 17 | "type": "StepProtocol", 18 | "stimuli": { 19 | "step": {"delay": 800.0, "amp": 0.140843, "thresh_perc": 200.2739, "duration": 1350.0, "totduration": 2400.0}, 20 | "holding": {"delay": 0.0, "amp": 0.153092, "duration": 2400.0, "totduration": 2400.0} 21 | } 22 | }, 23 | "Step_200_hyp": { 24 | "type": "StepProtocol", 25 | "stimuli": { 26 | "step": {"delay": 800.0, "amp": 0.14673, "thresh_perc": 200.2118, "duration": 1350.0, "totduration": 2400.0}, 27 | "holding": {"delay": 0.0, "amp": -0.121695, "duration": 2400.0, "totduration": 2400.0} 28 | } 29 | }, 30 | "IV_-140": { 31 | "type": "StepProtocol", 32 | "stimuli": { 33 | "step": {"delay": 800.0, "amp": -0.098644, "thresh_perc": -139.1379, "duration": 3000.0, "totduration": 4050.0}, 34 | "holding": {"delay": 0.0, "amp": 0.153485, "duration": 4050.0, "totduration": 4050.0} 35 | } 36 | }, 37 | "RMP": { 38 | "type": "StepProtocol", 39 | "stimuli": { 40 | "step": {"delay": 300, "amp": 0, "duration": 900.0, "totduration": 1200.0} 41 | } 42 | }, 43 | "hold_dep": { 44 | "type": "StepProtocol", 45 | "stimuli": { 46 | "step": {"delay": 300.0, "amp": 0.0, "thresh_perc": 0.0, "duration": 900.0, "totduration": 1200.0}, 47 | "holding": {"delay": 0.0, "amp": 0.147305, "duration": 1200.0, "totduration": 1200.0} 48 | } 49 | }, 50 | "hold_hyp": { 51 | "type": "StepProtocol", 52 | "stimuli": { 53 | "step": {"delay": 300.0, "amp": 0.0, "thresh_perc": 0.0, "duration": 900.0, "totduration": 1200.0}, 54 | "holding": {"delay": 0.0, "amp": -0.129995, "duration": 1200.0, "totduration": 1200.0} 55 | } 56 | }, 57 | "Rin_dep": { 58 | "type": "StepProtocol", 59 | "stimuli": { 60 | "step": {"delay": 800.0, "amp": -0.028535, "thresh_perc": -39.8617, "duration": 3000.0, "totduration": 4050.0}, 61 | "holding": {"delay": 0.0, "amp": 0.15064, "duration": 4050.0, "totduration": 4050.0} 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /examples/thalamocortical-cell/config/recipes.json: -------------------------------------------------------------------------------- 1 | { 2 | "cAD_ltb": { 3 | "morph_path": "morphologies/", 4 | "morphology": "jy160728_A_idA.asc", 5 | "params": "config/params/TC.json", 6 | "protocol": "config/protocols/cAD_ltb.json", 7 | "features": "config/features/cAD_ltb.json" 8 | }, 9 | "cNAD_ltb": { 10 | "morph_path": "morphologies/", 11 | "morphology": "jy170517_A_idA.asc", 12 | "params": "config/params/TC.json", 13 | "protocol": "config/protocols/cNAD_ltb.json", 14 | "features": "config/features/cNAD_ltb.json" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /examples/thalamocortical-cell/mechanisms/SK_E2.mod: -------------------------------------------------------------------------------- 1 | : SK-type calcium-activated potassium current 2 | : Reference : Kohler et al. 1996 3 | 4 | : From ModelDB, accession no. 139653 5 | 6 | NEURON { 7 | SUFFIX SK_E2 8 | USEION k READ ek WRITE ik 9 | USEION ca READ cai 10 | RANGE gSK_E2bar, gSK_E2, ik, zTau 11 | } 12 | 13 | UNITS { 14 | (mV) = (millivolt) 15 | (mA) = (milliamp) 16 | (mM) = (milli/liter) 17 | } 18 | 19 | PARAMETER { 20 | v (mV) 21 | gSK_E2bar = .000001 (mho/cm2) 22 | zTau = 1 (ms) 23 | ek (mV) 24 | cai (mM) 25 | } 26 | 27 | ASSIGNED { 28 | zInf 29 | ik (mA/cm2) 30 | gSK_E2 (S/cm2) 31 | } 32 | 33 | STATE { 34 | z FROM 0 TO 1 35 | } 36 | 37 | BREAKPOINT { 38 | SOLVE states METHOD cnexp 39 | gSK_E2 = gSK_E2bar * z 40 | ik = gSK_E2 * (v - ek) 41 | } 42 | 43 | DERIVATIVE states { 44 | rates(cai) 45 | z' = (zInf - z) / zTau 46 | } 47 | 48 | PROCEDURE rates(ca(mM)) { 49 | if(ca < 1e-7){ 50 | ca = ca + 1e-07 51 | } 52 | zInf = 1/(1 + (0.00043 / ca)^4.8) 53 | } 54 | 55 | INITIAL { 56 | rates(cai) 57 | z = zInf 58 | } 59 | -------------------------------------------------------------------------------- /examples/thalamocortical-cell/mechanisms/TC_Ih_Bud97.mod: -------------------------------------------------------------------------------- 1 | : Ih current for thalamo-cortical neurons 2 | : Ref.: Budde et al. (minf), J Physiol, 1997, Huguenard and McCormick, J Neurophysiol, 1992 (taum) 3 | 4 | NEURON { 5 | SUFFIX TC_ih_Bud97 6 | NONSPECIFIC_CURRENT ih 7 | RANGE gh_max, g_h, i_rec 8 | } 9 | 10 | UNITS { 11 | (S) = (siemens) 12 | (mV) = (millivolt) 13 | (mA) = (milliamp) 14 | } 15 | 16 | PARAMETER { 17 | gh_max = 2.2e-5 (S/cm2) 18 | e_h = -43.0 (mV) 19 | celsius (degC) 20 | q10 = 4 : Santoro et al., J. Neurosci. 2000 21 | 22 | } 23 | 24 | ASSIGNED { 25 | v (mV) 26 | ih (mA/cm2) 27 | g_h (S/cm2) 28 | mInf 29 | mTau 30 | tcorr : Add temperature correction 31 | i_rec 32 | } 33 | 34 | STATE { 35 | m 36 | } 37 | 38 | BREAKPOINT { 39 | SOLVE states METHOD cnexp 40 | g_h = gh_max*m 41 | ih = g_h*(v-e_h) 42 | i_rec = ih 43 | } 44 | 45 | DERIVATIVE states { 46 | rates() 47 | m' = (mInf-m)/mTau 48 | } 49 | 50 | INITIAL{ 51 | rates() 52 | m = mInf 53 | tcorr = q10^((celsius-34)/10) : EI: Recording temp. 34 C Huguenard et al. 54 | } 55 | 56 | UNITSOFF 57 | PROCEDURE rates(){ 58 | mInf = 1/(1+exp((v+86.4)/11.2)) : Budde et al., 1997 59 | mTau = (1/(exp(-14.59 - 0.086*v) + exp(-1.87 + 0.0701*v )))/tcorr : Huguenard et al., 1992 60 | } 61 | UNITSON 62 | -------------------------------------------------------------------------------- /examples/thalamocortical-cell/mechanisms/TC_Nap_Et2.mod: -------------------------------------------------------------------------------- 1 | :Comment : mtau deduced from text (said to be 6 times faster than for NaTa) 2 | :Comment : so I used the equations from NaT and multiplied by 6 3 | :Reference : Modeled according to kinetics derived from Magistretti & Alonso 1999 4 | :Comment: corrected rates using q10 = 2.3, target temperature 34, orginal 21 5 | 6 | : From ModelDB, accession no. 139653. mInf and hInf for TC models, see equations for references 7 | 8 | NEURON { 9 | SUFFIX TC_Nap_Et2 10 | USEION na READ ena WRITE ina 11 | RANGE gNap_Et2bar, gNap_Et2, ina 12 | } 13 | 14 | UNITS { 15 | (S) = (siemens) 16 | (mV) = (millivolt) 17 | (mA) = (milliamp) 18 | } 19 | 20 | PARAMETER { 21 | gNap_Et2bar = 0.00001 (S/cm2) 22 | } 23 | 24 | ASSIGNED { 25 | v (mV) 26 | ena (mV) 27 | ina (mA/cm2) 28 | gNap_Et2 (S/cm2) 29 | mInf 30 | mTau 31 | mAlpha 32 | mBeta 33 | hInf 34 | hTau 35 | hAlpha 36 | hBeta 37 | } 38 | 39 | STATE { 40 | m 41 | h 42 | } 43 | 44 | BREAKPOINT { 45 | SOLVE states METHOD cnexp 46 | gNap_Et2 = gNap_Et2bar*m*m*m*h 47 | ina = gNap_Et2*(v-ena) 48 | } 49 | 50 | DERIVATIVE states { 51 | rates() 52 | m' = (mInf-m)/mTau 53 | h' = (hInf-h)/hTau 54 | } 55 | 56 | INITIAL{ 57 | rates() 58 | m = mInf 59 | h = hInf 60 | } 61 | 62 | PROCEDURE rates(){ 63 | LOCAL qt 64 | qt = 2.3^((34-21)/10) 65 | 66 | UNITSOFF 67 | mInf = 1.0/(1+exp(-(v+56.93)/9.09)) : Parri and Crunelli, J. Neurosci. 1998 68 | if(v == -38){ 69 | v = v+0.0001 70 | } 71 | mAlpha = (0.182 * (v- -38))/(1-(exp(-(v- -38)/6))) 72 | mBeta = (0.124 * (-v -38))/(1-(exp(-(-v -38)/6))) 73 | mTau = 6*(1/(mAlpha + mBeta))/qt 74 | 75 | if(v == -17){ 76 | v = v + 0.0001 77 | } 78 | if(v == -64.4){ 79 | v = v+0.0001 80 | } 81 | hInf = 1.0/(1+exp((v+58.7)/14.2)) : Amarillo et al., J Neurophysiol, 2014 82 | hAlpha = -2.88e-6 * (v + 17) / (1 - exp((v + 17)/4.63)) 83 | hBeta = 6.94e-6 * (v + 64.4) / (1 - exp(-(v + 64.4)/2.63)) 84 | hTau = (1/(hAlpha + hBeta))/qt 85 | UNITSON 86 | } 87 | -------------------------------------------------------------------------------- /examples/thalamocortical-cell/mechanisms/TC_cadecay.mod: -------------------------------------------------------------------------------- 1 | : From ModelDB no. 139653 2 | 3 | NEURON { 4 | SUFFIX TC_cad 5 | USEION ca READ ica WRITE cai 6 | RANGE depth,kt,kd,cainf,taur, cai_rec, gamma 7 | } 8 | 9 | UNITS { 10 | 11 | (mM) = (milli/liter) 12 | (um) = (micron) 13 | (mA) = (milliamp) 14 | (msM) = (ms mM) 15 | FARADAY = (faraday) (coulombs) 16 | } 17 | 18 | PARAMETER { 19 | depth = .1 (um) : depth of shell 20 | gamma = 0.05 (1) : EI: percent of free calcium (not buffered) 21 | taur = 5 (ms) : rate of calcium removal 22 | cainf = 5e-5 (mM) : Value from Amarillo et al., J Neurophysiol, 2014 23 | } 24 | 25 | STATE { 26 | cai (mM) 27 | } 28 | 29 | INITIAL { 30 | cai = cainf 31 | } 32 | 33 | ASSIGNED { 34 | ica (mA/cm2) 35 | cai_rec (mM) 36 | } 37 | 38 | BREAKPOINT { 39 | SOLVE state METHOD derivimplicit 40 | 41 | } 42 | 43 | DERIVATIVE state { 44 | 45 | cai' = -(10000)*(ica*gamma/(2*FARADAY*depth)) - (cai - cainf)/taur 46 | cai_rec = cai 47 | 48 | } 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /examples/thalamocortical-cell/mechanisms/TC_iA.mod: -------------------------------------------------------------------------------- 1 | TITLE Fast Transient Potassium Current IA 2 | 3 | : From the model by Huguenard and McCormick, J Neurophysiol, 1992 4 | : Written by Yimy Amarillo, 2014 (Amarillo et al., J Neurophysiol, 2014) 5 | 6 | UNITS { 7 | (mV) = (millivolt) 8 | (mA) = (milliamp) 9 | (S) = (siemens) 10 | } 11 | 12 | NEURON { 13 | SUFFIX TC_iA 14 | USEION k READ ek WRITE ik 15 | RANGE gk_max, ik, taom, taoh1, taoh2 16 | } 17 | 18 | PARAMETER { 19 | gk_max = 5.5e-3 (S/cm2) : Default maximum conductance 20 | celsius 21 | } 22 | 23 | ASSIGNED { 24 | v (mV) 25 | ek (mV) 26 | ik (mA/cm2) 27 | m1inf 28 | m2inf 29 | hinf 30 | taoh1 (ms) 31 | taoh2 (ms) 32 | taom (ms) 33 | tadj 34 | } 35 | 36 | STATE { 37 | m1 m2 h1 h2 38 | } 39 | 40 | BREAKPOINT { 41 | SOLVE states METHOD cnexp 42 | ik = gk_max*(0.6*h1*m1^4+0.4*h2*m2^4)*(v-ek) 43 | } 44 | 45 | INITIAL { 46 | settables(v) 47 | tadj = 2.8 ^ ((celsius-23)/10) 48 | m1 = m1inf 49 | m2 = m2inf 50 | h1 = hinf 51 | h2 = hinf 52 | } 53 | 54 | DERIVATIVE states { 55 | settables(v) 56 | m1' = (m1inf-m1)/taom 57 | m2' = (m2inf-m2)/taom 58 | h1' = (hinf-h1)/taoh1 59 | h2' = (hinf-h2)/taoh2 60 | } 61 | 62 | UNITSOFF 63 | 64 | PROCEDURE settables(v (mV)) { 65 | LOCAL taodef 66 | 67 | m1inf = 1/(1+exp(-(v+60)/8.5)) 68 | m2inf = 1/(1+exp(-(v+36)/20)) 69 | hinf = 1/(1+exp((v+78)/6)) 70 | 71 | taom = (0.37 + 1/(exp((v+35.8)/19.7)+exp(-(v+79.7)/12.7))) / tadj 72 | 73 | taodef = (1/(exp((v+46)/5)+exp(-(v+238)/37.5))) / tadj 74 | if (v<(-63)) {taoh1 = taodef} else {taoh1 = (19 / tadj)} 75 | if (v<(-73)) {taoh2 = taodef} else {taoh2 = (60 / tadj)} 76 | 77 | } 78 | 79 | UNITSON 80 | -------------------------------------------------------------------------------- /examples/thalamocortical-cell/mechanisms/TC_iL.mod: -------------------------------------------------------------------------------- 1 | TITLE high threshold calcium current (L-current) 2 | 3 | : From ModelDB, accession: 3808 4 | : Based on the model by McCormick & Huguenard, J Neurophysiol, 1992 5 | : and errata in https://huguenardlab.stanford.edu/reprints/Errata_thalamic_cell_models.pdf 6 | 7 | INDEPENDENT {t FROM 0 TO 1 WITH 1 (ms)} 8 | 9 | NEURON { 10 | SUFFIX TC_iL 11 | USEION ca READ cai,cao WRITE ica 12 | RANGE pcabar, m_inf, tau_m, ica, i_rec 13 | } 14 | 15 | UNITS { 16 | (mA) = (milliamp) 17 | (mV) = (millivolt) 18 | (molar) = (1/liter) 19 | (mM) = (millimolar) 20 | FARADAY = (faraday) (coulomb) 21 | R = 8.314 (volt-coul/degC) 22 | } 23 | 24 | PARAMETER { 25 | v (mV) 26 | celsius (degC) 27 | dt (ms) 28 | cai = 0.5E-4 (mM) 29 | cao = 2 (mM) 30 | pcabar= 1e-4 (cm/s) 31 | } 32 | 33 | STATE { 34 | m 35 | } 36 | 37 | ASSIGNED { 38 | ica (mA/cm2) 39 | i_rec (mA/cm2) 40 | tau_m (ms) 41 | m_inf 42 | tcorr 43 | } 44 | 45 | BREAKPOINT { 46 | SOLVE states METHOD cnexp 47 | ica = pcabar * m*m * ghk(v,cai,cao) 48 | i_rec = ica 49 | } 50 | 51 | DERIVATIVE states { 52 | rates(v) 53 | 54 | m'= (m_inf-m) / tau_m 55 | } 56 | 57 | INITIAL { 58 | rates(v) 59 | tcorr = 3^((celsius-23.5)/10) 60 | m = 0 61 | } 62 | 63 | UNITSOFF 64 | 65 | FUNCTION ghk( v(mV), ci(mM), co(mM)) (millicoul/cm3) { 66 | LOCAL z, eci, eco 67 | z = v * (.001) * 2 *FARADAY / (R*(celsius+273.15)) 68 | eco = co*efun(z) 69 | eci = ci*efun(-z) 70 | :high cao charge moves inward 71 | :negative potential charge moves inward 72 | ghk = (.001)*2*FARADAY*(eci - eco) 73 | } 74 | 75 | FUNCTION efun(z) { 76 | if (fabs(z) < 1e-4) { 77 | efun = 1 - z/2 78 | }else{ 79 | efun = z/(exp(z) - 1) 80 | } 81 | } 82 | 83 | PROCEDURE rates(v(mV)) { LOCAL a,b 84 | a = 1.6 / (1+ exp(-0.072*(v-5))) 85 | b = 0.02 * vtrap( -(v-1.31), 5.36) 86 | 87 | tau_m = 1/(a+b) / tcorr 88 | m_inf = 1/(1+exp((v+10)/-10)) 89 | } 90 | 91 | FUNCTION vtrap(x,c) { 92 | : Traps for 0 in denominator of rate equations 93 | if (fabs(x/c) < 1e-6) { 94 | vtrap = c + x/2 } 95 | else { 96 | vtrap = x / (1-exp(-x/c)) } 97 | } 98 | UNITSON 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /examples/tsodyksmarkramstp/AUTHORS.txt: -------------------------------------------------------------------------------- 1 | Rodrigo Perin @ LNMC 2 | Giuseppe Chindemi @ BBP 3 | Andras Ecker @ BBP 4 | -------------------------------------------------------------------------------- /examples/tsodyksmarkramstp/README.md: -------------------------------------------------------------------------------- 1 | # Tsodyks-Markram model examples 2 | 3 | The Tsodyks-Markram model of short-term plasticity underwent many changes in the last twenty years. 4 | In this folder we provide 2 examples to fit 2 different versions using BluePyOpt. 5 | 6 | `tsodyksmarkramstp.ipynb` numerically integrates the "full version" of the TM model and fits a postsynaptic voltage trace. 7 | 8 | 9 | `tsodyksmarkramstp_multiplefreqs.ipynb` implements the event-based solution of the (reduced, but) more common version of the TM model and fits amplitudes from multiple stimulation frequencies for better generalization. 10 | 11 | -------------------------------------------------------------------------------- /examples/tsodyksmarkramstp/amps.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BluePyOpt/87325945d120bba99ea51953fe7f1c7f86d58414/examples/tsodyksmarkramstp/amps.pkl -------------------------------------------------------------------------------- /examples/tsodyksmarkramstp/tmodesolve.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """Tsodyks-Markram model ODE solver 3 | This module contains functions to solve the Tsodyks-Markram 4 | model. (same equations as in Maass and Markram 2002) 5 | 6 | @author: Andras Ecker 7 | @remark: Copyright (c) 2017, EPFL/Blue Brain Project 8 | This file is part of BluePyOpt 9 | This library is free software; you can redistribute it and/or modify it 10 | under the terms of the GNU Lesser General Public License version 3.0 as 11 | published by the Free Software Foundation. 12 | This library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | See the GNU Lesser General Public License for more details. 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | """ 21 | 22 | 23 | import numpy as np 24 | 25 | 26 | def solve_TM(t_stims, USE, Trec, Tfac, ASE): 27 | """Solve Tsodyks-Markram model and produce corresponding amplitudes. 28 | 29 | Parameters 30 | ---------- 31 | t_stims : numpy.ndarray 32 | Array of stimulation times (ms) 33 | USE : float 34 | Utilization of Synaptic Efficacy. Has to be in the interval [0, 1]. 35 | Trec : float 36 | Recovery time constant (ms). 37 | Tfac : float 38 | Facilitation time constant (ms). 39 | ASE : float 40 | Absolute Synaptic Efficacy. 41 | 42 | Returns 43 | ------- 44 | Ampls : numpy.ndarray 45 | Normalized amplitudes corresponding to input parameters 46 | tm_statevars : dictionary 47 | Value of state variables at stimulation times 48 | """ 49 | 50 | # Initialize state vectors 51 | U = np.zeros_like(t_stims) 52 | R = np.zeros_like(t_stims) 53 | Ampls = np.zeros_like(t_stims) 54 | R[0] = 1 55 | U[0] = USE 56 | Ampls[0] = ASE*U[0]*R[0] 57 | R[0] = R[0] - R[0]*U[0] 58 | U[0] = U[0] + USE*(1-U[0]) 59 | last_stim = t_stims[0] 60 | 61 | for i in range(1, len(t_stims)): 62 | delta_t = t_stims[i] - last_stim 63 | R[i] = 1 + (R[i-1] - 1)*np.exp(-delta_t/Trec) 64 | U[i] = USE + (U[i-1] - USE)*np.exp(-delta_t/Tfac) 65 | Ampls[i] = ASE*U[i]*R[i] 66 | R[i] = R[i] - R[i]*U[i] 67 | U[i] = U[i] + USE*(1-U[i]) 68 | last_stim = t_stims[i] 69 | 70 | tm_statevars = {"R": R, "U": U} 71 | 72 | return Ampls, tm_statevars 73 | -------------------------------------------------------------------------------- /examples/tsodyksmarkramstp/trace.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BluePyOpt/87325945d120bba99ea51953fe7f1c7f86d58414/examples/tsodyksmarkramstp/trace.pkl -------------------------------------------------------------------------------- /misc/github_wiki/bibtex/thesis_uses_BPO.bib: -------------------------------------------------------------------------------- 1 | 2 | @phdthesis{rizzaBiophysicallyDetailedCerebellar, 3 | title = {A {{Biophysically Detailed Cerebellar Stellate Neuron Model Optimized}} with {{Particle Swarm Optimization Algorithm}}}, 4 | author = {Rizza, Martina Francesca}, 5 | pages = {137}, 6 | langid = {english}, 7 | school = {Universit{\`a} Degli Studi Di Milano-Bicocca}, 8 | year = {2017} 9 | } 10 | 11 | @phdthesis{saraySystematicValidationDetailed, 12 | title = {Systematic Validation of Detailed Models of Hippocampal Neurons Based on Electrophysiological Data}, 13 | author = {S{\'a}ray, S{\'a}ra}, 14 | pages = {112}, 15 | langid = {english}, 16 | school = {P{\'a}zm{\'a}ny P{\'e}ter Catholic University}, 17 | year = {2021} 18 | } 19 | 20 | @phdthesis{deerasooriyaDynamicClampAnalysis, 21 | title = {Dynamic Clamp Analysis of Ion Channel Function}, 22 | author = {Yadeesha Deerasooriya}, 23 | pages = {162}, 24 | langid = {english}, 25 | school = {The University Of Melbourne}, 26 | year = {2019} 27 | } 28 | 29 | @phdthesis{luckmannSimulationBasedInferenceforNeuroscienceandBeyond, 30 | title = {Simulation-Based Inference for Neuroscience and Beyond}, 31 | author = {L{\"u}ckmann, Jan-Matthis}, 32 | langid = {english}, 33 | school = {Eberhard Karls Universit{\"a}t T{\"u}bingen}, 34 | year = {2022} 35 | } 36 | 37 | @phdthesis{nylenStriatumSilicoThesis, 38 | title = {On Striatum in Silico {{Thesis}} for {{Doctoral Degree}} ({{Ph}}.{{D}}.)}, 39 | author = {Nyl{\'e}n, Johanna Frost}, 40 | langid = {english}, 41 | school = {Karolinska Institutet}, 42 | year = {2023} 43 | } 44 | 45 | -------------------------------------------------------------------------------- /misc/pytest_migration/convert_pytest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd bluepyopt/tests 4 | 5 | declare -a StringArray=("./" "test_ephys/" "test_deapext/" ) 6 | 7 | for dir in ${StringArray[@]} 8 | do 9 | touch ${dir}__init__.py 10 | sed -i'' 's/^import utils/from . import utils/g' $dir*.py 11 | sed -i'' 's/import testmodels.dummycells/from .testmodels import dummycells/g' $dir*.py 12 | sed -i'' 's/testmodels.dummycells/dummycells/g' $dir*.py 13 | sed -i'' 's/from deapext_test_utils import make_mock_population/from .deapext_test_utils import make_mock_population/g' $dir*.py 14 | sed -i'' 's/nt.assert_raises/pytest.raises/g' $dir*.py 15 | sed -i'' 's/nt.ok_/nt.assert_true/g' $dir*.py 16 | sed -i'' 's/nt.eq_/nt.assert_equal/g' $dir*.py 17 | sed -i'' 's/nt.assert/assert/g' $dir*.py 18 | sed -i'' 's/assert_almost_equal/numpy.testing.assert_almost_equal/g' $dir*.py 19 | sed -i'' 's/@nt.raises(Exception)/@pytest.mark.xfail(raises=Exception)/g' $dir*.py 20 | # sed -i'' 's/import nose.tools as nt/from . import assert_helpers/g' $dir*.py 21 | sed -i'' 's/import nose.tools as nt//g' $dir*.py 22 | sed -i'' 's/from nose.plugins.attrib import attr/import pytest\nimport numpy/g' $dir*.py 23 | sed -i'' "s/@attr('unit')/@pytest.mark.unit/g" $dir*.py 24 | sed -i'' "s/@attr('slow')/@pytest.mark.slow/g" $dir*.py 25 | # cp ../../assert_helpers.py $dir 26 | done 27 | 28 | nose2pytest -v . 29 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "BluePyOpt", 3 | "description": "The Blue Brain Python Optimisation Library (BluePyOpt) is an extensible framework for data-driven model parameter optimisation that wraps and standardises several existing open-source tools.", 4 | "version": "1.9.50", 5 | "scripts": { 6 | "build_doc": "echo 'bluepyopt.readthedocs.io'" 7 | }, 8 | "repository": { 9 | "type": "git", 10 | "url": "https://github.com/BlueBrain/BluePyOpt/releases", 11 | "issuesurl": "https://github.com/BlueBrain/BluePyOpt/issues" 12 | }, 13 | "author": "Werner Van Geit (werner.vangeit@epfl.ch)", 14 | "contributors": ["Guiseppe Chindemi", "Jean-Denis Courcol", "Tanguy Damart", "Michael Gevaert", "Elisabetta Iavarone", "Christian Roessert", "Anil Tuncel", "Werner Van Geit"], 15 | "license": "LGPL/BSD" 16 | } 17 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools >= 64", "setuptools-scm>=8.0"] 3 | build-backend = "setuptools.build_meta" 4 | 5 | [project] 6 | name = "bluepyopt" 7 | authors = [ 8 | {name = "Blue Brain Project, EPFL", email = "werner.vangeit@epfl.ch"}, 9 | ] 10 | description="Blue Brain Python Optimisation Library (bluepyopt)" 11 | readme = "README.rst" 12 | license = {file = "LICENSE.txt"} 13 | requires-python = ">= 3.9" 14 | dynamic = ["version"] 15 | dependencies = [ 16 | "numpy>=1.6", 17 | "pandas>=0.18", 18 | "deap>=1.3.3", 19 | "efel>=2.13", 20 | "ipyparallel", 21 | "pickleshare>=0.7.3", 22 | "Jinja2>=2.8", 23 | "Pebble>=4.6.0", 24 | "NEURON>=7.8", 25 | ] 26 | classifiers = [ 27 | "Development Status :: 5 - Production/Stable", 28 | "Environment :: Console", 29 | "License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)", 30 | "Programming Language :: Python :: 3 :: Only", 31 | "Operating System :: POSIX", 32 | "Topic :: Scientific/Engineering", 33 | "Topic :: Utilities", 34 | ] 35 | keywords = [ 36 | "optimisation", 37 | "neuroscience", 38 | "BlueBrainProject", 39 | ] 40 | 41 | [project.optional-dependencies] 42 | all = ["scoop>=0.7", "pyneuroml>=0.5.20", "libNeuroML>=0.3.1", "LFPy>=2.3", "arbor>=0.10"] 43 | tests = ["pyneuroml>=0.5.20", "libNeuroML>=0.3.1", "LFPy>=2.3", "arbor>=0.10"] 44 | scoop = ["scoop>=0.7"] 45 | neuroml = ["pyneuroml>=0.5.20", "libNeuroML>=0.3.1"] 46 | lfpy = ["LFPy>=2.3"] 47 | arbor = ["arbor>=0.10"] 48 | 49 | [project.urls] 50 | Homepage = "https://github.com/BlueBrain/BluePyOpt" 51 | Source = "https://github.com/BlueBrain/BluePyOpt" 52 | Repository = "https://github.com/BlueBrain/BluePyOpt.git" 53 | Tracker = "https://github.com/BlueBrain/BluePyOpt/issues" 54 | Documentation = "https://bluepyopt.readthedocs.io/en/latest" 55 | 56 | [project.scripts] 57 | bpopt_tasksdb = "bluepyopt:ipyp.bpopt_tasksdb.main" 58 | 59 | [tool.setuptools] 60 | include-package-data = true 61 | 62 | [tool.setuptools.package-data] 63 | bluepyopt = [ 64 | "ephys/static/arbor_mechanisms.json", 65 | "ephys/templates/cell_template.jinja2", 66 | "ephys/templates/acc/_json_template.jinja2", 67 | "ephys/templates/acc/decor_acc_template.jinja2", 68 | "ephys/templates/acc/label_dict_acc_template.jinja2", 69 | "ephys/examples/simplecell/simple.swc", 70 | "neuroml/NeuroML2_mechanisms/*.nml" 71 | ] 72 | 73 | [tool.setuptools.packages.find] 74 | exclude = ["examples*"] 75 | 76 | [tool.setuptools_scm] 77 | version_scheme = "python-simplified-semver" 78 | local_scheme = "no-local-version" 79 | -------------------------------------------------------------------------------- /pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | markers = 3 | unit 4 | slow 5 | neuroml 6 | filterwarnings = 7 | ignore::RuntimeWarning:deap.* 8 | ignore::DeprecationWarning 9 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | -e . 2 | -------------------------------------------------------------------------------- /requirements_docs.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016-2022, EPFL/Blue Brain Project 2 | # 3 | # This file is part of BluePyOpt 4 | # This library is free software; you can redistribute it and/or modify it under 5 | # the terms of the GNU Lesser General Public License version 3.0 as published 6 | # by the Free Software Foundation. 7 | # This library is distributed in the hope that it will be useful, but WITHOUT 8 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 9 | # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 10 | # details. 11 | # You should have received a copy of the GNU Lesser General Public License 12 | # along with this library; if not, write to the Free Software Foundation, Inc., 13 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 14 | 15 | sphinx>=2.0.0 16 | sphinx-bluebrain-theme 17 | sphinx-autorun -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = py{3}-unit-functional-style 3 | minversion = 4 4 | 5 | [gh-actions] 6 | python = 7 | 3.9: py3 8 | 3.10: py3 9 | 3.11: py3 10 | 3.12: py3 11 | 12 | [testenv] 13 | envdir = 14 | py3{9,10,11,12,}{-unit,-functional,-style,-syntax}: {toxworkdir}/py3 15 | docs: {toxworkdir}/docs 16 | extras = tests 17 | deps = 18 | coverage 19 | flake8 20 | neuron-nightly 21 | sh 22 | pytest-cov 23 | download = true 24 | allowlist_externals = 25 | make 26 | find 27 | cd 28 | pwd 29 | passenv = https_proxy 30 | coverage_options = --cov-append --cov-report=xml --cov-config=.coveragerc 31 | setenv = 32 | ; for neuroml tests 33 | NEURON_HOME={envdir} 34 | commands = 35 | make clean 36 | 37 | style: pycodestyle --ignore=E402,W503,W504 bluepyopt 38 | syntax: flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics 39 | 40 | unit: pytest --cov=bluepyopt {[testenv]coverage_options} bluepyopt/tests -k unit 41 | functional: make stochkv_prepare l5pc_prepare sc_prepare meta_prepare 42 | functional: pytest --cov=bluepyopt {[testenv]coverage_options} bluepyopt/tests -k 'not unit and not neuroml' 43 | ; separate neuroml test from the other ones 44 | ; because it redefines l5pc template which makes neuron crash and tests fail 45 | functional: pytest --cov=bluepyopt {[testenv]coverage_options} bluepyopt/tests -m neuroml 46 | 47 | [testenv:docs] 48 | basepython = python3.9 49 | changedir = docs 50 | deps = 51 | sphinx 52 | sphinx-bluebrain-theme 53 | commands = make html SPHINXOPTS=-W 54 | allowlist_externals = make 55 | --------------------------------------------------------------------------------