├── docs ├── source │ ├── _static │ │ └── .gitkeep │ ├── changelog.rst │ ├── contributing.rst │ ├── logo │ │ └── BlueCelluLabBanner.jpg │ ├── index.rst │ └── api.rst ├── images │ └── voltage-readme.png ├── requirements_docs.txt ├── Makefile └── make.bat ├── tests ├── helpers │ ├── __init__.py │ └── os_utils.py ├── test_cell │ ├── __init__.py │ ├── test_recording.py │ ├── test_random.py │ └── test_cell_dict.py ├── test_circuit │ ├── __init__.py │ ├── test_node_id.py │ ├── test_config_sections.py │ └── test_validate.py ├── test_simulation │ ├── __init__.py │ └── test_parallel.py ├── test_stimulus │ ├── __init__.py │ └── test_circuit_stimulus_definitions.py ├── test_synapse │ ├── __init__.py │ ├── test-synapse-series.json │ └── test_synapse.py ├── __init__.py ├── examples │ ├── sonata_unit_test_sims │ │ ├── projections │ │ │ ├── echo │ │ │ ├── simulation_config.json.SUCCESS │ │ │ ├── output_sonata │ │ │ │ ├── populations_offset.dat │ │ │ │ ├── out.h5 │ │ │ │ └── soma.h5 │ │ │ └── circuit_config.json │ │ ├── condition_parameters │ │ │ ├── sim_conf │ │ │ │ └── populations_offset.dat │ │ │ ├── node_sets.json │ │ │ ├── circuit_sonata.json │ │ │ └── simulation_config.json │ │ └── synapse_replay │ │ │ ├── synapse_replay.h5 │ │ │ └── circuit_config.json │ ├── sim_quick_scx_bluepy │ │ ├── BlueConfig.SUCCESS │ │ ├── output │ │ │ ├── populations_offset.dat │ │ │ ├── out.h5 │ │ │ ├── soma_SONATA.h5 │ │ │ └── out.dat │ │ ├── user.target │ │ └── BlueConfig │ ├── sim_quick_scx_sonata │ │ ├── simulation_config.json.SUCCESS │ │ ├── simulation_config_hypamp.json.SUCCESS │ │ ├── simulation_config_noinput.json.SUCCESS │ │ ├── output_sonata_hypamp │ │ │ ├── populations_offset.dat │ │ │ ├── out.h5 │ │ │ └── soma.h5 │ │ ├── output_sonata_noinput │ │ │ ├── populations_offset.dat │ │ │ ├── out.h5 │ │ │ └── soma.h5 │ │ ├── simulation_config_noinput.json │ │ ├── simulation_config_hypamp.json │ │ └── circuit_sonata.json │ ├── circuit_sonata_quick_scx_multi_circuit │ │ ├── .exception_node │ │ ├── edges_AB.h5 │ │ ├── nodes_A.h5 │ │ ├── nodes_B.h5 │ │ ├── local_edges_A.h5 │ │ ├── local_edges_B.h5 │ │ ├── node_sets.json │ │ └── simulation_sonata.json │ ├── sim_quick_scx_sonata_multicircuit │ │ ├── output_sonata_hypamp │ │ │ ├── populations_offset.dat │ │ │ ├── out.h5 │ │ │ └── soma.h5 │ │ ├── output_sonata_noinput │ │ │ ├── populations_offset.dat │ │ │ ├── out.h5 │ │ │ └── soma.h5 │ │ ├── output_sonata_ornstein │ │ │ ├── populations_offset.dat │ │ │ ├── out.h5 │ │ │ └── soma.h5 │ │ ├── output_sonata_shotnoise │ │ │ ├── populations_offset.dat │ │ │ ├── out.h5 │ │ │ └── soma.h5 │ │ ├── simulation_config_noinput.json │ │ ├── simulation_config_hypamp.json │ │ ├── simulation_config_ornstein.json │ │ └── simulation_config_shotnoise.json │ ├── circuit_sonata_quick_scx │ │ ├── nodes_A.h5 │ │ ├── local_edges_A.h5 │ │ ├── node_sets.json │ │ └── circuit_sonata.json │ ├── circuit_hipp_mooc_most_central_10_SP_PC │ │ ├── edges │ │ │ └── edges.h5 │ │ ├── nodes │ │ │ └── nodes.h5 │ │ ├── hippocampus_projections │ │ │ └── nodes.h5 │ │ ├── circuit_config.json │ │ └── hoc-and-morphs.csv │ ├── ballstick_cell │ │ ├── bs.cfg │ │ └── ballstick.asc │ ├── hippocampus_opt_cell_template │ │ └── README.md │ ├── legacy_circuitconfig │ │ └── CircuitConfig │ └── tapertest_cells │ │ └── notaper_cell.hoc ├── bluecellulab-bb5-tests │ ├── tests │ │ ├── helpers │ │ │ └── __init__.py │ │ ├── examples │ │ │ ├── circuit_twocell_example1 │ │ │ │ ├── default_user.target │ │ │ │ ├── ncsFunctionalAllRecipePathways │ │ │ │ │ ├── start.target │ │ │ │ │ ├── nrn.h5 │ │ │ │ │ └── start.ncs │ │ │ │ ├── nodes.h5 │ │ │ │ ├── circuit.mvd3 │ │ │ │ ├── circuit_mvd2.sqlite │ │ │ │ ├── CircuitConfig │ │ │ │ └── start.target │ │ │ ├── sim_sonata_node │ │ │ │ ├── .gitignore │ │ │ │ ├── nodes.h5 │ │ │ │ └── user.target │ │ │ ├── sim_twocell_empty │ │ │ │ ├── output │ │ │ │ │ ├── out.dat │ │ │ │ │ ├── out.dat.original │ │ │ │ │ └── soma.bbp │ │ │ │ ├── user.target │ │ │ │ ├── run.sh │ │ │ │ └── BlueConfig │ │ │ ├── sim_twocell_noisestim │ │ │ │ ├── output │ │ │ │ │ ├── out.dat │ │ │ │ │ ├── out.dat.original │ │ │ │ │ └── soma.bbp │ │ │ │ ├── user.target │ │ │ │ ├── run.sh │ │ │ │ └── BlueConfig │ │ │ ├── sim_twocell_pulsestim │ │ │ │ ├── output │ │ │ │ │ ├── out.dat │ │ │ │ │ ├── out.dat.original │ │ │ │ │ └── soma.bbp │ │ │ │ ├── user.target │ │ │ │ └── run.sh │ │ │ ├── sim_twocell_all │ │ │ │ ├── output │ │ │ │ │ ├── out.dat │ │ │ │ │ ├── out.dat.original │ │ │ │ │ └── soma.bbp │ │ │ │ ├── user.target │ │ │ │ ├── BlueConfigWithInvalidSpikeLocation │ │ │ │ ├── BlueConfigWithInvalidModOverride │ │ │ │ ├── BlueConfigWithConditions │ │ │ │ ├── BlueConfigWithInvalidConnectionContents │ │ │ │ ├── run.sh │ │ │ │ └── BlueConfigWithInvalidConnectionEntries │ │ │ ├── sim_twocell_all_mvr │ │ │ │ ├── output │ │ │ │ │ ├── out.dat │ │ │ │ │ ├── out.dat.original │ │ │ │ │ └── soma.bbp │ │ │ │ ├── user.target │ │ │ │ └── run.sh │ │ │ ├── sim_twocell_replay │ │ │ │ ├── output │ │ │ │ │ ├── out.dat │ │ │ │ │ ├── out.dat.original │ │ │ │ │ └── soma.bbp │ │ │ │ ├── user.target │ │ │ │ ├── run.sh │ │ │ │ └── BlueConfig │ │ │ ├── sim_twocell_minis_replay │ │ │ │ ├── output │ │ │ │ │ ├── out.dat │ │ │ │ │ ├── out.dat.original │ │ │ │ │ ├── out-contains-negatives.dat │ │ │ │ │ └── soma.bbp │ │ │ │ ├── user.target │ │ │ │ ├── run.sh │ │ │ │ └── BlueConfig │ │ │ └── sim_twocell_forwardskip │ │ │ │ ├── user.target │ │ │ │ └── BlueConfig │ │ ├── test_sonata_proxy_gpfs.py │ │ ├── test_helpers.py │ │ └── test_iotools.py │ ├── .gitignore │ ├── test_requirements.txt │ ├── pytest.ini │ ├── tox.ini │ ├── pyvenv.cfg │ ├── .compile_mod.sh │ └── Makefile ├── data │ └── synapse_replay_file │ │ └── spikes.h5 ├── mechanisms │ ├── gap.mod │ ├── TC_Kleak.mod │ ├── README.md │ ├── TC_Naleak.mod │ ├── CaDynamics_E2.mod │ ├── TC_cadecay.mod │ ├── SKv3_1.mod │ ├── Im.mod │ ├── Ih.mod │ ├── SK_E2.mod │ ├── IN_Ih_Halnes2011.mod │ ├── Ca.mod │ ├── KdShu2007.mod │ ├── TC_Ih_Bud97.mod │ ├── Ca_HVA.mod │ ├── cacumm.mod │ ├── TC_kir_Con15.mod │ ├── Ca_LVAst.mod │ ├── K_Tst.mod │ ├── cacummb.mod │ ├── CaDynamics_DC0.mod │ ├── Ca_HVA2.mod │ ├── K_Pst.mod │ ├── kmb.mod │ ├── kdb.mod │ ├── h.mod │ ├── kd.mod │ ├── kdrbca1.mod │ ├── kd2.mod │ ├── kdrca1.mod │ └── TTXDynamicsSwitch.mod ├── LICENSE ├── test_exceptions.py └── test_ssim.py ├── bluecellulab ├── analysis │ └── __init__.py ├── stimulus │ └── __init__.py ├── synapse │ └── __init__.py ├── cell │ ├── __init__.py │ ├── ballstick │ │ ├── morphology.asc │ │ └── __init__.py │ ├── recording.py │ ├── cell_dict.py │ ├── sonata_proxy.py │ └── serialized_sections.py ├── circuit │ ├── circuit_access │ │ └── __init__.py │ ├── config │ │ └── __init__.py │ ├── __init__.py │ ├── node_id.py │ └── iotools.py ├── simulation │ ├── __init__.py │ └── parallel.py ├── type_aliases.py ├── __init__.py ├── hoc │ └── RNGSettings.hoc ├── verbosity.py └── utils.py ├── .gitattributes ├── examples ├── 2-sonata-network │ ├── circuit_sonata_quick_scx_multi_circuit │ │ ├── .exception_node │ │ ├── nodes_A.h5 │ │ ├── nodes_B.h5 │ │ ├── edges_AB.h5 │ │ ├── local_edges_A.h5 │ │ ├── local_edges_B.h5 │ │ ├── node_sets.json │ │ └── simulation_sonata.json │ └── sim_quick_scx_sonata_multicircuit │ │ ├── output_sonata_hypamp │ │ ├── populations_offset.dat │ │ ├── out.h5 │ │ └── soma.h5 │ │ ├── output_sonata_noinput │ │ ├── populations_offset.dat │ │ ├── out.h5 │ │ └── soma.h5 │ │ ├── output_sonata_ornstein │ │ ├── populations_offset.dat │ │ ├── out.h5 │ │ └── soma.h5 │ │ ├── output_sonata_shotnoise │ │ ├── populations_offset.dat │ │ ├── out.h5 │ │ └── soma.h5 │ │ ├── simulation_config_noinput.json │ │ ├── simulation_config_hypamp.json │ │ ├── simulation_config_ornstein.json │ │ └── simulation_config_shotnoise.json ├── mechanisms │ ├── README.md │ ├── gap.mod │ ├── CaDynamics_E2.mod │ ├── SKv3_1.mod │ ├── Im.mod │ ├── Ih.mod │ ├── SK_E2.mod │ ├── Ca.mod │ ├── KdShu2007.mod │ ├── Ca_HVA.mod │ ├── Ca_LVAst.mod │ ├── K_Tst.mod │ ├── CaDynamics_DC0.mod │ ├── Ca_HVA2.mod │ ├── K_Pst.mod │ └── TTXDynamicsSwitch.mod ├── LICENSE ├── 1-singlecell │ └── README.md ├── README.rst └── 4-epsp │ └── hippocampus_mechanisms │ ├── cacumm.mod │ ├── kmb.mod │ ├── h.mod │ ├── kdb.mod │ └── kdrbca1.mod ├── Makefile ├── MANIFEST.in ├── AUTHORS.txt ├── .gitignore ├── .readthedocs.yml ├── .github └── dependabot.yml ├── .compile_mod.sh ├── .gitlab-ci.yml ├── CONTRIBUTING.rst └── CITATION.cff /docs/source/_static/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/helpers/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/test_cell/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bluecellulab/analysis/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/test_circuit/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/test_simulation/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/test_stimulus/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/test_synapse/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | """Tests module.""" 2 | -------------------------------------------------------------------------------- /tests/examples/sonata_unit_test_sims/projections/echo: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/helpers/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_bluepy/BlueConfig.SUCCESS: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/source/changelog.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../../CHANGELOG.rst 2 | -------------------------------------------------------------------------------- /docs/source/contributing.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../../CONTRIBUTING.rst 2 | -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_sonata/simulation_config.json.SUCCESS: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_sonata/simulation_config_hypamp.json.SUCCESS: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bluecellulab/stimulus/__init__.py: -------------------------------------------------------------------------------- 1 | from .factory import StimulusFactory 2 | -------------------------------------------------------------------------------- /tests/examples/circuit_sonata_quick_scx_multi_circuit/.exception_node: -------------------------------------------------------------------------------- 1 | 5 2 | -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_sonata/simulation_config_noinput.json.SUCCESS: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_bluepy/output/populations_offset.dat: -------------------------------------------------------------------------------- 1 | NodeA::0:: 2 | -------------------------------------------------------------------------------- /tests/examples/sonata_unit_test_sims/projections/simulation_config.json.SUCCESS: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.asc linguist-detectable=false 2 | *.mod linguist-detectable=false 3 | -------------------------------------------------------------------------------- /examples/2-sonata-network/circuit_sonata_quick_scx_multi_circuit/.exception_node: -------------------------------------------------------------------------------- 1 | 5 2 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/circuit_twocell_example1/default_user.target: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_sonata_node/.gitignore: -------------------------------------------------------------------------------- 1 | /BlueConfig 2 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_empty/output/out.dat: -------------------------------------------------------------------------------- 1 | /scatter 2 | 5000000.0 2 3 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_noisestim/output/out.dat: -------------------------------------------------------------------------------- 1 | /scatter 2 | 5000000.0 2 3 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_pulsestim/output/out.dat: -------------------------------------------------------------------------------- 1 | /scatter 2 | 5000000.0 2 3 | -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_sonata/output_sonata_hypamp/populations_offset.dat: -------------------------------------------------------------------------------- 1 | ::0:: 2 | NodeA::0::NodeA 3 | -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_sonata/output_sonata_noinput/populations_offset.dat: -------------------------------------------------------------------------------- 1 | ::0:: 2 | NodeA::0::NodeA 3 | -------------------------------------------------------------------------------- /docs/images/voltage-readme.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/docs/images/voltage-readme.png -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_empty/output/out.dat.original: -------------------------------------------------------------------------------- 1 | /scatter 2 | 5000000.0 2 3 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_noisestim/output/out.dat.original: -------------------------------------------------------------------------------- 1 | /scatter 2 | 5000000.0 2 3 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_pulsestim/output/out.dat.original: -------------------------------------------------------------------------------- 1 | /scatter 2 | 5000000.0 2 3 | -------------------------------------------------------------------------------- /tests/examples/sonata_unit_test_sims/condition_parameters/sim_conf/populations_offset.dat: -------------------------------------------------------------------------------- 1 | ::0:: 2 | NodeA::0::NodeA 3 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/circuit_twocell_example1/ncsFunctionalAllRecipePathways/start.target: -------------------------------------------------------------------------------- 1 | ../start.target -------------------------------------------------------------------------------- /docs/requirements_docs.txt: -------------------------------------------------------------------------------- 1 | sphinx>=7.0.1 2 | sphinx-bluebrain-theme>=0.4.1 3 | sphinx_autodoc_typehints>=1.23.2 4 | seaborn>=0.13.2 5 | -------------------------------------------------------------------------------- /docs/source/logo/BlueCelluLabBanner.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/docs/source/logo/BlueCelluLabBanner.jpg -------------------------------------------------------------------------------- /tests/data/synapse_replay_file/spikes.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/data/synapse_replay_file/spikes.h5 -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_sonata_multicircuit/output_sonata_hypamp/populations_offset.dat: -------------------------------------------------------------------------------- 1 | ::0:: 2 | NodeA::0::NodeA 3 | NodeB::1000::NodeB 4 | -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_sonata_multicircuit/output_sonata_noinput/populations_offset.dat: -------------------------------------------------------------------------------- 1 | ::0:: 2 | NodeA::0::NodeA 3 | NodeB::1000::NodeB 4 | -------------------------------------------------------------------------------- /tests/examples/sonata_unit_test_sims/projections/output_sonata/populations_offset.dat: -------------------------------------------------------------------------------- 1 | ::0:: 2 | hippocampus_neurons::0::hippocampus_neurons 3 | -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_sonata_multicircuit/output_sonata_ornstein/populations_offset.dat: -------------------------------------------------------------------------------- 1 | ::0:: 2 | NodeA::0::NodeA 3 | NodeB::1000::NodeB 4 | -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_sonata_multicircuit/output_sonata_shotnoise/populations_offset.dat: -------------------------------------------------------------------------------- 1 | ::0:: 2 | NodeA::0::NodeA 3 | NodeB::1000::NodeB 4 | -------------------------------------------------------------------------------- /examples/2-sonata-network/sim_quick_scx_sonata_multicircuit/output_sonata_hypamp/populations_offset.dat: -------------------------------------------------------------------------------- 1 | ::0:: 2 | NodeA::0::NodeA 3 | NodeB::1000::NodeB 4 | -------------------------------------------------------------------------------- /tests/examples/circuit_sonata_quick_scx/nodes_A.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/examples/circuit_sonata_quick_scx/nodes_A.h5 -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_bluepy/output/out.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/examples/sim_quick_scx_bluepy/output/out.h5 -------------------------------------------------------------------------------- /examples/2-sonata-network/sim_quick_scx_sonata_multicircuit/output_sonata_noinput/populations_offset.dat: -------------------------------------------------------------------------------- 1 | ::0:: 2 | NodeA::0::NodeA 3 | NodeB::1000::NodeB 4 | -------------------------------------------------------------------------------- /examples/2-sonata-network/sim_quick_scx_sonata_multicircuit/output_sonata_ornstein/populations_offset.dat: -------------------------------------------------------------------------------- 1 | ::0:: 2 | NodeA::0::NodeA 3 | NodeB::1000::NodeB 4 | -------------------------------------------------------------------------------- /examples/2-sonata-network/sim_quick_scx_sonata_multicircuit/output_sonata_shotnoise/populations_offset.dat: -------------------------------------------------------------------------------- 1 | ::0:: 2 | NodeA::0::NodeA 3 | NodeB::1000::NodeB 4 | -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_bluepy/user.target: -------------------------------------------------------------------------------- 1 | Target Cell Mosaic_A 2 | { 3 | a1 a2 a3 4 | } 5 | 6 | Target Cell Mosaic_B 7 | { 8 | a1 a2 9 | } 10 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_all/output/out.dat: -------------------------------------------------------------------------------- 1 | /scatter 2 | 15.0 2 3 | 30.0 2 4 | 45.0 2 5 | 60.0 2 6 | 75.0 2 7 | 90.0 2 8 | 5000000.0 2 9 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_all_mvr/output/out.dat: -------------------------------------------------------------------------------- 1 | /scatter 2 | 15.0 2 3 | 30.0 2 4 | 45.0 2 5 | 60.0 2 6 | 75.0 2 7 | 90.0 2 8 | 5000000.0 2 9 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_replay/output/out.dat: -------------------------------------------------------------------------------- 1 | /scatter 2 | 15.0 2 3 | 30.0 2 4 | 45.0 2 5 | 60.0 2 6 | 75.0 2 7 | 90.0 2 8 | 5000000.0 2 9 | -------------------------------------------------------------------------------- /tests/examples/circuit_sonata_quick_scx/local_edges_A.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/examples/circuit_sonata_quick_scx/local_edges_A.h5 -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_bluepy/output/soma_SONATA.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/examples/sim_quick_scx_bluepy/output/soma_SONATA.h5 -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | clean: 2 | rm -f .coverage 3 | rm -f .coverage.* 4 | rm -f *.coverage 5 | rm -f coverage.xml 6 | rm -f *.nrndat 7 | rm -f .coverage.* 8 | rm -f python.*.btr 9 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_all/output/out.dat.original: -------------------------------------------------------------------------------- 1 | /scatter 2 | 15.0 2 3 | 30.0 2 4 | 45.0 2 5 | 60.0 2 6 | 75.0 2 7 | 90.0 2 8 | 5000000.0 2 9 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_minis_replay/output/out.dat: -------------------------------------------------------------------------------- 1 | /scatter 2 | 15.0 2 3 | 30.0 2 4 | 45.0 2 5 | 60.0 2 6 | 75.0 2 7 | 90.0 2 8 | 5000000.0 2 9 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | recursive-include bluecellulab/hoc *.hoc 2 | recursive-include bluecellulab/cell/ballstick *.asc *.hoc 3 | recursive-exclude examples * 4 | recursive-exclude tests * 5 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_all_mvr/output/out.dat.original: -------------------------------------------------------------------------------- 1 | /scatter 2 | 15.0 2 3 | 30.0 2 4 | 45.0 2 5 | 60.0 2 6 | 75.0 2 7 | 90.0 2 8 | 5000000.0 2 9 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_replay/output/out.dat.original: -------------------------------------------------------------------------------- 1 | /scatter 2 | 15.0 2 3 | 30.0 2 4 | 45.0 2 5 | 60.0 2 6 | 75.0 2 7 | 90.0 2 8 | 5000000.0 2 9 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_minis_replay/output/out.dat.original: -------------------------------------------------------------------------------- 1 | /scatter 2 | 15.0 2 3 | 30.0 2 4 | 45.0 2 5 | 60.0 2 6 | 75.0 2 7 | 90.0 2 8 | 5000000.0 2 9 | -------------------------------------------------------------------------------- /tests/examples/circuit_sonata_quick_scx_multi_circuit/edges_AB.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/examples/circuit_sonata_quick_scx_multi_circuit/edges_AB.h5 -------------------------------------------------------------------------------- /tests/examples/circuit_sonata_quick_scx_multi_circuit/nodes_A.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/examples/circuit_sonata_quick_scx_multi_circuit/nodes_A.h5 -------------------------------------------------------------------------------- /tests/examples/circuit_sonata_quick_scx_multi_circuit/nodes_B.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/examples/circuit_sonata_quick_scx_multi_circuit/nodes_B.h5 -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_sonata/output_sonata_hypamp/out.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/examples/sim_quick_scx_sonata/output_sonata_hypamp/out.h5 -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_sonata/output_sonata_hypamp/soma.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/examples/sim_quick_scx_sonata/output_sonata_hypamp/soma.h5 -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_sonata/output_sonata_noinput/out.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/examples/sim_quick_scx_sonata/output_sonata_noinput/out.h5 -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_sonata/output_sonata_noinput/soma.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/examples/sim_quick_scx_sonata/output_sonata_noinput/soma.h5 -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/.gitignore: -------------------------------------------------------------------------------- 1 | *.nrndat 2 | bin 3 | lib 4 | share 5 | .pytest_cache 6 | .tox-info.json 7 | .tox 8 | .neurodamus 9 | __pycache__ 10 | x86_64 11 | nrnivmodl.log 12 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_sonata_node/nodes.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/bluecellulab-bb5-tests/tests/examples/sim_sonata_node/nodes.h5 -------------------------------------------------------------------------------- /tests/examples/circuit_hipp_mooc_most_central_10_SP_PC/edges/edges.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/examples/circuit_hipp_mooc_most_central_10_SP_PC/edges/edges.h5 -------------------------------------------------------------------------------- /tests/examples/circuit_hipp_mooc_most_central_10_SP_PC/nodes/nodes.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/examples/circuit_hipp_mooc_most_central_10_SP_PC/nodes/nodes.h5 -------------------------------------------------------------------------------- /tests/examples/circuit_sonata_quick_scx/node_sets.json: -------------------------------------------------------------------------------- 1 | { 2 | "Mosaic_A": { 3 | "population": "NodeA" 4 | }, 5 | "Mosaic_B": { 6 | "population": "NodeB" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tests/examples/circuit_sonata_quick_scx_multi_circuit/local_edges_A.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/examples/circuit_sonata_quick_scx_multi_circuit/local_edges_A.h5 -------------------------------------------------------------------------------- /tests/examples/circuit_sonata_quick_scx_multi_circuit/local_edges_B.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/examples/circuit_sonata_quick_scx_multi_circuit/local_edges_B.h5 -------------------------------------------------------------------------------- /tests/examples/sonata_unit_test_sims/projections/output_sonata/out.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/examples/sonata_unit_test_sims/projections/output_sonata/out.h5 -------------------------------------------------------------------------------- /tests/examples/sonata_unit_test_sims/projections/output_sonata/soma.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/examples/sonata_unit_test_sims/projections/output_sonata/soma.h5 -------------------------------------------------------------------------------- /tests/examples/sonata_unit_test_sims/synapse_replay/synapse_replay.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/examples/sonata_unit_test_sims/synapse_replay/synapse_replay.h5 -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/test_requirements.txt: -------------------------------------------------------------------------------- 1 | bluepy-configfile>=0.1.18 2 | bluepy[bbp]>=2.5.0 3 | pytest 4 | pytest-timeout 5 | pytest-xdist 6 | pytest-forked 7 | ruff>=0.0.40 8 | mypy>=1.2.0 9 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_minis_replay/output/out-contains-negatives.dat: -------------------------------------------------------------------------------- 1 | /scatter 2 | 15.0 2 3 | -30.0 2 4 | 45.0 2 5 | -60.0 2 6 | -75.0 2 7 | 90.0 2 8 | 5000000.0 2 9 | -------------------------------------------------------------------------------- /tests/examples/sonata_unit_test_sims/condition_parameters/node_sets.json: -------------------------------------------------------------------------------- 1 | { 2 | "Mosaic_A": { 3 | "population": "NodeA" 4 | }, 5 | "Mosaic_B": { 6 | "population": "NodeB" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /examples/2-sonata-network/circuit_sonata_quick_scx_multi_circuit/nodes_A.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/examples/2-sonata-network/circuit_sonata_quick_scx_multi_circuit/nodes_A.h5 -------------------------------------------------------------------------------- /examples/2-sonata-network/circuit_sonata_quick_scx_multi_circuit/nodes_B.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/examples/2-sonata-network/circuit_sonata_quick_scx_multi_circuit/nodes_B.h5 -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_all/output/soma.bbp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_all/output/soma.bbp -------------------------------------------------------------------------------- /examples/2-sonata-network/circuit_sonata_quick_scx_multi_circuit/edges_AB.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/examples/2-sonata-network/circuit_sonata_quick_scx_multi_circuit/edges_AB.h5 -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/circuit_twocell_example1/nodes.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/bluecellulab-bb5-tests/tests/examples/circuit_twocell_example1/nodes.h5 -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_empty/output/soma.bbp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_empty/output/soma.bbp -------------------------------------------------------------------------------- /tests/examples/circuit_sonata_quick_scx_multi_circuit/node_sets.json: -------------------------------------------------------------------------------- 1 | { 2 | "Mosaic_A": { 3 | "population": "NodeA" 4 | }, 5 | "Mosaic_B": { 6 | "population": "NodeB" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_sonata_multicircuit/output_sonata_hypamp/out.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/examples/sim_quick_scx_sonata_multicircuit/output_sonata_hypamp/out.h5 -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_sonata_multicircuit/output_sonata_hypamp/soma.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/examples/sim_quick_scx_sonata_multicircuit/output_sonata_hypamp/soma.h5 -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_sonata_multicircuit/output_sonata_noinput/out.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/examples/sim_quick_scx_sonata_multicircuit/output_sonata_noinput/out.h5 -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_all_mvr/output/soma.bbp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_all_mvr/output/soma.bbp -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_replay/output/soma.bbp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_replay/output/soma.bbp -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_sonata_multicircuit/output_sonata_noinput/soma.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/examples/sim_quick_scx_sonata_multicircuit/output_sonata_noinput/soma.h5 -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_sonata_multicircuit/output_sonata_ornstein/out.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/examples/sim_quick_scx_sonata_multicircuit/output_sonata_ornstein/out.h5 -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_sonata_multicircuit/output_sonata_ornstein/soma.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/examples/sim_quick_scx_sonata_multicircuit/output_sonata_ornstein/soma.h5 -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_sonata_multicircuit/output_sonata_shotnoise/out.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/examples/sim_quick_scx_sonata_multicircuit/output_sonata_shotnoise/out.h5 -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_sonata_multicircuit/output_sonata_shotnoise/soma.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/examples/sim_quick_scx_sonata_multicircuit/output_sonata_shotnoise/soma.h5 -------------------------------------------------------------------------------- /examples/2-sonata-network/circuit_sonata_quick_scx_multi_circuit/local_edges_A.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/examples/2-sonata-network/circuit_sonata_quick_scx_multi_circuit/local_edges_A.h5 -------------------------------------------------------------------------------- /examples/2-sonata-network/circuit_sonata_quick_scx_multi_circuit/local_edges_B.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/examples/2-sonata-network/circuit_sonata_quick_scx_multi_circuit/local_edges_B.h5 -------------------------------------------------------------------------------- /examples/2-sonata-network/circuit_sonata_quick_scx_multi_circuit/node_sets.json: -------------------------------------------------------------------------------- 1 | { 2 | "Mosaic_A": { 3 | "population": "NodeA" 4 | }, 5 | "Mosaic_B": { 6 | "population": "NodeB" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | markers = 3 | v5: tests on the neocortex circuit version 5. 4 | v6: tests on the neocortex circuit version 6. 5 | thal: tests on the thalamus circuit. 6 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/circuit_twocell_example1/circuit.mvd3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/bluecellulab-bb5-tests/tests/examples/circuit_twocell_example1/circuit.mvd3 -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_noisestim/output/soma.bbp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_noisestim/output/soma.bbp -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_pulsestim/output/soma.bbp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_pulsestim/output/soma.bbp -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_minis_replay/output/soma.bbp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_minis_replay/output/soma.bbp -------------------------------------------------------------------------------- /examples/2-sonata-network/sim_quick_scx_sonata_multicircuit/output_sonata_hypamp/out.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/examples/2-sonata-network/sim_quick_scx_sonata_multicircuit/output_sonata_hypamp/out.h5 -------------------------------------------------------------------------------- /tests/examples/circuit_hipp_mooc_most_central_10_SP_PC/hippocampus_projections/nodes.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/examples/circuit_hipp_mooc_most_central_10_SP_PC/hippocampus_projections/nodes.h5 -------------------------------------------------------------------------------- /examples/2-sonata-network/sim_quick_scx_sonata_multicircuit/output_sonata_hypamp/soma.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/examples/2-sonata-network/sim_quick_scx_sonata_multicircuit/output_sonata_hypamp/soma.h5 -------------------------------------------------------------------------------- /examples/2-sonata-network/sim_quick_scx_sonata_multicircuit/output_sonata_noinput/out.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/examples/2-sonata-network/sim_quick_scx_sonata_multicircuit/output_sonata_noinput/out.h5 -------------------------------------------------------------------------------- /examples/2-sonata-network/sim_quick_scx_sonata_multicircuit/output_sonata_noinput/soma.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/examples/2-sonata-network/sim_quick_scx_sonata_multicircuit/output_sonata_noinput/soma.h5 -------------------------------------------------------------------------------- /examples/2-sonata-network/sim_quick_scx_sonata_multicircuit/output_sonata_ornstein/out.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/examples/2-sonata-network/sim_quick_scx_sonata_multicircuit/output_sonata_ornstein/out.h5 -------------------------------------------------------------------------------- /examples/2-sonata-network/sim_quick_scx_sonata_multicircuit/output_sonata_ornstein/soma.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/examples/2-sonata-network/sim_quick_scx_sonata_multicircuit/output_sonata_ornstein/soma.h5 -------------------------------------------------------------------------------- /examples/2-sonata-network/sim_quick_scx_sonata_multicircuit/output_sonata_shotnoise/out.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/examples/2-sonata-network/sim_quick_scx_sonata_multicircuit/output_sonata_shotnoise/out.h5 -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/circuit_twocell_example1/circuit_mvd2.sqlite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/bluecellulab-bb5-tests/tests/examples/circuit_twocell_example1/circuit_mvd2.sqlite -------------------------------------------------------------------------------- /AUTHORS.txt: -------------------------------------------------------------------------------- 1 | Authors 2 | ======================== 3 | 4 | This software was developed at the Blue Brain Project, EPFL: 5 | 6 | * Werner Van Geit 7 | * Anil Tuncel 8 | * Mike Gevaert 9 | * Ben Torben Nielsen 10 | * Eilif Muller 11 | -------------------------------------------------------------------------------- /bluecellulab/synapse/__init__.py: -------------------------------------------------------------------------------- 1 | """Synapse and synapse parameters representation and operations.""" 2 | 3 | from .synapse_types import Synapse, AmpanmdaSynapse, GabaabSynapse, GluSynapse 4 | from .synapse_factory import SynapseFactory 5 | -------------------------------------------------------------------------------- /examples/2-sonata-network/sim_quick_scx_sonata_multicircuit/output_sonata_shotnoise/soma.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/examples/2-sonata-network/sim_quick_scx_sonata_multicircuit/output_sonata_shotnoise/soma.h5 -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_sonata_node/user.target: -------------------------------------------------------------------------------- 1 | Target Cell PreCell 2 | { 3 | a2 4 | } 5 | 6 | Target Cell PostCell 7 | { 8 | a1 9 | } 10 | 11 | Target Cell MyPairs 12 | { 13 | PreCell PostCell 14 | } 15 | 16 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_all/user.target: -------------------------------------------------------------------------------- 1 | Target Cell PreCell 2 | { 3 | a2 4 | } 5 | 6 | Target Cell PostCell 7 | { 8 | a1 9 | } 10 | 11 | Target Cell MyPairs 12 | { 13 | PreCell PostCell 14 | } 15 | 16 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_empty/user.target: -------------------------------------------------------------------------------- 1 | Target Cell PreCell 2 | { 3 | a2 4 | } 5 | 6 | Target Cell PostCell 7 | { 8 | a1 9 | } 10 | 11 | Target Cell MyPairs 12 | { 13 | PreCell PostCell 14 | } 15 | 16 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_all_mvr/user.target: -------------------------------------------------------------------------------- 1 | Target Cell PreCell 2 | { 3 | a2 4 | } 5 | 6 | Target Cell PostCell 7 | { 8 | a1 9 | } 10 | 11 | Target Cell MyPairs 12 | { 13 | PreCell PostCell 14 | } 15 | 16 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_noisestim/user.target: -------------------------------------------------------------------------------- 1 | Target Cell PreCell 2 | { 3 | a2 4 | } 5 | 6 | Target Cell PostCell 7 | { 8 | a1 9 | } 10 | 11 | Target Cell MyPairs 12 | { 13 | PreCell PostCell 14 | } 15 | 16 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_pulsestim/user.target: -------------------------------------------------------------------------------- 1 | Target Cell PreCell 2 | { 3 | a2 4 | } 5 | 6 | Target Cell PostCell 7 | { 8 | a1 9 | } 10 | 11 | Target Cell MyPairs 12 | { 13 | PreCell PostCell 14 | } 15 | 16 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_replay/user.target: -------------------------------------------------------------------------------- 1 | Target Cell PreCell 2 | { 3 | a2 4 | } 5 | 6 | Target Cell PostCell 7 | { 8 | a1 9 | } 10 | 11 | Target Cell MyPairs 12 | { 13 | PreCell PostCell 14 | } 15 | 16 | -------------------------------------------------------------------------------- /tests/examples/ballstick_cell/bs.cfg: -------------------------------------------------------------------------------- 1 | [neuron] 2 | CM: 1.000000 3 | RM: 33333.333333 4 | RA: 100.000000 5 | EL: -75.000000 6 | 7 | [soma] 8 | D: 10 9 | L: 27.7746918378 10 | 11 | [morph] 12 | lengths: [200.000000] 13 | diams: [3.000000] 14 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_forwardskip/user.target: -------------------------------------------------------------------------------- 1 | Target Cell PreCell 2 | { 3 | a2 4 | } 5 | 6 | Target Cell PostCell 7 | { 8 | a1 9 | } 10 | 11 | Target Cell MyPairs 12 | { 13 | PreCell PostCell 14 | } 15 | 16 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_minis_replay/user.target: -------------------------------------------------------------------------------- 1 | Target Cell PreCell 2 | { 3 | a2 4 | } 5 | 6 | Target Cell PostCell 7 | { 8 | a1 9 | } 10 | 11 | Target Cell MyPairs 12 | { 13 | PreCell PostCell 14 | } 15 | 16 | -------------------------------------------------------------------------------- /bluecellulab/cell/__init__.py: -------------------------------------------------------------------------------- 1 | """The cell module representing the NEURON cell and operations on it.""" 2 | 3 | from .core import Cell 4 | from .cell_dict import CellDict 5 | from .sonata_proxy import SonataProxy 6 | from .ballstick import create_ball_stick 7 | -------------------------------------------------------------------------------- /bluecellulab/circuit/circuit_access/__init__.py: -------------------------------------------------------------------------------- 1 | from .definition import EmodelProperties, CircuitAccess, get_synapse_connection_parameters 2 | from .bluepy_circuit_access import BluepyCircuitAccess 3 | from .sonata_circuit_access import SonataCircuitAccess 4 | -------------------------------------------------------------------------------- /bluecellulab/simulation/__init__.py: -------------------------------------------------------------------------------- 1 | """Simulation module responsible of NEURON simulation.""" 2 | 3 | from .simulation import Simulation 4 | from .neuron_globals import set_global_condition_parameters 5 | from .neuron_globals import set_minis_single_vesicle_values 6 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/circuit_twocell_example1/ncsFunctionalAllRecipePathways/nrn.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/HEAD/tests/bluecellulab-bb5-tests/tests/examples/circuit_twocell_example1/ncsFunctionalAllRecipePathways/nrn.h5 -------------------------------------------------------------------------------- /bluecellulab/circuit/config/__init__.py: -------------------------------------------------------------------------------- 1 | """Simulation configuration file parser module.""" 2 | 3 | from .definition import SimulationConfig 4 | from .bluepy_simulation_config import BluepySimulationConfig 5 | from .sonata_simulation_config import SonataSimulationConfig 6 | -------------------------------------------------------------------------------- /tests/examples/hippocampus_opt_cell_template/README.md: -------------------------------------------------------------------------------- 1 | This cell is employed for testing the loading of templates. 2 | 3 | To avoid the unnecessary compilation of ion channel mechanisms, they have been deactivated in the hoc. 4 | 5 | **Caution:** do not use this cell in scientific simulations. 6 | -------------------------------------------------------------------------------- /bluecellulab/cell/ballstick/morphology.asc: -------------------------------------------------------------------------------- 1 | ("CellBody" 2 | (Color Red) 3 | (CellBody) 4 | (10, 0, 0, 0) 5 | (0, 10, 0, 0) 6 | (-10, 0, 0, 0) 7 | (0, -10, 0, 0) 8 | (10, 0, 0, 0) 9 | ); 10 | 11 | ( (Color Green) 12 | (Dendrite) 13 | (10, 0, 0, 3) 14 | (210, 0, 0, 3) 15 | ); 16 | -------------------------------------------------------------------------------- /examples/mechanisms/README.md: -------------------------------------------------------------------------------- 1 | Common, neocortex-v5 and neocortex-v6 mod files are merged. Below are the sources. 2 | 3 | Common mods repository: hpc/sim/models/common.git 4 | Common mods git hash: bfe26c3d 5 | 6 | Neocortex mods repository: hpc/sim/models/neocortex.git 7 | Neocortex mods git hash: 7feb8d9 8 | -------------------------------------------------------------------------------- /tests/examples/ballstick_cell/ballstick.asc: -------------------------------------------------------------------------------- 1 | ("CellBody" 2 | (Color Red) 3 | (CellBody) 4 | (10, 0, 0, 0) 5 | (0, 10, 0, 0) 6 | (-10, 0, 0, 0) 7 | (0, -10, 0, 0) 8 | (10, 0, 0, 0) 9 | ); 10 | 11 | ( (Color Green) 12 | (Dendrite) 13 | (10, 0, 0, 3) 14 | (210, 0, 0, 3) 15 | ); 16 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/circuit_twocell_example1/ncsFunctionalAllRecipePathways/start.ncs: -------------------------------------------------------------------------------- 1 | # File generated by bluepy circuit extractor 2 | Cells 2 3 | { 4 | a1 1 1 a1.nrn cADpyr232_L5_TTPC1_5_dend-C220197A-P2_axon-C060110A3_-_Clone_2 5 | a2 1 1 a2.nrn cADpyr231_L6_TPC_L1_6_dend-tkb060530a2_ch1_ct_n_ab_100x_1_axon-tkb060123a1_ch1_ct_b_hw_60x_1_-_Clone_1 6 | } 7 | -------------------------------------------------------------------------------- /tests/mechanisms/gap.mod: -------------------------------------------------------------------------------- 1 | NEURON { 2 | POINT_PROCESS Gap 3 | RANGE vgap 4 | RANGE g, i 5 | NONSPECIFIC_CURRENT i 6 | RANGE synapseID, selected_for_report 7 | } 8 | PARAMETER { 9 | g = 1 (nanosiemens) 10 | selected_for_report = 0 11 | } 12 | ASSIGNED { 13 | v (millivolt) 14 | vgap (millivolt) 15 | i (nanoamp) 16 | synapseID 17 | } 18 | BREAKPOINT { i = (v - vgap)*(g*1e-3) } 19 | -------------------------------------------------------------------------------- /examples/mechanisms/gap.mod: -------------------------------------------------------------------------------- 1 | NEURON { 2 | POINT_PROCESS Gap 3 | RANGE vgap 4 | RANGE g, i 5 | NONSPECIFIC_CURRENT i 6 | RANGE synapseID, selected_for_report 7 | } 8 | PARAMETER { 9 | g = 1 (nanosiemens) 10 | selected_for_report = 0 11 | } 12 | ASSIGNED { 13 | v (millivolt) 14 | vgap (millivolt) 15 | i (nanoamp) 16 | synapseID 17 | } 18 | BREAKPOINT { i = (v - vgap)*(g*1e-3) } 19 | -------------------------------------------------------------------------------- /bluecellulab/cell/recording.py: -------------------------------------------------------------------------------- 1 | """Neuron recordings related functions.""" 2 | from __future__ import annotations 3 | from bluecellulab.type_aliases import NeuronSection 4 | 5 | 6 | def section_to_voltage_recording_str(section: NeuronSection, segment=0.5) -> str: 7 | """Converts a section and segment to voltage recording string.""" 8 | return f"neuron.h.{section.name()}({segment})._ref_v" 9 | -------------------------------------------------------------------------------- /bluecellulab/circuit/__init__.py: -------------------------------------------------------------------------------- 1 | """Module responsible of circuit access.""" 2 | 3 | from .synapse_properties import SynapseProperty 4 | from .node_id import CellId 5 | from .circuit_access import BluepyCircuitAccess, CircuitAccess, SonataCircuitAccess, EmodelProperties 6 | from .simulation_access import BluepySimulationAccess, SimulationAccess, SonataSimulationAccess 7 | from .validate import SimulationValidator 8 | -------------------------------------------------------------------------------- /tests/LICENSE: -------------------------------------------------------------------------------- 1 | BlueCellulab is licensed under the Apache License, unless noted otherwise, 2 | e.g., for external dependencies such as MOD or morphology files. 3 | For MOD files for which the original source is available on ModelDB, 4 | any specific licenses on mentioned on ModelDB, or the generic License of ModelDB apply. 5 | The licenses of the morphology files used in this repository are available on: https://zenodo.org/record/5909613 6 | -------------------------------------------------------------------------------- /examples/LICENSE: -------------------------------------------------------------------------------- 1 | BlueCellulab is licensed under the Apache License, unless noted otherwise, 2 | e.g., for external dependencies such as MOD or morphology files. 3 | For MOD files for which the original source is available on ModelDB, 4 | any specific licenses on mentioned on ModelDB, or the generic License of ModelDB apply. 5 | The licenses of the morphology files used in this repository are available on: https://zenodo.org/record/5909613 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /modlib 2 | **/x86_64 3 | /.tox 4 | *.pyc 5 | *.egg-info 6 | .eggs 7 | /dist 8 | /jekylltest 9 | /doc/build 10 | /docs/build 11 | /docs/source/_autosummary 12 | .debug 13 | .profiling 14 | .vscode 15 | /.python-version 16 | coverage.xml 17 | .coverage 18 | .coverage* 19 | *_t=0.0.nrndat 20 | *.DS_STORE 21 | .tox-info.json 22 | nrnivmodl.log 23 | .mypy_cache 24 | .ruff_cache 25 | .pytest_cache 26 | *.btr 27 | *.whl 28 | .ipynb_checkpoints 29 | -------------------------------------------------------------------------------- /examples/1-singlecell/README.md: -------------------------------------------------------------------------------- 1 | ### Provenance for the hoc and morph files 2 | 3 | hoc: BlueCelluLab/tests/examples/circuit_sonata_quick_scx/components/hoc/cADpyr_L2TPC.hoc' 4 | morph: BlueCelluLab/tests/examples/circuit_sonata_quick_scx/components/morphologies/asc/rr110330_C3_idA.asc 5 | emodel_properties (retrieved from the circuit): EmodelProperties(threshold_current=1.1433533430099487, holding_current=1.4146618843078613, AIS_scaler=1.4561502933502197, soma_scaler=1.0) 6 | -------------------------------------------------------------------------------- /.readthedocs.yml: -------------------------------------------------------------------------------- 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 | build: 13 | os: "ubuntu-20.04" 14 | tools: 15 | python: "3.10" 16 | 17 | python: 18 | install: 19 | - method: pip 20 | path: . 21 | - requirements: docs/requirements_docs.txt -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | minversion=4.0.0 3 | skipsdist = True 4 | envlist = lint,py3 5 | 6 | [testenv] 7 | envdir = 8 | py3: {toxworkdir}/py3 9 | deps = 10 | bluecellulab>=1.1.1 11 | allowlist_externals = 12 | make 13 | commands = 14 | make install_deps compile_mod run_tests 15 | 16 | [testenv:lint] 17 | envdir={toxworkdir}/{envname} 18 | deps = 19 | bluecellulab>=1.1.1 20 | allowlist_externals = 21 | make 22 | commands = 23 | make install_deps run_lint 24 | -------------------------------------------------------------------------------- /bluecellulab/cell/ballstick/__init__.py: -------------------------------------------------------------------------------- 1 | """A simple ball and stick model.""" 2 | 3 | import importlib_resources as resources 4 | from bluecellulab.cell import Cell 5 | 6 | 7 | def create_ball_stick() -> Cell: 8 | """Creates a ball and stick model by using package's hoc and asc.""" 9 | hoc = resources.files("bluecellulab") / "cell/ballstick/emodel.hoc" 10 | morphology = resources.files("bluecellulab") / "cell/ballstick/morphology.asc" 11 | return Cell(template_path=hoc, morphology_path=morphology) 12 | -------------------------------------------------------------------------------- /bluecellulab/type_aliases.py: -------------------------------------------------------------------------------- 1 | """Type aliases used within the package.""" 2 | from __future__ import annotations 3 | from typing import Dict 4 | from typing_extensions import TypeAlias 5 | from neuron import h as hoc_type 6 | 7 | HocObjectType: TypeAlias = hoc_type # until NEURON is typed, most NEURON types are this 8 | NeuronRNG: TypeAlias = hoc_type 9 | NeuronVector: TypeAlias = hoc_type 10 | NeuronSection: TypeAlias = hoc_type 11 | TStim: TypeAlias = hoc_type 12 | 13 | SectionMapping = Dict[str, NeuronSection] 14 | -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_bluepy/output/out.dat: -------------------------------------------------------------------------------- 1 | /scatter 2 | 0.100 1 3 | 0.150 3 4 | 0.175 2 5 | 2.275 1 6 | 3.025 2 7 | 3.450 3 8 | 4.350 1 9 | 5.700 2 10 | 6.975 3 11 | 7.700 1 12 | 8.975 2 13 | 11.050 3 14 | 12.525 1 15 | 13.950 2 16 | 15.500 3 17 | 16.800 1 18 | 20.150 2 19 | 20.225 3 20 | 21.400 1 21 | 25.175 3 22 | 26.050 1 23 | 26.100 2 24 | 30.300 3 25 | 30.600 1 26 | 31.725 2 27 | 35.100 1 28 | 35.550 3 29 | 37.125 2 30 | 39.525 1 31 | 40.925 3 32 | 42.450 2 33 | 43.950 1 34 | 46.400 3 35 | 47.750 2 36 | 48.375 1 37 | -------------------------------------------------------------------------------- /tests/mechanisms/TC_Kleak.mod: -------------------------------------------------------------------------------- 1 | TITLE Leak potassium current 2 | : From Amarillo et al., 2014 3 | 4 | NEURON { 5 | SUFFIX TC_Kleak 6 | USEION k READ ek WRITE ik 7 | RANGE gmax, i_rec 8 | } 9 | 10 | UNITS { 11 | (mA) = (milliamp) 12 | (mV) = (millivolt) 13 | (S) = (siemens) 14 | } 15 | 16 | PARAMETER { 17 | gmax = 1.0e-5 (S/cm2) 18 | } 19 | 20 | ASSIGNED { 21 | v (mV) 22 | ek (mV) 23 | ik (mA/cm2) 24 | i_rec 25 | } 26 | 27 | 28 | BREAKPOINT { 29 | ik = gmax*(v - ek) 30 | i_rec = ik 31 | } 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/source/index.rst: -------------------------------------------------------------------------------- 1 | .. bluecellulab documentation master file, created by 2 | sphinx-quickstart on Mon Jun 19 11:35:51 2023. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | 7 | .. include:: ../../README.rst 8 | :end-before: .. substitutions 9 | 10 | 11 | .. toctree:: 12 | :hidden: 13 | :maxdepth: 2 14 | 15 | Home 16 | list_of_stim 17 | api.rst 18 | compiling-mechanisms.rst 19 | changelog 20 | contributing 21 | 22 | .. |banner| image:: /logo/BlueCelluLabBanner.jpg 23 | -------------------------------------------------------------------------------- /tests/examples/legacy_circuitconfig/CircuitConfig: -------------------------------------------------------------------------------- 1 | Run Default 2 | { 3 | 4 | MorphologyPath /dir/l5/release/2012.07.23/morphologies/h5 5 | METypePath ../circuit_twocell_example1/ccells/ 6 | MeshPath /dir/l5/release/2012.07.23/meshes 7 | CircuitPath ../circuit_twocell_example1 8 | nrnPath ../circuit_twocell_example1/ncsFunctionalAllRecipePathways 9 | TargetFile /dir/l5/release/2012.07.23/circuit/SomatosensoryCxS1-v4.lowerCellDensity.r151/O1/merged_circuit/default_user.target 10 | BioName SomatosensoryCxS1-v4.lowerCellDensity.r151 11 | CentralHyperColumn 2 12 | 13 | } 14 | 15 | -------------------------------------------------------------------------------- /docs/source/api.rst: -------------------------------------------------------------------------------- 1 | bluecellulab 2 | ============ 3 | 4 | .. automodule:: bluecellulab 5 | :members: 6 | :show-inheritance: 7 | 8 | 9 | .. rubric:: Modules 10 | 11 | .. autosummary:: 12 | :toctree: _autosummary 13 | :recursive: 14 | 15 | analysis 16 | cell 17 | circuit 18 | connection 19 | dendrogram 20 | exceptions 21 | graph 22 | importer 23 | neuron_interpreter 24 | plotwindow 25 | psection 26 | psegment 27 | rngsettings 28 | simulation 29 | circuit_simulation 30 | stimulus 31 | synapse 32 | tools 33 | utils 34 | type_aliases 35 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_all/BlueConfigWithInvalidSpikeLocation: -------------------------------------------------------------------------------- 1 | Run Default 2 | { 3 | MorphologyPath ../circuit_twocell_example1/morphologies 4 | METypePath ../circuit_twocell_example1/ccells 5 | 6 | CircuitPath ../circuit_twocell_example1 7 | nrnPath ../circuit_twocell_example1/ncsFunctionalAllRecipePathways 8 | 9 | CurrentDir ./ 10 | OutputRoot .//output 11 | TargetFile .//user.target 12 | 13 | CircuitTarget mc2_Layer5 14 | Duration 100 15 | Dt 0.025 16 | 17 | BaseSeed 12345 18 | ExtracellularCalcium 1.25 19 | SpikeLocation NeitherSomaNorAIS 20 | } 21 | -------------------------------------------------------------------------------- /tests/mechanisms/README.md: -------------------------------------------------------------------------------- 1 | Common, neocortex-v5 and neocortex-v6 mod files are merged. Below are the sources. 2 | 3 | Common mods repository: hpc/sim/models/common.git 4 | Common mods git hash: bfe26c3d 5 | 6 | Neocortex mods repository: hpc/sim/models/neocortex.git 7 | Neocortex mods git hash: 7feb8d9 8 | 9 | [Update] 10 | The mechanisms for the Hippocampus are added and any conflicts that arose are addressed by favoring the modifications intended for the neocortex. Please note, these modifications are solely intended for software testing and verification purposes. They are not designed or recommended for conducting scientific simulations. 11 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/circuit_twocell_example1/CircuitConfig: -------------------------------------------------------------------------------- 1 | Run Default 2 | { 3 | 4 | MorphologyPath /bgscratch/bbp/l5/release/2012.07.23/morphologies/h5 5 | METypePath ../circuit_twocell_example1/ccells/ 6 | MeshPath /bgscratch/bbp/l5/release/2012.07.23/meshes 7 | CircuitPath ../circuit_twocell_example1 8 | nrnPath ../circuit_twocell_example1/ncsFunctionalAllRecipePathways 9 | TargetFile /bgscratch/bbp/l5/release/2012.07.23/circuit/SomatosensoryCxS1-v4.lowerCellDensity.r151/O1/merged_circuit/default_user.target 10 | BioName SomatosensoryCxS1-v4.lowerCellDensity.r151 11 | CentralHyperColumn 2 12 | 13 | } 14 | 15 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/pyvenv.cfg: -------------------------------------------------------------------------------- 1 | home = /gpfs/bbp.cscs.ch/ssd/apps/bsd/2022-01-10/stage_externals/install_gcc-11.2.0-skylake/python-3.9.7-yj5alh/bin 2 | implementation = CPython 3 | version_info = 3.9.7.final.0 4 | virtualenv = 20.17.1 5 | include-system-site-packages = false 6 | base-prefix = /gpfs/bbp.cscs.ch/ssd/apps/bsd/2022-01-10/stage_externals/install_gcc-11.2.0-skylake/python-3.9.7-yj5alh 7 | base-exec-prefix = /gpfs/bbp.cscs.ch/ssd/apps/bsd/2022-01-10/stage_externals/install_gcc-11.2.0-skylake/python-3.9.7-yj5alh 8 | base-executable = /gpfs/bbp.cscs.ch/ssd/apps/bsd/2022-01-10/stage_externals/install_gcc-11.2.0-skylake/python-3.9.7-yj5alh/bin/python3.9 9 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "github-actions" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "monthly" 12 | commit-message: 13 | # Prefix all commit messages with "CI(dependabot): " 14 | prefix: "CI(dependabot): " 15 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = source 9 | BUILDDIR = build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_forwardskip/BlueConfig: -------------------------------------------------------------------------------- 1 | Run Default 2 | { 3 | CircuitPath ../circuit_twocell_example1 4 | nrnPath ../circuit_twocell_example1/ncsFunctionalAllRecipePathways 5 | MorphologyPath ../circuit_twocell_example1/morphologies 6 | METypePath ../circuit_twocell_example1/ccells 7 | 8 | ForwardSkip 50 9 | RNGMode Random123 10 | Dt 0.025 11 | Duration 10.0 12 | 13 | CurrentDir ./ 14 | OutputRoot .//output 15 | TargetFile .//user.target 16 | 17 | } 18 | 19 | Report soma 20 | { 21 | Target S1HL 22 | Type compartment 23 | ReportOn v 24 | Unit mV 25 | Format Bin 26 | Dt 0.1 27 | StartTime 0.0 28 | EndTime 10.0 29 | } 30 | -------------------------------------------------------------------------------- /tests/mechanisms/TC_Naleak.mod: -------------------------------------------------------------------------------- 1 | TITLE Leak potassium current 2 | : From Amarillo et al., 2014 3 | 4 | NEURON { 5 | SUFFIX TC_Naleak 6 | :USEION na READ ena WRITE ina 7 | USEION na WRITE ina :Read ena from the modfile 8 | RANGE g, i_rec, ena 9 | } 10 | 11 | :CONSTANT { 12 | :Q10 = 3 (1) : To check, recordings at room temperature 13 | :} 14 | 15 | UNITS { 16 | (mA) = (milliamp) 17 | :(uA) = (microamp) 18 | (mV) = (millivolt) 19 | (S) = (siemens) 20 | } 21 | 22 | PARAMETER { 23 | ena = 0 (mV) 24 | g = 3.0e-6 (S/cm2) <0,1e9> 25 | } 26 | 27 | ASSIGNED { 28 | v (mV) 29 | ina (mA/cm2) 30 | :qt (1) 31 | i_rec 32 | } 33 | 34 | 35 | BREAKPOINT { 36 | ina = g*(v - ena) 37 | i_rec = ina 38 | } 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_all/BlueConfigWithInvalidModOverride: -------------------------------------------------------------------------------- 1 | Run Default 2 | { 3 | MorphologyPath ../circuit_twocell_example1/morphologies 4 | METypePath ../circuit_twocell_example1/ccells 5 | 6 | CircuitPath ../circuit_twocell_example1 7 | nrnPath ../circuit_twocell_example1/ncsFunctionalAllRecipePathways 8 | 9 | CurrentDir ./ 10 | OutputRoot .//output 11 | TargetFile .//user.target 12 | 13 | CircuitTarget mc2_Layer5 14 | Duration 100 15 | Dt 0.025 16 | } 17 | 18 | Connection plasticity 19 | { 20 | Source Excitatory 21 | Destination Excitatory 22 | ModOverride NonExistingModNotEvenGlusynapse 23 | Weight 1.0 24 | SpontMinis 0.0 25 | SynapseConfigure %s.theta_d_GB = -1 %s.theta_p_GB = -1 %s.verbose = 1 26 | } 27 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_all/BlueConfigWithConditions: -------------------------------------------------------------------------------- 1 | Run Default 2 | { 3 | MorphologyPath ../circuit_twocell_example1/morphologies 4 | METypePath ../circuit_twocell_example1/ccells 5 | 6 | CircuitPath ../circuit_twocell_example1 7 | nrnPath ../circuit_twocell_example1/ncsFunctionalAllRecipePathways 8 | 9 | CurrentDir ./ 10 | OutputRoot .//output 11 | TargetFile .//user.target 12 | 13 | CircuitTarget mc2_Layer5 14 | Duration 100 15 | Dt 0.025 16 | 17 | BaseSeed 12345 18 | ExtracellularCalcium 1.25 19 | } 20 | 21 | # Extra settings for synapses 22 | Conditions synapses 23 | { 24 | randomize_Gaba_risetime False 25 | SYNAPSES__init_depleted 1 26 | SYNAPSES__minis_single_vesicle 1 27 | cao_CR_GluSynapse 1.25 28 | } 29 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_all/BlueConfigWithInvalidConnectionContents: -------------------------------------------------------------------------------- 1 | Run Default 2 | { 3 | 4 | Prefix /bgscratch/bbp/release/02.04.12 5 | MorphologyPath ../circuit_twocell_example1/morphologies 6 | METypePath ../circuit_twocell_example1/ccells 7 | 8 | CircuitPath ../circuit_twocell_example1 9 | nrnPath ../circuit_twocell_example1/ncsFunctionalAllRecipePathways 10 | 11 | CurrentDir ./ 12 | OutputRoot .//output 13 | TargetFile .//user.target 14 | 15 | CircuitTarget mc2_Layer5 16 | Duration 100 17 | Dt 0.025 18 | 19 | BaseSeed 12345 20 | } 21 | 22 | 23 | Connection changeUse 24 | { 25 | Source Excitatory 26 | Destination Excitatory 27 | Weight 1.0 28 | SynapseConfigure %s.Dep = 1.0 29 | SpontMinis 100.0 30 | UnsupportedDelay 5000 31 | } 32 | -------------------------------------------------------------------------------- /tests/examples/circuit_sonata_quick_scx_multi_circuit/simulation_sonata.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "manifest": { 4 | "$OUTPUT_DIR": "./reporting", 5 | "$INPUT_DIR": "./" 6 | }, 7 | "run": { 8 | "tstart": 0, 9 | "tstop": 1.0, 10 | "dt": 0.1, 11 | "random_seed": 123 12 | }, 13 | "output": { 14 | "output_dir": "$OUTPUT_DIR", 15 | "spikes_file": "spikes.h5", 16 | "spikes_sort_order": "by_time" 17 | }, 18 | "reports": { 19 | "soma_report": { 20 | "cells": "node_set1", 21 | "variable_name": "v", 22 | "sections": "soma" 23 | }, 24 | "compartment_report": { 25 | "cells": "node_set2", 26 | "variable_name": "v", 27 | "sections": "all" 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /.compile_mod.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright 2023-2024 Blue Brain Project / EPFL 4 | 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -e 18 | 19 | INSTALL_DIR=$1 20 | MOD_DIR=$2 21 | 22 | cd ${INSTALL_DIR} 23 | 24 | echo "Building mod files" 25 | rm -rf x86_64 26 | nrnivmodl ${MOD_DIR} >nrnivmodl.log 2>&1 27 | -------------------------------------------------------------------------------- /examples/2-sonata-network/circuit_sonata_quick_scx_multi_circuit/simulation_sonata.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "manifest": { 4 | "$OUTPUT_DIR": "./reporting", 5 | "$INPUT_DIR": "./" 6 | }, 7 | "run": { 8 | "tstart": 0, 9 | "tstop": 1.0, 10 | "dt": 0.1, 11 | "random_seed": 123 12 | }, 13 | "output": { 14 | "output_dir": "$OUTPUT_DIR", 15 | "spikes_file": "spikes.h5", 16 | "spikes_sort_order": "by_time" 17 | }, 18 | "reports": { 19 | "soma_report": { 20 | "cells": "node_set1", 21 | "variable_name": "v", 22 | "sections": "soma" 23 | }, 24 | "compartment_report": { 25 | "cells": "node_set2", 26 | "variable_name": "v", 27 | "sections": "all" 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /tests/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/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 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/.compile_mod.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright 2024 Blue Brain Project / EPFL 4 | 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -e 18 | 19 | INSTALL_DIR=$1 20 | MOD_DIR=$2 21 | 22 | cd ${INSTALL_DIR} 23 | 24 | echo "Building mod files" 25 | rm -rf x86_64 26 | nrnivmodl ${MOD_DIR} >nrnivmodl.log 2>&1 27 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_all/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2024 Blue Brain Project / EPFL 4 | 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | BGLIB_DIR=~/private/src/bbp/lib 18 | 19 | $BGLIB_DIR/x86_64/special $BGLIB_DIR/hoclib/init.hoc -NFRAME 1000 -mpi 20 | cd output 21 | cp out.dat.original out.dat 22 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_all_mvr/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2024 Blue Brain Project / EPFL 4 | 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | BGLIB_DIR=~/private/src/bbp/lib 18 | 19 | $BGLIB_DIR/x86_64/special $BGLIB_DIR/hoclib/init.hoc -NFRAME 1000 -mpi 20 | cd output 21 | cp out.dat.original out.dat 22 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_empty/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2024 Blue Brain Project / EPFL 4 | 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | BGLIB_DIR=~/private/src/bbp/lib 18 | 19 | $BGLIB_DIR/x86_64/special $BGLIB_DIR/hoclib/init.hoc -NFRAME 1000 -mpi 20 | cd output 21 | cp out.dat.original out.dat 22 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_noisestim/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2024 Blue Brain Project / EPFL 4 | 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | BGLIB_DIR=~/private/src/bbp/lib 18 | 19 | $BGLIB_DIR/x86_64/special $BGLIB_DIR/hoclib/init.hoc -NFRAME 1000 -mpi 20 | cd output 21 | cp out.dat.original out.dat 22 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_pulsestim/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2024 Blue Brain Project / EPFL 4 | 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | BGLIB_DIR=~/private/src/bbp/lib 18 | 19 | $BGLIB_DIR/x86_64/special $BGLIB_DIR/hoclib/init.hoc -NFRAME 1000 -mpi 20 | cd output 21 | cp out.dat.original out.dat 22 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_replay/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2024 Blue Brain Project / EPFL 4 | 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | BGLIB_DIR=~/private/src/bbp/lib 18 | 19 | $BGLIB_DIR/x86_64/special $BGLIB_DIR/hoclib/init.hoc -NFRAME 1000 -mpi 20 | cd output 21 | cp out.dat.original out.dat 22 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_minis_replay/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2024 Blue Brain Project / EPFL 4 | 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | BGLIB_DIR=~/private/src/bbp/lib 18 | 19 | $BGLIB_DIR/x86_64/special $BGLIB_DIR/hoclib/init.hoc -NFRAME 1000 -mpi 20 | cd output 21 | cp out.dat.original out.dat 22 | -------------------------------------------------------------------------------- /tests/helpers/os_utils.py: -------------------------------------------------------------------------------- 1 | # Copyright 2023-2024 Blue Brain Project / EPFL 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | from contextlib import contextmanager 15 | import os 16 | 17 | 18 | @contextmanager 19 | def cwd(path): 20 | """Cwd function that can be used in a context manager.""" 21 | old_dir = os.getcwd() 22 | os.chdir(path) 23 | yield 24 | os.chdir(old_dir) 25 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | include: 2 | - project: cells/ci 3 | file: /ci/lib/common.yml 4 | 5 | workflow: 6 | # run for the default branch and all types of merge request pipelines, but not for tags 7 | rules: 8 | - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH 9 | - if: $CI_EXTERNAL_PULL_REQUEST_IID 10 | 11 | tests: 12 | stage: test 13 | tags: 14 | - bb5_map 15 | before_script: 16 | - !reference [.define-functions] 17 | - !reference [.bb5, clean-env] 18 | - !reference [.bb5, load-python-39] 19 | - !reference [.bb5, load-python-310] 20 | - !reference [.bb5, load-extra-modules] 21 | - !reference [.run-pre-build-command] 22 | - !reference [.setup-venv] 23 | - !reference [.gitlab-access] 24 | script: 25 | - pip install . # Install the package itself 26 | - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@bbpgitlab.epfl.ch/cells/bluecellulab-bb5-tests.git 27 | - cd bluecellulab-bb5-tests 28 | - make 29 | -------------------------------------------------------------------------------- /examples/2-sonata-network/sim_quick_scx_sonata_multicircuit/simulation_config_noinput.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest": { 3 | "$OUTPUT_DIR": "." 4 | }, 5 | "run": { 6 | "tstop": 50.0, 7 | "dt": 0.025, 8 | "random_seed": 1 9 | }, 10 | "conditions": { 11 | "v_init": -65 12 | }, 13 | "target_simulator": "NEURON", 14 | "network": "circuit_sonata.json", 15 | "node_set": "Mosaic_A", 16 | "output": { 17 | "output_dir": "$OUTPUT_DIR/output_sonata_noinput", 18 | "spikes_file": "out.h5", 19 | "spikes_sort_order": "by_time" 20 | }, 21 | "inputs": {}, 22 | "reports": { 23 | "soma": { 24 | "cells": "Mosaic_A", 25 | "variable_name": "v", 26 | "type": "compartment", 27 | "dt": 1.0, 28 | "start_time": 0.0, 29 | "end_time": 20.0, 30 | "sections": "soma", 31 | "compartments": "center" 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=source 11 | set BUILDDIR=build 12 | 13 | %SPHINXBUILD% >NUL 2>NUL 14 | if errorlevel 9009 ( 15 | echo. 16 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 17 | echo.installed, then set the SPHINXBUILD environment variable to point 18 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 19 | echo.may add the Sphinx directory to PATH. 20 | echo. 21 | echo.If you don't have Sphinx installed, grab it from 22 | echo.https://www.sphinx-doc.org/ 23 | exit /b 1 24 | ) 25 | 26 | if "%1" == "" goto help 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /tests/test_simulation/test_parallel.py: -------------------------------------------------------------------------------- 1 | # Copyright 2023-2024 Blue Brain Project / EPFL 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | from bluecellulab.simulation.parallel import IsolatedProcess 15 | 16 | 17 | def test_isolated_process(): 18 | """Test to ensure isolated process keeps its properties.""" 19 | runner = IsolatedProcess() 20 | assert runner._processes == 1 21 | assert runner._maxtasksperchild == 1 22 | -------------------------------------------------------------------------------- /tests/test_synapse/test-synapse-series.json: -------------------------------------------------------------------------------- 1 | { 2 | "PRE_GID": 2772, 3 | "AXONAL_DELAY": 1.875, 4 | "POST_SECTION_ID": 169, 5 | "POST_SEGMENT_ID": 13, 6 | "POST_SEGMENT_OFFSET": 1.2331762313842773, 7 | "G_SYNX": 0.31100621819496155, 8 | "U_SYN": 0.4691869616508484, 9 | "D_SYN": 676.0911254882812, 10 | "F_SYN": 20.528654098510742, 11 | "DTC": 1.7678316831588745, 12 | "TYPE": 114, 13 | "NRRP": 1, 14 | "U_HILL_COEFFICIENT": 2.7899999618530273, 15 | "CONDUCTANCE_RATIO": 0.699999988079071, 16 | "source_population_name": "S1nonbarrel_neurons", 17 | "source_popid": 2969, 18 | "target_popid": 2969, 19 | "volume_CR": 0.030861396342515945, 20 | "rho0_GB": 0.0, 21 | "Use_d_TM": 0.4691869616508484, 22 | "Use_p_TM": 0.8595461249351501, 23 | "gmax_d_AMPA": 0.31100621819496155, 24 | "gmax_p_AMPA": 0.6220124363899231, 25 | "theta_d": 0.4981519281864166, 26 | "theta_p": 0.5749450922012329 27 | } -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_all/BlueConfigWithInvalidConnectionEntries: -------------------------------------------------------------------------------- 1 | Run Default 2 | { 3 | Prefix /bgscratch/bbp/release/02.04.12 4 | MorphologyPath ../circuit_twocell_example1/morphologies 5 | METypePath ../circuit_twocell_example1/ccells 6 | 7 | CircuitPath ../circuit_twocell_example1 8 | nrnPath ../circuit_twocell_example1/ncsFunctionalAllRecipePathways 9 | 10 | CurrentDir ./ 11 | OutputRoot .//output 12 | TargetFile .//user.target 13 | 14 | CircuitTarget mc2_Layer5 15 | Duration 100 16 | Dt 0.025 17 | 18 | BaseSeed 12345 19 | } 20 | 21 | Connection changeUse 22 | { 23 | Source Excitatory 24 | Destination UndefinedTarget 25 | Weight 1.0 26 | SynapseConfigure %s.Dep = 1.0 27 | SpontMinis 100.0 28 | } 29 | 30 | Connection scheme_minus2 31 | { 32 | Source Excitatory 33 | Destination Excitatory 34 | Weight 1.0 35 | SynapseConfigure %s.NMDA_ratio = 0.4 36 | } 37 | -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_sonata_multicircuit/simulation_config_noinput.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest": { 3 | "$CIRCUIT_DIR": "usecase3", 4 | "$OUTPUT_DIR": "." 5 | }, 6 | "run": { 7 | "tstop": 50.0, 8 | "dt": 0.025, 9 | "random_seed": 1 10 | }, 11 | "conditions": { 12 | "v_init": -65 13 | }, 14 | "target_simulator": "NEURON", 15 | "network": "circuit_sonata.json", 16 | "node_set": "Mosaic_A", 17 | "output": { 18 | "output_dir": "$OUTPUT_DIR/output_sonata_noinput", 19 | "spikes_file": "out.h5", 20 | "spikes_sort_order": "by_time" 21 | }, 22 | "inputs": {}, 23 | "reports": { 24 | "soma": { 25 | "cells": "Mosaic_A", 26 | "variable_name": "v", 27 | "type": "compartment", 28 | "dt": 1.0, 29 | "start_time": 0.0, 30 | "end_time": 20.0, 31 | "sections": "soma", 32 | "compartments": "center" 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/Makefile: -------------------------------------------------------------------------------- 1 | # Variables 2 | PIP_INDEX_URL := https://pypi.python.org/simple 3 | NEURON_MODULE_OPTIONS := '-nogui' 4 | TESTS_DIR := tests 5 | MECHANISMS_DIR := ./../mechanisms/ 6 | PYTEST_OPTS := --numprocesses=auto --timeout=600 -vsx --forked 7 | 8 | # Default rule (similar to 'testenv' in tox) 9 | default: install_deps compile_mod run_lint run_tests 10 | 11 | # Rule for installing dependencies (similar to 'deps' in tox) 12 | install_deps: 13 | python -m pip install --index-url $(PIP_INDEX_URL) -r test_requirements.txt 14 | 15 | # Rule for compiling mod (similar to the first 'commands' in tox) 16 | compile_mod: 17 | chmod +x ./.compile_mod.sh 18 | ./.compile_mod.sh . $(MECHANISMS_DIR) 19 | 20 | # Rule for running tests (similar to the second 'commands' in tox) 21 | run_tests: 22 | NEURON_MODULE_OPTIONS=$(NEURON_MODULE_OPTIONS) pytest $(TESTS_DIR) $(PYTEST_OPTS) 23 | 24 | run_lint: 25 | ruff check $(TESTS_DIR) 26 | mypy $(TESTS_DIR) --ignore-missing-imports 27 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_empty/BlueConfig: -------------------------------------------------------------------------------- 1 | Run Default 2 | { 3 | Date 22:11:12 4 | Time 14:27:09 5 | svnPath https://bbpteam.epfl.ch/svn/bluebrain 6 | Version 1094 7 | Prefix /bgscratch/bbp/release/02.04.12 8 | MorphologyPath ../circuit_twocell_example1/morphologies 9 | METypePath ../circuit_twocell_example1/ccells 10 | 11 | CircuitPath ../circuit_twocell_example1 12 | nrnPath ../circuit_twocell_example1/ncsFunctionalAllRecipePathways 13 | 14 | CurrentDir ./ 15 | OutputRoot .//output 16 | TargetFile .//user.target 17 | 18 | CircuitTarget mc2_Layer5 19 | Duration 100 20 | Dt 0.025 21 | 22 | BaseSeed 12345 23 | } 24 | 25 | Report soma 26 | { 27 | Target Mosaic 28 | Type compartment 29 | ReportOn v 30 | Unit mV 31 | Format Bin 32 | Dt 0.1 33 | StartTime 0 34 | EndTime 20000 35 | } 36 | -------------------------------------------------------------------------------- /bluecellulab/__init__.py: -------------------------------------------------------------------------------- 1 | """Package for performing single cell or network simulations and 2 | experiments.""" 3 | 4 | try: 5 | import bluepy 6 | BLUEPY_AVAILABLE = True 7 | except ImportError: 8 | BLUEPY_AVAILABLE = False 9 | 10 | from bluecellulab.importer import import_hoc 11 | from .verbosity import * 12 | from .cell import Cell, create_ball_stick # NOQA 13 | from .circuit import EmodelProperties 14 | from .connection import Connection # NOQA 15 | from .plotwindow import PlotWindow # NOQA 16 | from .dendrogram import Dendrogram # NOQA 17 | from .psection import PSection # NOQA 18 | from .psegment import PSegment # NOQA 19 | from .simulation import Simulation # NOQA 20 | from .rngsettings import RNGSettings # NOQA 21 | from .circuit_simulation import CircuitSimulation # NOQA 22 | import neuron 23 | 24 | from .simulation.neuron_globals import NeuronGlobals 25 | 26 | logger.debug("Loading the hoc files.") 27 | import_hoc(neuron) 28 | _ = NeuronGlobals.get_instance() # initiate the singleton 29 | -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_sonata/simulation_config_noinput.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest": { 3 | "$CIRCUIT_DIR": "usecase3", 4 | "$OUTPUT_DIR": "." 5 | }, 6 | "run": { 7 | "tstop": 50.0, 8 | "dt": 0.025, 9 | "random_seed": 1 10 | }, 11 | "conditions": { 12 | "v_init": -65 13 | }, 14 | "target_simulator": "NEURON", 15 | "network": "circuit_sonata.json", 16 | "node_set": "Mosaic_A", 17 | "output": { 18 | "output_dir": "$OUTPUT_DIR/output_sonata_noinput", 19 | "spikes_file": "out.h5", 20 | "spikes_sort_order": "by_time" 21 | }, 22 | "inputs": {}, 23 | "reports": { 24 | "soma": { 25 | "cells": "Mosaic_A", 26 | "variable_name": "v", 27 | "type": "compartment", 28 | "dt": 1.0, 29 | "start_time": 0.0, 30 | "end_time": 10.0, 31 | "sections": "soma", 32 | "compartments": "center" 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /tests/mechanisms/TC_cadecay.mod: -------------------------------------------------------------------------------- 1 | : From Hay et al, 2011 model, 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), see CaDynamics_E2.mod ctx 21 | taur = 5 (ms) : rate of calcium removal 22 | cainf = 5e-5 (mM) : Value from Amarillo et al., 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 : EI: from CaDynamics_E2.mod ctxay 46 | cai_rec = cai 47 | 48 | } 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /tests/test_cell/test_recording.py: -------------------------------------------------------------------------------- 1 | # Copyright 2023-2024 Blue Brain Project / EPFL 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """Tests for the recording module.""" 15 | from neuron import h 16 | from bluecellulab.cell.recording import section_to_voltage_recording_str 17 | 18 | 19 | def test_section_to_voltage_recording_str(): 20 | section = h.Section(name='test_section') 21 | recording_str = section_to_voltage_recording_str(section, 0.5) 22 | expected_str = "neuron.h.test_section(0.5)._ref_v" 23 | assert recording_str == expected_str 24 | -------------------------------------------------------------------------------- /tests/examples/circuit_sonata_quick_scx/circuit_sonata.json: -------------------------------------------------------------------------------- 1 | { 2 | "node_sets_file": "./node_sets.json", 3 | "version": 2, 4 | "networks": { 5 | "nodes": [ 6 | { 7 | "nodes_file": "nodes_A.h5", 8 | "populations": { 9 | "NodeA": { 10 | "type": "biophysical", 11 | "morphologies_dir": "./components/morphologies/swc", 12 | "biophysical_neuron_models_dir": "./components/hoc", 13 | "alternate_morphologies": { 14 | "neurolucida-asc": "./components/morphologies/asc" 15 | } 16 | } 17 | } 18 | } 19 | ], 20 | "edges": [ 21 | { 22 | "edges_file": "local_edges_A.h5", 23 | "populations": { 24 | "NodeA__NodeA__chemical": { 25 | "type": "chemical" 26 | } 27 | } 28 | } 29 | ] 30 | } 31 | } -------------------------------------------------------------------------------- /tests/mechanisms/SKv3_1.mod: -------------------------------------------------------------------------------- 1 | :Comment : 2 | :Reference : : Rettig et.al (1992) EMBO J 11, no. 7: 2473-86. 3 | : Methods: Grupe et al. (1990) EMBO J 9, 1749-1756. 4 | : LJP: OK, no LJP, "Patch pipetes were filed with the normal bathing solution in al experiments."" 5 | 6 | NEURON { 7 | SUFFIX SKv3_1 8 | USEION k READ ek WRITE ik 9 | RANGE gSKv3_1bar, gSKv3_1, ik 10 | } 11 | 12 | UNITS { 13 | (S) = (siemens) 14 | (mV) = (millivolt) 15 | (mA) = (milliamp) 16 | } 17 | 18 | PARAMETER { 19 | gSKv3_1bar = 0.00001 (S/cm2) 20 | } 21 | 22 | ASSIGNED { 23 | v (mV) 24 | ek (mV) 25 | ik (mA/cm2) 26 | gSKv3_1 (S/cm2) 27 | mInf 28 | mTau 29 | } 30 | 31 | STATE { 32 | m 33 | } 34 | 35 | BREAKPOINT { 36 | SOLVE states METHOD cnexp 37 | gSKv3_1 = gSKv3_1bar*m 38 | ik = gSKv3_1*(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 | UNITSOFF 53 | mInf = 1/(1+exp(((v -(18.700))/(-9.700)))) 54 | mTau = 0.2*20.000/(1+exp(((v -(-46.560))/(-44.140)))) 55 | UNITSON 56 | } 57 | -------------------------------------------------------------------------------- /examples/mechanisms/SKv3_1.mod: -------------------------------------------------------------------------------- 1 | :Comment : 2 | :Reference : : Rettig et.al (1992) EMBO J 11, no. 7: 2473-86. 3 | : Methods: Grupe et al. (1990) EMBO J 9, 1749-1756. 4 | : LJP: OK, no LJP, "Patch pipetes were filed with the normal bathing solution in al experiments."" 5 | 6 | NEURON { 7 | SUFFIX SKv3_1 8 | USEION k READ ek WRITE ik 9 | RANGE gSKv3_1bar, gSKv3_1, ik 10 | } 11 | 12 | UNITS { 13 | (S) = (siemens) 14 | (mV) = (millivolt) 15 | (mA) = (milliamp) 16 | } 17 | 18 | PARAMETER { 19 | gSKv3_1bar = 0.00001 (S/cm2) 20 | } 21 | 22 | ASSIGNED { 23 | v (mV) 24 | ek (mV) 25 | ik (mA/cm2) 26 | gSKv3_1 (S/cm2) 27 | mInf 28 | mTau 29 | } 30 | 31 | STATE { 32 | m 33 | } 34 | 35 | BREAKPOINT { 36 | SOLVE states METHOD cnexp 37 | gSKv3_1 = gSKv3_1bar*m 38 | ik = gSKv3_1*(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 | UNITSOFF 53 | mInf = 1/(1+exp(((v -(18.700))/(-9.700)))) 54 | mTau = 0.2*20.000/(1+exp(((v -(-46.560))/(-44.140)))) 55 | UNITSON 56 | } 57 | -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_sonata/simulation_config_hypamp.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest": { 3 | "$CIRCUIT_DIR": "usecase3", 4 | "$OUTPUT_DIR": "." 5 | }, 6 | "run": { 7 | "tstop": 50.0, 8 | "dt": 0.025, 9 | "random_seed": 1 10 | }, 11 | "conditions": { 12 | "v_init": -65 13 | }, 14 | "target_simulator": "NEURON", 15 | "network": "circuit_sonata.json", 16 | "node_set": "Mosaic_A", 17 | "output": { 18 | "output_dir": "$OUTPUT_DIR/output_sonata_hypamp", 19 | "spikes_file": "out.h5", 20 | "spikes_sort_order": "by_time" 21 | }, 22 | "inputs": { 23 | "hypamp_mosaic": { 24 | "module": "hyperpolarizing", 25 | "input_type": "current_clamp", 26 | "delay": 0.0, 27 | "duration": 4000.0, 28 | "node_set": "Mosaic_A" 29 | } 30 | }, 31 | "reports": { 32 | "soma": { 33 | "cells": "Mosaic_A", 34 | "variable_name": "v", 35 | "type": "compartment", 36 | "dt": 1.0, 37 | "start_time": 0.0, 38 | "end_time": 10.0, 39 | "sections": "soma", 40 | "compartments": "center" 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /CONTRIBUTING.rst: -------------------------------------------------------------------------------- 1 | Contributing to BlueCelluLab 2 | ============================ 3 | 4 | Thank you for taking the time to contribute! 5 | 6 | Reporting Bugs and Suggesting Enhancements 7 | ------------------------------------------ 8 | 9 | 1. Search existing `issues `_. 10 | 2. Open a new issue with a clear title and detailed description. 11 | 3. Include steps to reproduce, expected and actual behavior for bugs, or the current and expected behavior for enhancements. 12 | 4. Attach any relevant screenshots or files. 13 | 5. If applicable specify the versions of BlueCelluLab, Python and any relevant dependencies. 14 | 15 | Pull Requests 16 | ------------- 17 | 18 | 1. Fork the repository and create a new branch. 19 | 2. Make your changes. 20 | 3. Run `tox -e lint` to check the code format. 21 | 4. Run the tests with `tox -e py3`. 22 | 5. Add unit tests for the new code. 23 | 6. If applicable add type hints and docstrings. 24 | 7. If applicable update the documentation. 25 | 8. Submit a pull request with a clear description. 26 | 27 | Thank you for contributing to BlueCelluLab! 28 | -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_sonata_multicircuit/simulation_config_hypamp.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest": { 3 | "$CIRCUIT_DIR": "usecase3", 4 | "$OUTPUT_DIR": "." 5 | }, 6 | "run": { 7 | "tstop": 50.0, 8 | "dt": 0.025, 9 | "random_seed": 1 10 | }, 11 | "conditions": { 12 | "v_init": -65 13 | }, 14 | "target_simulator": "NEURON", 15 | "network": "circuit_sonata.json", 16 | "node_set": "Mosaic_A", 17 | "output": { 18 | "output_dir": "$OUTPUT_DIR/output_sonata_hypamp", 19 | "spikes_file": "out.h5", 20 | "spikes_sort_order": "by_time" 21 | }, 22 | "inputs": { 23 | "hypamp_mosaic": { 24 | "module": "hyperpolarizing", 25 | "input_type": "current_clamp", 26 | "delay": 0.0, 27 | "duration": 4000.0, 28 | "node_set": "Mosaic_A" 29 | } 30 | }, 31 | "reports": { 32 | "soma": { 33 | "cells": "Mosaic_A", 34 | "variable_name": "v", 35 | "type": "compartment", 36 | "dt": 1.0, 37 | "start_time": 0.0, 38 | "end_time": 20.0, 39 | "sections": "soma", 40 | "compartments": "center" 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /examples/2-sonata-network/sim_quick_scx_sonata_multicircuit/simulation_config_hypamp.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest": { 3 | "$OUTPUT_DIR": "." 4 | }, 5 | "run": { 6 | "tstart": 1000.0, 7 | "tstop":1275.0, 8 | "dt": 0.025, 9 | "random_seed": 1 10 | }, 11 | "conditions": { 12 | "v_init": -65 13 | }, 14 | "target_simulator": "NEURON", 15 | "network": "circuit_sonata.json", 16 | "node_set": "Mosaic_A", 17 | "output": { 18 | "output_dir": "$OUTPUT_DIR/output_sonata_hypamp", 19 | "spikes_file": "out.h5", 20 | "spikes_sort_order": "by_time" 21 | }, 22 | "inputs": { 23 | "hypamp_mosaic": { 24 | "module": "hyperpolarizing", 25 | "input_type": "current_clamp", 26 | "delay": 1000.0, 27 | "duration": 250.0, 28 | "node_set": "Mosaic_A" 29 | } 30 | }, 31 | "reports": { 32 | "soma": { 33 | "cells": "Mosaic_A", 34 | "variable_name": "v", 35 | "type": "compartment", 36 | "dt": 1.0, 37 | "start_time": 1000.0, 38 | "end_time": 1275.0, 39 | "sections": "soma", 40 | "compartments": "center" 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /tests/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/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/mechanisms/Ih.mod: -------------------------------------------------------------------------------- 1 | :Comment : 2 | :Reference : : Kole,Hallermann,and Stuart, J. Neurosci. 2006 3 | : LJP: OK, "Somatic whole- cell voltage was corrected for the 14 mV difference" 4 | 5 | NEURON { 6 | SUFFIX Ih 7 | NONSPECIFIC_CURRENT ihcn 8 | RANGE gIhbar, gIh, ihcn 9 | } 10 | 11 | UNITS { 12 | (S) = (siemens) 13 | (mV) = (millivolt) 14 | (mA) = (milliamp) 15 | } 16 | 17 | PARAMETER { 18 | gIhbar = 0.00001 (S/cm2) 19 | ehcn = -45.0 (mV) 20 | } 21 | 22 | ASSIGNED { 23 | v (mV) 24 | ihcn (mA/cm2) 25 | gIh (S/cm2) 26 | mInf 27 | mTau 28 | mAlpha 29 | mBeta 30 | } 31 | 32 | STATE { 33 | m 34 | } 35 | 36 | BREAKPOINT { 37 | SOLVE states METHOD cnexp 38 | gIh = gIhbar*m 39 | ihcn = gIh*(v-ehcn) 40 | } 41 | 42 | DERIVATIVE states { 43 | rates() 44 | m' = (mInf-m)/mTau 45 | } 46 | 47 | INITIAL{ 48 | rates() 49 | m = mInf 50 | } 51 | 52 | PROCEDURE rates(){ 53 | UNITSOFF 54 | if(v == -154.9){ 55 | v = v + 0.0001 56 | } 57 | mAlpha = 0.001*6.43*(v+154.9)/(exp((v+154.9)/11.9)-1) 58 | mBeta = 0.001*193*exp(v/33.1) 59 | mInf = mAlpha/(mAlpha + mBeta) 60 | mTau = 1/(mAlpha + mBeta) 61 | UNITSON 62 | } 63 | -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_bluepy/BlueConfig: -------------------------------------------------------------------------------- 1 | Run Default 2 | { 3 | CircuitPath ../circuit_sonata_quick_scx 4 | MorphologyPath ../circuit_sonata_quick_scx/components/morphologies/asc 5 | MorphologyType asc 6 | METypePath ../circuit_sonata_quick_scx/components/hoc 7 | CellLibraryFile ../circuit_sonata_quick_scx/nodes_A.h5 8 | nrnPath ../circuit_sonata_quick_scx/local_edges_A.h5 9 | CircuitTarget Mosaic_A 10 | 11 | Simulator NEURON 12 | RNGMode Random123 13 | BaseSeed 1 14 | 15 | CurrentDir . 16 | OutputRoot output 17 | TargetFile user.target 18 | 19 | RunMode RR 20 | Duration 50 21 | Dt 0.025 22 | } 23 | 24 | 25 | Report soma_SONATA 26 | { 27 | Target Mosaic_A 28 | Type compartment 29 | ReportOn v 30 | Unit mV 31 | Format SONATA 32 | Dt 1 33 | StartTime 0 34 | EndTime 10 35 | } 36 | 37 | 38 | Stimulus hypamp 39 | { 40 | Mode Current 41 | Pattern Hyperpolarizing 42 | Delay 0.0 43 | Duration 4000 44 | } 45 | 46 | 47 | StimulusInject hypamp_mosaic 48 | { 49 | Stimulus hypamp 50 | Target Mosaic_A 51 | } 52 | -------------------------------------------------------------------------------- /tests/mechanisms/Ih.mod: -------------------------------------------------------------------------------- 1 | :Comment : 2 | :Reference : : Kole,Hallermann,and Stuart, J. Neurosci. 2006 3 | : LJP: OK, "Somatic whole- cell voltage was corrected for the 14 mV difference" 4 | 5 | NEURON { 6 | SUFFIX Ih 7 | NONSPECIFIC_CURRENT ihcn 8 | RANGE gIhbar, gIh, ihcn 9 | } 10 | 11 | UNITS { 12 | (S) = (siemens) 13 | (mV) = (millivolt) 14 | (mA) = (milliamp) 15 | } 16 | 17 | PARAMETER { 18 | gIhbar = 0.00001 (S/cm2) 19 | ehcn = -45.0 (mV) 20 | } 21 | 22 | ASSIGNED { 23 | v (mV) 24 | ihcn (mA/cm2) 25 | gIh (S/cm2) 26 | mInf 27 | mTau 28 | mAlpha 29 | mBeta 30 | } 31 | 32 | STATE { 33 | m 34 | } 35 | 36 | BREAKPOINT { 37 | SOLVE states METHOD cnexp 38 | gIh = gIhbar*m 39 | ihcn = gIh*(v-ehcn) 40 | } 41 | 42 | DERIVATIVE states { 43 | rates() 44 | m' = (mInf-m)/mTau 45 | } 46 | 47 | INITIAL{ 48 | rates() 49 | m = mInf 50 | } 51 | 52 | PROCEDURE rates(){ 53 | UNITSOFF 54 | if(v == -154.9){ 55 | v = v + 0.0001 56 | } 57 | mAlpha = 0.001*6.43*(v+154.9)/(exp((v+154.9)/11.9)-1) 58 | mBeta = 0.001*193*exp(v/33.1) 59 | mInf = mAlpha/(mAlpha + mBeta) 60 | mTau = 1/(mAlpha + mBeta) 61 | UNITSON 62 | } 63 | -------------------------------------------------------------------------------- /tests/test_stimulus/test_circuit_stimulus_definitions.py: -------------------------------------------------------------------------------- 1 | # Copyright 2023-2024 Blue Brain Project / EPFL 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """Unit tests for the stimuli module.""" 15 | 16 | from pydantic import ValidationError 17 | import pytest 18 | from bluecellulab.stimulus.circuit_stimulus_definitions import SynapseReplay 19 | 20 | 21 | def test_synapse_replay_validator(): 22 | """Assures synapse replay's validator fails.""" 23 | with pytest.raises(ValidationError): 24 | _ = SynapseReplay( 25 | target="target1", 26 | delay=0, 27 | duration=3000, 28 | spike_file="file_that_does_not_exist.dat", 29 | ) 30 | -------------------------------------------------------------------------------- /tests/test_cell/test_random.py: -------------------------------------------------------------------------------- 1 | # Copyright 2023-2024 Blue Brain Project / EPFL 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """Unit tests for cell/random module.""" 15 | import neuron 16 | from pytest import approx 17 | 18 | from bluecellulab.cell.random import gamma 19 | 20 | 21 | def test_gamma(): 22 | """Unit test for the gamma function.""" 23 | rng = neuron.h.Random() 24 | gamma_shape = 0.5 25 | gamma_scale = 1.5 26 | N = 5 27 | res = gamma(rng, gamma_shape, gamma_scale, N) 28 | assert len(res) == N 29 | assert sum(res) == approx(2.9341513) 30 | assert res[0] == approx(0.2862183) 31 | assert max(res) == approx(1.3015527) 32 | assert min(res) == approx(0.2802995) 33 | -------------------------------------------------------------------------------- /tests/examples/sonata_unit_test_sims/condition_parameters/circuit_sonata.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest": { 3 | "$NETWORK_DIR": "../../circuit_sonata_quick_scx" 4 | }, 5 | "networks": { 6 | "nodes": [ 7 | { 8 | "nodes_file": "$NETWORK_DIR/nodes_A.h5", 9 | "populations": { 10 | "NodeA": { 11 | "type": "biophysical", 12 | "morphologies_dir": "../../circuit_sonata_quick_scx/components/morphologies/swc", 13 | "biophysical_neuron_models_dir": "../../circuit_sonata_quick_scx/components/hoc", 14 | "alternate_morphologies": { 15 | "neurolucida-asc": "../../circuit_sonata_quick_scx/components/morphologies/asc" 16 | } 17 | } 18 | } 19 | } 20 | ], 21 | "edges": [ 22 | { 23 | "edges_file": "$NETWORK_DIR/local_edges_A.h5", 24 | "populations": { 25 | "NodeA__NodeA__chemical": { 26 | "type": "chemical" 27 | } 28 | } 29 | } 30 | ] 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_sonata/circuit_sonata.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest": { 3 | "$NETWORK_DIR": "../circuit_sonata_quick_scx" 4 | }, 5 | "node_sets_file": "$NETWORK_DIR/node_sets.json", 6 | "networks": { 7 | "nodes": [ 8 | { 9 | "nodes_file": "$NETWORK_DIR/nodes_A.h5", 10 | "populations": { 11 | "NodeA": { 12 | "type": "biophysical", 13 | "morphologies_dir": "../circuit_sonata_quick_scx/components/morphologies/swc", 14 | "biophysical_neuron_models_dir": "../circuit_sonata_quick_scx/components/hoc", 15 | "alternate_morphologies": { 16 | "neurolucida-asc": "../circuit_sonata_quick_scx/components/morphologies/asc" 17 | } 18 | } 19 | } 20 | } 21 | ], 22 | "edges": [ 23 | { 24 | "edges_file": "$NETWORK_DIR/local_edges_A.h5", 25 | "populations": { 26 | "NodeA__NodeA__chemical": { 27 | "type": "chemical" 28 | } 29 | } 30 | } 31 | ] 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /tests/mechanisms/SK_E2.mod: -------------------------------------------------------------------------------- 1 | : SK-type calcium-activated potassium current 2 | : Reference : Kohler et al. 1996 3 | : LJP: OK, correction not necessary, no voltage values 4 | 5 | NEURON { 6 | SUFFIX SK_E2 7 | USEION k READ ek WRITE ik 8 | USEION ca READ cai 9 | RANGE gSK_E2bar, gSK_E2, ik, zTau 10 | } 11 | 12 | UNITS { 13 | (mV) = (millivolt) 14 | (mA) = (milliamp) 15 | (mM) = (milli/liter) 16 | } 17 | 18 | PARAMETER { 19 | v (mV) 20 | gSK_E2bar = .000001 (mho/cm2) 21 | zTau = 1 (ms) 22 | ek (mV) 23 | cai (mM) 24 | } 25 | 26 | ASSIGNED { 27 | zInf 28 | ik (mA/cm2) 29 | gSK_E2 (S/cm2) 30 | } 31 | 32 | STATE { 33 | z FROM 0 TO 1 34 | } 35 | 36 | BREAKPOINT { 37 | SOLVE states METHOD cnexp 38 | gSK_E2 = gSK_E2bar * z 39 | ik = gSK_E2 * (v - ek) 40 | } 41 | 42 | DERIVATIVE states { 43 | rates(cai) 44 | z' = (zInf - z) / zTau 45 | } 46 | 47 | PROCEDURE rates(ca(mM)) { 48 | if(ca < 1e-7){ 49 | ca = ca + 1e-07 50 | } 51 | zInf = 1/(1 + (0.00043 / ca)^4.8) 52 | } 53 | 54 | INITIAL { 55 | rates(cai) 56 | z = zInf 57 | } 58 | -------------------------------------------------------------------------------- /examples/mechanisms/SK_E2.mod: -------------------------------------------------------------------------------- 1 | : SK-type calcium-activated potassium current 2 | : Reference : Kohler et al. 1996 3 | : LJP: OK, correction not necessary, no voltage values 4 | 5 | NEURON { 6 | SUFFIX SK_E2 7 | USEION k READ ek WRITE ik 8 | USEION ca READ cai 9 | RANGE gSK_E2bar, gSK_E2, ik, zTau 10 | } 11 | 12 | UNITS { 13 | (mV) = (millivolt) 14 | (mA) = (milliamp) 15 | (mM) = (milli/liter) 16 | } 17 | 18 | PARAMETER { 19 | v (mV) 20 | gSK_E2bar = .000001 (mho/cm2) 21 | zTau = 1 (ms) 22 | ek (mV) 23 | cai (mM) 24 | } 25 | 26 | ASSIGNED { 27 | zInf 28 | ik (mA/cm2) 29 | gSK_E2 (S/cm2) 30 | } 31 | 32 | STATE { 33 | z FROM 0 TO 1 34 | } 35 | 36 | BREAKPOINT { 37 | SOLVE states METHOD cnexp 38 | gSK_E2 = gSK_E2bar * z 39 | ik = gSK_E2 * (v - ek) 40 | } 41 | 42 | DERIVATIVE states { 43 | rates(cai) 44 | z' = (zInf - z) / zTau 45 | } 46 | 47 | PROCEDURE rates(ca(mM)) { 48 | if(ca < 1e-7){ 49 | ca = ca + 1e-07 50 | } 51 | zInf = 1/(1 + (0.00043 / ca)^4.8) 52 | } 53 | 54 | INITIAL { 55 | rates(cai) 56 | z = zInf 57 | } 58 | -------------------------------------------------------------------------------- /tests/mechanisms/IN_Ih_Halnes2011.mod: -------------------------------------------------------------------------------- 1 | :Ih current for thalamic interneurons 2 | : Based on data and model in Halnes et al., 2011, PLOS Comp. Bio. 3 | 4 | NEURON { 5 | SUFFIX IN_ih 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 = -45.0 (mV) 19 | celsius (degC) 20 | q10 = 4 : Santoro et al., 2000 21 | } 22 | 23 | ASSIGNED { 24 | v (mV) 25 | ih (mA/cm2) 26 | g_h (S/cm2) 27 | mInf 28 | mTau 29 | tcorr :Add temperature correction 30 | i_rec 31 | } 32 | 33 | STATE { 34 | m 35 | } 36 | 37 | BREAKPOINT { 38 | SOLVE states METHOD cnexp 39 | g_h = gh_max*m 40 | ih = g_h*(v-e_h) 41 | i_rec = ih 42 | } 43 | 44 | DERIVATIVE states { 45 | rates() 46 | m' = (mInf-m)/mTau 47 | } 48 | 49 | INITIAL{ 50 | rates() 51 | m = mInf 52 | :tcorr = q10^((celsius-34)/10) :EI: Recording temp. 36 C Halnes, 2011, close to sim (34 C) -> no temperature correction 53 | } 54 | 55 | UNITSOFF 56 | PROCEDURE rates(){ 57 | v = v + 0 58 | mInf = 1/(1+exp((v+96)/10)) : Halnes et al., 2011, ModelDB 140229 59 | mTau = exp((v+250)/30.7) / ( 1 + exp((v+78.8)/5.78)): Halnes et al., 2011, ModelDB 140229 60 | v = v - 0 61 | } 62 | UNITSON 63 | -------------------------------------------------------------------------------- /tests/test_circuit/test_node_id.py: -------------------------------------------------------------------------------- 1 | # Copyright 2023-2024 Blue Brain Project / EPFL 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """Unit tests for node_id.py""" 15 | from bluecellulab.circuit.node_id import create_cell_id, create_cell_ids, CellId 16 | 17 | 18 | def test_create_cell_id(): 19 | """Testing creation of CellId.""" 20 | assert create_cell_id(1) == CellId("", 1) 21 | assert create_cell_id(("", 2)) == CellId("", 2) 22 | assert create_cell_id(("pop1", 2)) == CellId("pop1", 2) 23 | 24 | 25 | def test_create_cell_ids(): 26 | """Testing creation of CellIds.""" 27 | assert create_cell_ids([1, 2]) == [CellId("", 1), CellId("", 2)] 28 | assert create_cell_ids([("", 2), ("pop1", 2)]) == [ 29 | CellId("", 2), 30 | CellId("pop1", 2), 31 | ] 32 | -------------------------------------------------------------------------------- /tests/test_circuit/test_config_sections.py: -------------------------------------------------------------------------------- 1 | # Copyright 2023-2024 Blue Brain Project / EPFL 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """Unit tests for circuit/config/sections.py.""" 15 | 16 | import pytest 17 | from bluecellulab.circuit.config.sections import string_to_bool 18 | 19 | 20 | def test_string_to_bool(): 21 | """Unit test for the string_to_bool function.""" 22 | assert string_to_bool("True") 23 | assert string_to_bool("true") 24 | assert string_to_bool("TRUE") 25 | assert string_to_bool("1") 26 | assert string_to_bool("False") is False 27 | assert string_to_bool("false") is False 28 | assert string_to_bool("FALSE") is False 29 | assert string_to_bool("0") is False 30 | with pytest.raises(ValueError): 31 | string_to_bool("invalid") 32 | -------------------------------------------------------------------------------- /tests/mechanisms/Ca.mod: -------------------------------------------------------------------------------- 1 | :Comment : 2 | :Reference : : Reuveni, Friedman, Amitai, and Gutnick, J.Neurosci. 1993 3 | 4 | NEURON { 5 | SUFFIX Ca 6 | USEION ca READ eca WRITE ica 7 | RANGE gCabar, gCa, ica 8 | } 9 | 10 | UNITS { 11 | (S) = (siemens) 12 | (mV) = (millivolt) 13 | (mA) = (milliamp) 14 | } 15 | 16 | PARAMETER { 17 | gCabar = 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 = gCabar*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/mechanisms/Ca.mod: -------------------------------------------------------------------------------- 1 | :Comment : 2 | :Reference : : Reuveni, Friedman, Amitai, and Gutnick, J.Neurosci. 1993 3 | 4 | NEURON { 5 | SUFFIX Ca 6 | USEION ca READ eca WRITE ica 7 | RANGE gCabar, gCa, ica 8 | } 9 | 10 | UNITS { 11 | (S) = (siemens) 12 | (mV) = (millivolt) 13 | (mA) = (milliamp) 14 | } 15 | 16 | PARAMETER { 17 | gCabar = 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 = gCabar*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/mechanisms/KdShu2007.mod: -------------------------------------------------------------------------------- 1 | TITLE K-D 2 | : K-D current for prefrontal cortical neuron ------Yuguo Yu 2007 3 | : LJP: OK, "liquid junction potential of 10 mV was subtracted from each recording" 4 | 5 | NEURON { 6 | THREADSAFE 7 | SUFFIX KdShu2007 8 | USEION k WRITE ik 9 | RANGE gkbar, ik, ek 10 | RANGE minf, mtau, hinf, htau 11 | } 12 | 13 | PARAMETER { 14 | gkbar = 0.1 (mho/cm2) 15 | 16 | celsius 17 | ek = -100 (mV) : must be explicitly def. in hoc 18 | v (mV) 19 | vhalfm=-43 (mV) 20 | km=8 21 | vhalfh=-67 (mV) 22 | kh=7.3 23 | q10=2.3 24 | } 25 | 26 | 27 | UNITS { 28 | (mA) = (milliamp) 29 | (mV) = (millivolt) 30 | (pS) = (picosiemens) 31 | (um) = (micron) 32 | } 33 | 34 | ASSIGNED { 35 | ik (mA/cm2) 36 | minf mtau (ms) 37 | hinf htau (ms) 38 | } 39 | 40 | 41 | STATE { m h} 42 | 43 | BREAKPOINT { 44 | SOLVE states METHOD cnexp 45 | ik = gkbar * m*h*(v-ek) 46 | } 47 | 48 | INITIAL { 49 | trates(v) 50 | m=minf 51 | h=hinf 52 | } 53 | 54 | DERIVATIVE states { 55 | trates(v) 56 | m' = (minf-m)/mtau 57 | h' = (hinf-h)/htau 58 | } 59 | 60 | PROCEDURE trates(v) { 61 | LOCAL qt 62 | qt=q10^((celsius-22)/10) 63 | minf=1-1/(1+exp((v-vhalfm)/km)) 64 | hinf=1/(1+exp((v-vhalfh)/kh)) 65 | 66 | mtau = 0.6 67 | htau = 1500 68 | } 69 | -------------------------------------------------------------------------------- /tests/mechanisms/KdShu2007.mod: -------------------------------------------------------------------------------- 1 | TITLE K-D 2 | : K-D current for prefrontal cortical neuron ------Yuguo Yu 2007 3 | : LJP: OK, "liquid junction potential of 10 mV was subtracted from each recording" 4 | 5 | NEURON { 6 | THREADSAFE 7 | SUFFIX KdShu2007 8 | USEION k WRITE ik 9 | RANGE gkbar, ik, ek 10 | RANGE minf, mtau, hinf, htau 11 | } 12 | 13 | PARAMETER { 14 | gkbar = 0.1 (mho/cm2) 15 | 16 | celsius 17 | ek = -100 (mV) : must be explicitly def. in hoc 18 | v (mV) 19 | vhalfm=-43 (mV) 20 | km=8 21 | vhalfh=-67 (mV) 22 | kh=7.3 23 | q10=2.3 24 | } 25 | 26 | 27 | UNITS { 28 | (mA) = (milliamp) 29 | (mV) = (millivolt) 30 | (pS) = (picosiemens) 31 | (um) = (micron) 32 | } 33 | 34 | ASSIGNED { 35 | ik (mA/cm2) 36 | minf mtau (ms) 37 | hinf htau (ms) 38 | } 39 | 40 | 41 | STATE { m h} 42 | 43 | BREAKPOINT { 44 | SOLVE states METHOD cnexp 45 | ik = gkbar * m*h*(v-ek) 46 | } 47 | 48 | INITIAL { 49 | trates(v) 50 | m=minf 51 | h=hinf 52 | } 53 | 54 | DERIVATIVE states { 55 | trates(v) 56 | m' = (minf-m)/mtau 57 | h' = (hinf-h)/htau 58 | } 59 | 60 | PROCEDURE trates(v) { 61 | LOCAL qt 62 | qt=q10^((celsius-22)/10) 63 | minf=1-1/(1+exp((v-vhalfm)/km)) 64 | hinf=1/(1+exp((v-vhalfh)/kh)) 65 | 66 | mtau = 0.6 67 | htau = 1500 68 | } 69 | -------------------------------------------------------------------------------- /tests/examples/circuit_hipp_mooc_most_central_10_SP_PC/circuit_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "components": { 3 | "morphologies_dir": "./components/morphologies/swc", 4 | "biophysical_neuron_models_dir": "./components/hoc" 5 | }, 6 | "node_sets_file": "$BASE_DIR/node_sets.json", 7 | "networks": { 8 | "nodes": [ 9 | { 10 | "nodes_file": "$BASE_DIR/hippocampus_projections/nodes.h5", 11 | "node_types_file": null, 12 | "populations": { 13 | "hippocampus_projections": { 14 | "type": "virtual" 15 | } 16 | } 17 | }, 18 | { 19 | "nodes_file": "$BASE_DIR/nodes/nodes.h5", 20 | "node_types_file": null, 21 | "populations": { 22 | "hippocampus_neurons": { 23 | "type": "biophysical" 24 | } 25 | } 26 | } 27 | ], 28 | "edges": [ 29 | { 30 | "edges_file": "$BASE_DIR/edges/edges.h5", 31 | "edge_types_file": null, 32 | "populations": { 33 | "hippocampus_neurons__hippocampus_neurons__chemical": { 34 | "type": "chemical" 35 | }, 36 | "hippocampus_projections__hippocampus_neurons__chemical": { 37 | "type": "chemical" 38 | } 39 | } 40 | } 41 | ] 42 | }, 43 | "manifest": { 44 | "$BASE_DIR": "./" 45 | } 46 | } -------------------------------------------------------------------------------- /tests/mechanisms/TC_Ih_Bud97.mod: -------------------------------------------------------------------------------- 1 | :Ih current for thalamo-cortical neurons 2 | : Ref.: Huguenard et al., 1997 (taum), Budde et al., 1997 (minf) 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 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, 1992 q10 = 4 (Santoro et al., 2000). 54 | } 55 | 56 | UNITSOFF 57 | PROCEDURE rates(){ 58 | v = v + 0 59 | :mInf = 1/(1+exp((v+86.2)/4.2)) : Cain et al., 2015 60 | mInf = 1/(1+exp((v+86.4)/11.2)) : Budde et al., 1997 61 | mTau = (1/(exp(-14.59 - 0.086*v) + exp(-1.87 + 0.0701*v )))/tcorr : From Huguenard, 1992, LJP? 62 | v = v - 0 63 | } 64 | UNITSON 65 | -------------------------------------------------------------------------------- /tests/mechanisms/Ca_HVA.mod: -------------------------------------------------------------------------------- 1 | :Comment : 2 | :Reference : : Reuveni, Friedman, Amitai, and Gutnick, J.Neurosci. 1993 3 | : LJP: not corrected! 4 | 5 | NEURON { 6 | SUFFIX Ca_HVA 7 | USEION ca READ eca WRITE ica 8 | RANGE gCa_HVAbar, gCa_HVA, ica 9 | } 10 | 11 | UNITS { 12 | (S) = (siemens) 13 | (mV) = (millivolt) 14 | (mA) = (milliamp) 15 | } 16 | 17 | PARAMETER { 18 | gCa_HVAbar = 0.00001 (S/cm2) 19 | } 20 | 21 | ASSIGNED { 22 | v (mV) 23 | eca (mV) 24 | ica (mA/cm2) 25 | gCa (S/cm2) 26 | mInf 27 | mTau 28 | mAlpha 29 | mBeta 30 | hInf 31 | hTau 32 | hAlpha 33 | hBeta 34 | } 35 | 36 | STATE { 37 | m 38 | h 39 | } 40 | 41 | BREAKPOINT { 42 | SOLVE states METHOD cnexp 43 | gCa = gCa_HVAbar*m*m*h 44 | ica = gCa*(v-eca) 45 | } 46 | 47 | DERIVATIVE states { 48 | rates() 49 | m' = (mInf-m)/mTau 50 | h' = (hInf-h)/hTau 51 | } 52 | 53 | INITIAL{ 54 | rates() 55 | m = mInf 56 | h = hInf 57 | } 58 | 59 | PROCEDURE rates(){ 60 | UNITSOFF 61 | if((v == -27) ){ 62 | v = v+0.0001 63 | } 64 | mAlpha = (0.055*(-27-v))/(exp((-27-v)/3.8) - 1) 65 | mBeta = (0.94*exp((-75-v)/17)) 66 | mInf = mAlpha/(mAlpha + mBeta) 67 | mTau = 1/(mAlpha + mBeta) 68 | hAlpha = (0.000457*exp((-13-v)/50)) 69 | hBeta = (0.0065/(exp((-v-15)/28)+1)) 70 | hInf = hAlpha/(hAlpha + hBeta) 71 | hTau = 1/(hAlpha + hBeta) 72 | UNITSON 73 | } 74 | -------------------------------------------------------------------------------- /examples/mechanisms/Ca_HVA.mod: -------------------------------------------------------------------------------- 1 | :Comment : 2 | :Reference : : Reuveni, Friedman, Amitai, and Gutnick, J.Neurosci. 1993 3 | : LJP: not corrected! 4 | 5 | NEURON { 6 | SUFFIX Ca_HVA 7 | USEION ca READ eca WRITE ica 8 | RANGE gCa_HVAbar, gCa_HVA, ica 9 | } 10 | 11 | UNITS { 12 | (S) = (siemens) 13 | (mV) = (millivolt) 14 | (mA) = (milliamp) 15 | } 16 | 17 | PARAMETER { 18 | gCa_HVAbar = 0.00001 (S/cm2) 19 | } 20 | 21 | ASSIGNED { 22 | v (mV) 23 | eca (mV) 24 | ica (mA/cm2) 25 | gCa (S/cm2) 26 | mInf 27 | mTau 28 | mAlpha 29 | mBeta 30 | hInf 31 | hTau 32 | hAlpha 33 | hBeta 34 | } 35 | 36 | STATE { 37 | m 38 | h 39 | } 40 | 41 | BREAKPOINT { 42 | SOLVE states METHOD cnexp 43 | gCa = gCa_HVAbar*m*m*h 44 | ica = gCa*(v-eca) 45 | } 46 | 47 | DERIVATIVE states { 48 | rates() 49 | m' = (mInf-m)/mTau 50 | h' = (hInf-h)/hTau 51 | } 52 | 53 | INITIAL{ 54 | rates() 55 | m = mInf 56 | h = hInf 57 | } 58 | 59 | PROCEDURE rates(){ 60 | UNITSOFF 61 | if((v == -27) ){ 62 | v = v+0.0001 63 | } 64 | mAlpha = (0.055*(-27-v))/(exp((-27-v)/3.8) - 1) 65 | mBeta = (0.94*exp((-75-v)/17)) 66 | mInf = mAlpha/(mAlpha + mBeta) 67 | mTau = 1/(mAlpha + mBeta) 68 | hAlpha = (0.000457*exp((-13-v)/50)) 69 | hBeta = (0.0065/(exp((-v-15)/28)+1)) 70 | hInf = hAlpha/(hAlpha + hBeta) 71 | hTau = 1/(hAlpha + hBeta) 72 | UNITSON 73 | } 74 | -------------------------------------------------------------------------------- /tests/test_circuit/test_validate.py: -------------------------------------------------------------------------------- 1 | # Copyright 2023-2024 Blue Brain Project / EPFL 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """Unit tests for circuit/validate.py.""" 15 | import pandas as pd 16 | import pytest 17 | 18 | from bluecellulab.circuit.synapse_properties import SynapseProperty 19 | from bluecellulab.circuit.validate import check_nrrp_value 20 | 21 | 22 | def test_check_nrrp_value(): 23 | """Unit test for check nrrp value.""" 24 | synapses = pd.DataFrame(data={SynapseProperty.NRRP: [15.0, 16.0]}) 25 | 26 | check_nrrp_value(synapses) 27 | 28 | synapses[SynapseProperty.NRRP].loc[0] = 15.1 29 | with pytest.raises(ValueError): 30 | check_nrrp_value(synapses) 31 | 32 | synapses[SynapseProperty.NRRP].loc[0] = -1 33 | 34 | with pytest.raises(ValueError): 35 | check_nrrp_value(synapses) 36 | -------------------------------------------------------------------------------- /tests/examples/circuit_hipp_mooc_most_central_10_SP_PC/hoc-and-morphs.csv: -------------------------------------------------------------------------------- 1 | ,morphology,model_template 2 | 0,dend-051208AM2_axon-mpg141017_a1-2_idC_-_Scale_x1.000_y0.850_z1.000,CA1_pyr_cACpyr_mpg150305_A_idB_2019030511201 3 | 1,dend-mpg141216_A_idA_axon-mpg141017_a1-2_idC_-_Scale_x1.000_y0.900_z1.000_-_Clone_12,CA1_pyr_cACpyr_mpg141017_a1_2_idC_2019032814340 4 | 2,mpg141017_a1-2_idC_-_Scale_x1.000_y0.850_z1.000_-_Clone_11,CA1_pyr_cACpyr_mpg141217_A_idB_2019030511280 5 | 3,dend-mpg141216_A_idA_axon-mpg141017_a1-2_idC_-_Scale_x1.000_y0.850_z1.000_-_Clone_7,CA1_pyr_cACpyr_oh140807_A0_idB_2019030510521 6 | 4,dend-oh140521_B0_Rat_idC_axon-mpg141017_a1-2_idC_-_Scale_x1.000_y0.850_z1.000_-_Clone_12,CA1_pyr_cACpyr_oh140807_A0_idJ_2019032814272 7 | 5,dend-mpg141216_A_idA_axon-mpg141017_a1-2_idC_-_Scale_x1.000_y0.900_z1.000_-_Clone_4,CA1_pyr_cACpyr_oh140807_A0_idJ_2019032814272 8 | 6,dend-051208AM2_axon-mpg141017_a1-2_idC_-_Scale_x1.000_y0.850_z1.000_-_Clone_10,CA1_pyr_cACpyr_oh140807_A0_idJ_2019032814272 9 | 7,dend-oh140521_B0_Rat_idC_axon-mpg141017_a1-2_idC_-_Scale_x1.000_y0.850_z1.000_-_Clone_1,CA1_pyr_cACpyr_oh140807_A0_idB_2019030510521 10 | 8,dend-oh140807_A0_idF_axon-mpg141017_a1-2_idC_-_Scale_x1.000_y0.850_z1.000_-_Clone_12,CA1_pyr_cACpyr_mpg141017_a1_2_idC_2019032814340 11 | 9,dend-mpg141216_A_idA_axon-mpg141017_a1-2_idC_-_Scale_x1.000_y0.950_z1.000_-_Clone_4,CA1_pyr_cACpyr_oh140807_A0_idF_2019030511545 12 | -------------------------------------------------------------------------------- /CITATION.cff: -------------------------------------------------------------------------------- 1 | cff-version: 1.2.0 2 | message: "If you use this software, please cite it as below." 3 | title: "BlueCelluLab" 4 | doi: 10.5281/zenodo.8113483 5 | url: https://zenodo.org/doi/10.5281/zenodo.8113483 6 | abstract: "The Blue Brain Cellular Laboratory is designed for simulations and experiments on individual cells or groups of cells. Use cases for which bluecellulab is well suited include: scripting and statistics across single or pairs of cells, light-weight detailed reporting on a few state variables post-simulation, development of synaptic plasticity rules, dynamics validations of e.g. synaptic properties, automation of in-silico whole-cell patching experiments, debugging both scientifically and computationally." 7 | authors: 8 | - family-names: "Tuncel" 9 | given-names: "Anil" 10 | - family-names: "Van Geit" 11 | given-names: "Werner" 12 | - family-names: "Gevaert" 13 | given-names: "Mike" 14 | - family-names: "Torben-Nielsen" 15 | given-names: "Benjamin" 16 | - family-names: "Mandge" 17 | given-names: "Darshan" 18 | - family-names: "Kilic" 19 | given-names: "Ilkan" 20 | - family-names: "Jaquier" 21 | given-names: "Aurélien" 22 | - family-names: "Muller" 23 | given-names: "Eilif" 24 | - family-names: "Kanari" 25 | given-names: "Lida" 26 | - family-names: "Markram" 27 | given-names: "Henry" 28 | date-released: 2020-03-01 29 | publisher: "Zenodo" -------------------------------------------------------------------------------- /examples/2-sonata-network/sim_quick_scx_sonata_multicircuit/simulation_config_ornstein.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest": { 3 | "$OUTPUT_DIR": "." 4 | }, 5 | "run": { 6 | "tstop": 50.0, 7 | "dt": 0.025, 8 | "random_seed": 1 9 | }, 10 | "conditions": { 11 | "v_init": -65 12 | }, 13 | "target_simulator": "NEURON", 14 | "network": "circuit_sonata.json", 15 | "node_set": "Mosaic_A", 16 | "output": { 17 | "output_dir": "$OUTPUT_DIR/output_sonata_ornstein", 18 | "spikes_file": "out.h5", 19 | "spikes_sort_order": "by_time" 20 | }, 21 | "inputs": { 22 | "ornstein_uhlenbeck": { 23 | "module": "ornstein_uhlenbeck", 24 | "input_type": "conductance", 25 | "delay": 0.0, 26 | "duration": 500.0, 27 | "reversal": 0, 28 | "tau": 2.8, 29 | "sigma": 0.1542, 30 | "mean": 0.199, 31 | "node_set": "Mosaic_A", 32 | "random_seed": 42 33 | } 34 | }, 35 | "reports": { 36 | "soma": { 37 | "cells": "Mosaic_A", 38 | "variable_name": "v", 39 | "type": "compartment", 40 | "dt": 1.0, 41 | "start_time": 0.0, 42 | "end_time": 20.0, 43 | "sections": "soma", 44 | "compartments": "center" 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /tests/mechanisms/cacumm.mod: -------------------------------------------------------------------------------- 1 | COMMENT 2 | calcium accumulation into a volume of area*depth next to the 3 | membrane with a decay (time constant tau) to resting level 4 | given by the global calcium variable cai0_ca_ion 5 | Modified to include a resting current (irest) and peak value 6 | (cmax) 7 | i is a dummy current needed to force a BREAKPOINT 8 | ENDCOMMENT 9 | 10 | NEURON { 11 | SUFFIX cacum 12 | USEION ca READ ica WRITE cai 13 | NONSPECIFIC_CURRENT i 14 | RANGE depth, tau, cai0, cmax 15 | } 16 | 17 | UNITS { 18 | (mM) = (milli/liter) 19 | (mA) = (milliamp) 20 | F = (faraday) (coulombs) 21 | } 22 | 23 | PARAMETER { 24 | depth = 0.1 (um) : assume volume = area*depth 25 | irest = 0 (mA/cm2) : to be initialized in hoc 26 | tau = 100 (ms) 27 | cai0 = 50e-6 (mM) : Requires explicit use in INITIAL 28 | : block for it to take precedence over cai0_ca_ion 29 | : Do not forget to initialize in hoc if different 30 | : from this default. 31 | } 32 | 33 | ASSIGNED { 34 | ica (mA/cm2) 35 | cmax 36 | i (mA/cm2) 37 | } 38 | 39 | STATE { 40 | cai (mM) 41 | } 42 | 43 | INITIAL { 44 | cai = cai0 45 | :irest = ica 46 | cmax=cai 47 | } 48 | 49 | BREAKPOINT { 50 | SOLVE integrate METHOD derivimplicit 51 | if (cai>cmax) {cmax=cai} 52 | i=0 53 | } 54 | 55 | DERIVATIVE integrate { 56 | cai' = (irest-ica)/depth/F/2 * (1e4) + (cai0 - cai)/tau 57 | } 58 | -------------------------------------------------------------------------------- /bluecellulab/circuit/node_id.py: -------------------------------------------------------------------------------- 1 | # Copyright 2023-2024 Blue Brain Project / EPFL 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """Identifier for the circuit nodes. 15 | 16 | Account for multi-population and the single. 17 | """ 18 | 19 | from __future__ import annotations 20 | from typing import NamedTuple 21 | 22 | 23 | CellId = NamedTuple("CellId", [("population_name", str), ("id", int)]) 24 | 25 | 26 | def create_cell_id(cell_id: int | tuple[str, int] | CellId) -> CellId: 27 | """Make a CellId from a tuple or an int.""" 28 | if isinstance(cell_id, tuple): 29 | return CellId(*cell_id) 30 | else: 31 | return CellId("", cell_id) 32 | 33 | 34 | def create_cell_ids(cell_ids: list[int] | list[tuple[str, int] | CellId]) -> list[CellId]: 35 | """Make a list of CellId from a list of tuple or int.""" 36 | return [create_cell_id(cell_id) for cell_id in cell_ids] 37 | -------------------------------------------------------------------------------- /bluecellulab/hoc/RNGSettings.hoc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file RNGSetting.hoc 3 | * @brief To help with transitioning RNG behavior, this will contain setting/flags. 4 | * @author king 5 | * @date 2017-03-08 6 | * @remark Copyright 2005-2023 Blue Brain Project / EPFL 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | {load_file("fileUtils.hoc")} 22 | 23 | rngMode = 0 // corresponds to COMPATIBILITY defined below 24 | globalSeed = 0 25 | 26 | begintemplate RNGSettings 27 | 28 | public init, interpret, getRNGMode, getGlobalSeed 29 | public COMPATIBILITY, RANDOM123, UPMCELLRAN4 30 | 31 | external rngMode, globalSeed, terminate 32 | 33 | proc init() { 34 | // consts for random number handling 35 | COMPATIBILITY = 0 36 | RANDOM123 = 1 37 | UPMCELLRAN4 = 2 38 | } 39 | 40 | func getRNGMode() { 41 | return rngMode 42 | } 43 | 44 | endtemplate RNGSettings 45 | -------------------------------------------------------------------------------- /examples/README.rst: -------------------------------------------------------------------------------- 1 | BlueCelluLab's usage examples 2 | ==================================== 3 | 4 | - Follow the order of examples to understand the library's usage. 5 | - Interactive python notebook files are provided in each example directory. 6 | - The `mechanisms` directory is containing the mod files required for the examples, its compilation instructions is provided in the first tutorial. 7 | 8 | 9 | .. list-table:: 10 | :header-rows: 1 11 | 12 | * - File Name 13 | - Description 14 | * - `singlecell.ipynb <1-singlecell/singlecell.ipynb>`_ 15 | - Demonstration of single cell simulation capabilities 16 | * - `sonata-network.ipynb <2-sonata-network/sonata-network.ipynb>`_ 17 | - Simulating a group of cells from a multi polulation SONATA circuit 18 | * - `bpap.ipynb <3-bpap/bpap.ipynb>`_ 19 | - Simulating back propagating action potential in a dendritic tree 20 | * - `epsp.ipynb <4-epsp/epsp.ipynb>`_ 21 | - Simulating excitatory post synaptic potential on a Hippocampal CA1 cell 22 | * - `stimuli.ipynb <5-stimuli/stimuli.ipynb>`_ 23 | - Exploring the stimuli available at BlueCelluLab 24 | * - `stimuli-sequence.ipynb <6-stimuli-sequence/stimuli-sequence.ipynb>`_ 25 | - Simulating a sequence of stimuli on a cell in parallel 26 | * - `Multiple-protocols.ipynb <7-Extra-Simulation/Multiple-protocols.ipynb>`_ 27 | - Simulating multiple protocols on a cell using previous examples 28 | -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_sonata_multicircuit/simulation_config_ornstein.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest": { 3 | "$CIRCUIT_DIR": "usecase3", 4 | "$OUTPUT_DIR": "." 5 | }, 6 | "run": { 7 | "tstop": 50.0, 8 | "dt": 0.025, 9 | "random_seed": 1 10 | }, 11 | "conditions": { 12 | "v_init": -65 13 | }, 14 | "target_simulator": "NEURON", 15 | "network": "circuit_sonata.json", 16 | "node_set": "Mosaic_A", 17 | "output": { 18 | "output_dir": "$OUTPUT_DIR/output_sonata_ornstein", 19 | "spikes_file": "out.h5", 20 | "spikes_sort_order": "by_time" 21 | }, 22 | "inputs": { 23 | "ornstein_uhlenbeck": { 24 | "module": "ornstein_uhlenbeck", 25 | "input_type": "conductance", 26 | "delay": 0.0, 27 | "duration": 500.0, 28 | "reversal": 0, 29 | "tau": 2.8, 30 | "sigma": 0.1542, 31 | "mean": 0.199, 32 | "node_set": "Mosaic_A", 33 | "random_seed": 42 34 | } 35 | }, 36 | "reports": { 37 | "soma": { 38 | "cells": "Mosaic_A", 39 | "variable_name": "v", 40 | "type": "compartment", 41 | "dt": 1.0, 42 | "start_time": 0.0, 43 | "end_time": 20.0, 44 | "sections": "soma", 45 | "compartments": "center" 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /tests/mechanisms/TC_kir_Con15.mod: -------------------------------------------------------------------------------- 1 | TITLE Inward Rectifying Potassium Channel (IRK) 2 | 3 | COMMENT 4 | ********************************************* 5 | reference: NISENBAUM, E. S. & WILSON, C. J. (1995). Potassium currents 6 | responsible for inward and outward rectification in rat neostriatal 7 | spiny projection neurons. Journal of Neuroscience 15, 4449-4463. 8 | 9 | as reported in Williams SR et al., J Physiol (1997) 10 | 11 | William Connelly 2013 12 | ********************************************* 13 | 14 | ENDCOMMENT 15 | 16 | INDEPENDENT {t FROM 0 TO 1 WITH 1 (ms)} 17 | 18 | NEURON { 19 | SUFFIX TC_kir_Con15 20 | USEION k READ ek WRITE ik 21 | RANGE gkbar, m_inf, tau_m 22 | GLOBAL shift 23 | } 24 | 25 | UNITS { 26 | (mA) = (milliamp) 27 | (mV) = (millivolt) 28 | } 29 | 30 | PARAMETER { 31 | v (mV) 32 | ek (mV) 33 | gkbar= 0.0005 (mho/cm2) 34 | tau_m = 1.0 35 | shift = 0 EI: See Connelly et al., 2015 36 | } 37 | 38 | STATE { 39 | m 40 | } 41 | 42 | ASSIGNED { 43 | ik (mA/cm2) 44 | m_inf 45 | } 46 | 47 | BREAKPOINT { 48 | SOLVE states METHOD cnexp 49 | ik = gkbar * m^3 * (v-ek) 50 | } 51 | 52 | DERIVATIVE states { 53 | evaluate_fct(v) 54 | m'= (m_inf-m) / tau_m 55 | } 56 | 57 | INITIAL { 58 | evaluate_fct(v) 59 | m = m_inf 60 | } 61 | 62 | PROCEDURE evaluate_fct(v(mV)) { 63 | 64 | m_inf = 1/(1 + exp( (v - ek - 15 + shift)/10) ) 65 | } -------------------------------------------------------------------------------- /examples/4-epsp/hippocampus_mechanisms/cacumm.mod: -------------------------------------------------------------------------------- 1 | COMMENT 2 | calcium accumulation into a volume of area*depth next to the 3 | membrane with a decay (time constant tau) to resting level 4 | given by the global calcium variable cai0_ca_ion 5 | Modified to include a resting current (irest) and peak value 6 | (cmax) 7 | i is a dummy current needed to force a BREAKPOINT 8 | ENDCOMMENT 9 | 10 | NEURON { 11 | SUFFIX cacum 12 | USEION ca READ ica WRITE cai 13 | NONSPECIFIC_CURRENT i 14 | RANGE depth, tau, cai0, cmax 15 | } 16 | 17 | UNITS { 18 | (mM) = (milli/liter) 19 | (mA) = (milliamp) 20 | F = (faraday) (coulombs) 21 | } 22 | 23 | PARAMETER { 24 | depth = 0.1 (um) : assume volume = area*depth 25 | irest = 0 (mA/cm2) : to be initialized in hoc 26 | tau = 100 (ms) 27 | cai0 = 50e-6 (mM) : Requires explicit use in INITIAL 28 | : block for it to take precedence over cai0_ca_ion 29 | : Do not forget to initialize in hoc if different 30 | : from this default. 31 | } 32 | 33 | ASSIGNED { 34 | ica (mA/cm2) 35 | cmax 36 | i (mA/cm2) 37 | } 38 | 39 | STATE { 40 | cai (mM) 41 | } 42 | 43 | INITIAL { 44 | cai = cai0 45 | :irest = ica 46 | cmax=cai 47 | } 48 | 49 | BREAKPOINT { 50 | SOLVE integrate METHOD derivimplicit 51 | if (cai>cmax) {cmax=cai} 52 | i=0 53 | } 54 | 55 | DERIVATIVE integrate { 56 | cai' = (irest-ica)/depth/F/2 * (1e4) + (cai0 - cai)/tau 57 | } 58 | -------------------------------------------------------------------------------- /tests/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 | : LJP: OK 6 | 7 | NEURON { 8 | SUFFIX Ca_LVAst 9 | USEION ca READ eca WRITE ica 10 | RANGE gCa_LVAstbar, gCa_LVAst, ica 11 | } 12 | 13 | UNITS { 14 | (S) = (siemens) 15 | (mV) = (millivolt) 16 | (mA) = (milliamp) 17 | } 18 | 19 | PARAMETER { 20 | gCa_LVAstbar = 0.00001 (S/cm2) 21 | } 22 | 23 | ASSIGNED { 24 | v (mV) 25 | eca (mV) 26 | ica (mA/cm2) 27 | gCa_LVAst (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 | gCa_LVAst = gCa_LVAstbar*m*m*h 42 | ica = gCa_LVAst*(v-eca) 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 | v = v + 10 63 | mInf = 1.0000/(1+ exp((v - -30.000)/-6)) 64 | mTau = (5.0000 + 20.0000/(1+exp((v - -25.000)/5)))/qt 65 | hInf = 1.0000/(1+ exp((v - -80.000)/6.4)) 66 | hTau = (20.0000 + 50.0000/(1+exp((v - -40.000)/7)))/qt 67 | v = v - 10 68 | UNITSON 69 | } 70 | -------------------------------------------------------------------------------- /tests/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 | : LJP: OK 6 | 7 | NEURON { 8 | SUFFIX K_Tst 9 | USEION k READ ek WRITE ik 10 | RANGE gK_Tstbar, gK_Tst, ik 11 | } 12 | 13 | UNITS { 14 | (S) = (siemens) 15 | (mV) = (millivolt) 16 | (mA) = (milliamp) 17 | } 18 | 19 | PARAMETER { 20 | gK_Tstbar = 0.00001 (S/cm2) 21 | } 22 | 23 | ASSIGNED { 24 | v (mV) 25 | ek (mV) 26 | ik (mA/cm2) 27 | gK_Tst (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_Tst = gK_Tstbar*(m^4)*h 42 | ik = gK_Tst*(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 | 61 | UNITSOFF 62 | v = v + 10 63 | mInf = 1/(1 + exp(-(v+0)/19)) 64 | mTau = (0.34+0.92*exp(-((v+71)/59)^2))/qt 65 | hInf = 1/(1 + exp(-(v+66)/-10)) 66 | hTau = (8+49*exp(-((v+73)/23)^2))/qt 67 | v = v - 10 68 | UNITSON 69 | } 70 | -------------------------------------------------------------------------------- /examples/2-sonata-network/sim_quick_scx_sonata_multicircuit/simulation_config_shotnoise.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest": { 3 | "$OUTPUT_DIR": "." 4 | }, 5 | "run": { 6 | "tstop": 50.0, 7 | "dt": 0.025, 8 | "random_seed": 1 9 | }, 10 | "conditions": { 11 | "v_init": -65 12 | }, 13 | "target_simulator": "NEURON", 14 | "network": "circuit_sonata.json", 15 | "node_set": "Mosaic_A", 16 | "output": { 17 | "output_dir": "$OUTPUT_DIR/output_sonata_shotnoise", 18 | "spikes_file": "out.h5", 19 | "spikes_sort_order": "by_time" 20 | }, 21 | "inputs": { 22 | "stim_test_shot_noise": { 23 | "module": "shot_noise", 24 | "input_type": "current_clamp", 25 | "delay": 0.0, 26 | "duration": 400.0, 27 | "decay_time": 4, 28 | "rise_time": 0.4, 29 | "rate": 2000, 30 | "amp_mean": 0.04, 31 | "amp_var": 0.0016, 32 | "node_set": "Mosaic_A", 33 | "random_seed": 42 34 | } 35 | }, 36 | "reports": { 37 | "soma": { 38 | "cells": "Mosaic_A", 39 | "variable_name": "v", 40 | "type": "compartment", 41 | "dt": 1.0, 42 | "start_time": 0.0, 43 | "end_time": 20.0, 44 | "sections": "soma", 45 | "compartments": "center" 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /examples/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 | : LJP: OK 6 | 7 | NEURON { 8 | SUFFIX Ca_LVAst 9 | USEION ca READ eca WRITE ica 10 | RANGE gCa_LVAstbar, gCa_LVAst, ica 11 | } 12 | 13 | UNITS { 14 | (S) = (siemens) 15 | (mV) = (millivolt) 16 | (mA) = (milliamp) 17 | } 18 | 19 | PARAMETER { 20 | gCa_LVAstbar = 0.00001 (S/cm2) 21 | } 22 | 23 | ASSIGNED { 24 | v (mV) 25 | eca (mV) 26 | ica (mA/cm2) 27 | gCa_LVAst (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 | gCa_LVAst = gCa_LVAstbar*m*m*h 42 | ica = gCa_LVAst*(v-eca) 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 | v = v + 10 63 | mInf = 1.0000/(1+ exp((v - -30.000)/-6)) 64 | mTau = (5.0000 + 20.0000/(1+exp((v - -25.000)/5)))/qt 65 | hInf = 1.0000/(1+ exp((v - -80.000)/6.4)) 66 | hTau = (20.0000 + 50.0000/(1+exp((v - -40.000)/7)))/qt 67 | v = v - 10 68 | UNITSON 69 | } 70 | -------------------------------------------------------------------------------- /examples/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 | : LJP: OK 6 | 7 | NEURON { 8 | SUFFIX K_Tst 9 | USEION k READ ek WRITE ik 10 | RANGE gK_Tstbar, gK_Tst, ik 11 | } 12 | 13 | UNITS { 14 | (S) = (siemens) 15 | (mV) = (millivolt) 16 | (mA) = (milliamp) 17 | } 18 | 19 | PARAMETER { 20 | gK_Tstbar = 0.00001 (S/cm2) 21 | } 22 | 23 | ASSIGNED { 24 | v (mV) 25 | ek (mV) 26 | ik (mA/cm2) 27 | gK_Tst (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_Tst = gK_Tstbar*(m^4)*h 42 | ik = gK_Tst*(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 | 61 | UNITSOFF 62 | v = v + 10 63 | mInf = 1/(1 + exp(-(v+0)/19)) 64 | mTau = (0.34+0.92*exp(-((v+71)/59)^2))/qt 65 | hInf = 1/(1 + exp(-(v+66)/-10)) 66 | hTau = (8+49*exp(-((v+73)/23)^2))/qt 67 | v = v - 10 68 | UNITSON 69 | } 70 | -------------------------------------------------------------------------------- /tests/examples/sonata_unit_test_sims/projections/circuit_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest": { 3 | "$NETWORK_DIR": "../../circuit_hipp_mooc_most_central_10_SP_PC", 4 | "$COMPONENT_DIR": "$NETWORK_DIR/components" 5 | }, 6 | "components": { 7 | "morphologies_dir": "$COMPONENT_DIR/morphologies", 8 | "biophysical_neuron_models_dir": "$COMPONENT_DIR/hoc" 9 | }, 10 | "node_sets_file": "./node_sets.json", 11 | "networks": { 12 | "nodes": [ 13 | { 14 | "nodes_file": "$NETWORK_DIR/hippocampus_projections/nodes.h5", 15 | "node_types_file": null, 16 | "populations": { 17 | "hippocampus_projections": { 18 | "type": "virtual" 19 | } 20 | } 21 | }, 22 | { 23 | "nodes_file": "$NETWORK_DIR/nodes/nodes.h5", 24 | "node_types_file": null, 25 | "populations": { 26 | "hippocampus_neurons": { 27 | "type": "biophysical" 28 | } 29 | } 30 | } 31 | ], 32 | "edges": [ 33 | { 34 | "edges_file": "$NETWORK_DIR/edges/edges.h5", 35 | "edge_types_file": null, 36 | "populations":{ 37 | "hippocampus_neurons__hippocampus_neurons__chemical": { 38 | "type": "chemical" 39 | }, 40 | "hippocampus_projections__hippocampus_neurons__chemical": { 41 | "type": "chemical" 42 | } 43 | } 44 | } 45 | ] 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /tests/examples/sonata_unit_test_sims/synapse_replay/circuit_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest": { 3 | "$NETWORK_DIR": "../../circuit_hipp_mooc_most_central_10_SP_PC", 4 | "$COMPONENT_DIR": "$NETWORK_DIR/components" 5 | }, 6 | "components": { 7 | "morphologies_dir": "$COMPONENT_DIR/morphologies", 8 | "biophysical_neuron_models_dir": "$COMPONENT_DIR/hoc" 9 | }, 10 | "node_sets_file": "./node_sets.json", 11 | "networks": { 12 | "nodes": [ 13 | { 14 | "nodes_file": "$NETWORK_DIR/hippocampus_projections/nodes.h5", 15 | "node_types_file": null, 16 | "populations": { 17 | "hippocampus_projections": { 18 | "type": "virtual" 19 | } 20 | } 21 | }, 22 | { 23 | "nodes_file": "$NETWORK_DIR/nodes/nodes.h5", 24 | "node_types_file": null, 25 | "populations": { 26 | "hippocampus_neurons": { 27 | "type": "biophysical" 28 | } 29 | } 30 | } 31 | ], 32 | "edges": [ 33 | { 34 | "edges_file": "$NETWORK_DIR/edges/edges.h5", 35 | "edge_types_file": null, 36 | "populations":{ 37 | "hippocampus_neurons__hippocampus_neurons__chemical": { 38 | "type": "chemical" 39 | }, 40 | "hippocampus_projections__hippocampus_neurons__chemical": { 41 | "type": "chemical" 42 | } 43 | } 44 | } 45 | ] 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /tests/examples/sim_quick_scx_sonata_multicircuit/simulation_config_shotnoise.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest": { 3 | "$CIRCUIT_DIR": "usecase3", 4 | "$OUTPUT_DIR": "." 5 | }, 6 | "run": { 7 | "tstop": 50.0, 8 | "dt": 0.025, 9 | "random_seed": 1 10 | }, 11 | "conditions": { 12 | "v_init": -65 13 | }, 14 | "target_simulator": "NEURON", 15 | "network": "circuit_sonata.json", 16 | "node_set": "Mosaic_A", 17 | "output": { 18 | "output_dir": "$OUTPUT_DIR/output_sonata_shotnoise", 19 | "spikes_file": "out.h5", 20 | "spikes_sort_order": "by_time" 21 | }, 22 | "inputs": { 23 | "stim_test_shot_noise": { 24 | "module": "shot_noise", 25 | "input_type": "current_clamp", 26 | "delay": 0.0, 27 | "duration": 400.0, 28 | "decay_time": 4, 29 | "rise_time": 0.4, 30 | "rate": 2000, 31 | "amp_mean": 0.04, 32 | "amp_var": 0.0016, 33 | "node_set": "Mosaic_A", 34 | "random_seed": 42 35 | } 36 | }, 37 | "reports": { 38 | "soma": { 39 | "cells": "Mosaic_A", 40 | "variable_name": "v", 41 | "type": "compartment", 42 | "dt": 1.0, 43 | "start_time": 0.0, 44 | "end_time": 20.0, 45 | "sections": "soma", 46 | "compartments": "center" 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_replay/BlueConfig: -------------------------------------------------------------------------------- 1 | Run Default 2 | { 3 | Date 22:11:12 4 | Time 14:27:09 5 | svnPath https://bbpteam.epfl.ch/svn/bluebrain 6 | Version 1094 7 | Prefix /bgscratch/bbp/release/02.04.12 8 | MorphologyPath ../circuit_twocell_example1/morphologies 9 | METypePath ../circuit_twocell_example1/ccells 10 | 11 | CircuitPath ../circuit_twocell_example1 12 | nrnPath ../circuit_twocell_example1/ncsFunctionalAllRecipePathways 13 | 14 | CurrentDir ./ 15 | OutputRoot .//output 16 | TargetFile .//user.target 17 | 18 | CircuitTarget mc2_Layer5 19 | Duration 100 20 | Dt 0.025 21 | 22 | } 23 | 24 | Report soma 25 | { 26 | Target Mosaic 27 | Type compartment 28 | ReportOn v 29 | Unit mV 30 | Format Bin 31 | Dt 0.1 32 | StartTime 0 33 | EndTime 20000 34 | } 35 | 36 | Stimulus spikeReplay 37 | { 38 | Mode Current 39 | Delay 0 40 | Duration 100 41 | Pattern SynapseReplay 42 | SpikeFile output/out.dat.original 43 | } 44 | 45 | StimulusInject spikeReplayIntooneCell 46 | { 47 | Stimulus spikeReplay 48 | Target Mosaic 49 | } 50 | 51 | Connection changeUse 52 | { 53 | Source Excitatory 54 | Destination Excitatory 55 | Weight 1.0 56 | SynapseConfigure %s.Dep = 1.0 57 | } 58 | -------------------------------------------------------------------------------- /tests/mechanisms/cacummb.mod: -------------------------------------------------------------------------------- 1 | COMMENT 2 | calcium accumulation into a volume of area*depth next to the 3 | membrane with a decay (time constant tau) to resting level 4 | given by the global calcium variable cai0_ca_ion 5 | Modified to include a resting current (irest) and peak value 6 | (cmax) 7 | i is a dummy current needed to force a BREAKPOINT 8 | ENDCOMMENT 9 | 10 | NEURON { 11 | SUFFIX cacumb 12 | USEION ca READ ica WRITE cai 13 | NONSPECIFIC_CURRENT i 14 | RANGE depth, tau, cai0, cmax 15 | } 16 | 17 | UNITS { 18 | (mM) = (milli/liter) 19 | (mA) = (milliamp) 20 | F = (faraday) (coulombs) 21 | } 22 | 23 | PARAMETER { 24 | depth = 0.1 (um) : assume volume = area*depth 25 | tau = 100 (ms) 26 | cai0 = 50e-6 (mM) : Requires explicit use in INITIAL 27 | : block for it to take precedence over cai0_ca_ion 28 | : Do not forget to initialize in hoc if different 29 | : from this default. 30 | } 31 | 32 | ASSIGNED { 33 | ica (mA/cm2) 34 | cmax 35 | i (mA/cm2) 36 | irest (mA/cm2) 37 | } 38 | 39 | STATE { 40 | cai (mM) 41 | } 42 | 43 | INITIAL { 44 | cai = cai0 45 | : ica and irest is 0 at the begining. Also, as ica changes with multiple 46 | : finitialize, to have same state, avoid setting irest to ica 47 | : irest = ica 48 | cmax=cai 49 | } 50 | 51 | BREAKPOINT { 52 | SOLVE integrate METHOD derivimplicit 53 | if (cai>cmax) {cmax=cai} 54 | i=0 55 | } 56 | 57 | DERIVATIVE integrate { 58 | cai' = (irest-ica)/depth/F/2 * (1e4) + (cai0 - cai)/tau 59 | } 60 | -------------------------------------------------------------------------------- /bluecellulab/cell/cell_dict.py: -------------------------------------------------------------------------------- 1 | # Copyright 2023-2024 Blue Brain Project / EPFL 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """Dictionary of cells that support the old way of retrieval by int ids. 15 | 16 | as well as the new way of retrieval by CellId. 17 | """ 18 | 19 | from __future__ import annotations 20 | 21 | import bluecellulab 22 | from bluecellulab.circuit.node_id import CellId, create_cell_id 23 | 24 | 25 | class CellDict(dict): 26 | """Dictionary of Cell objects, backwards compatible with old gid 27 | representation.""" 28 | 29 | def __setitem__(self, key: int | tuple[str, int], value: bluecellulab.Cell) -> None: 30 | super().__setitem__(create_cell_id(key), value) 31 | 32 | def __getitem__(self, key: int | tuple[str, int]) -> bluecellulab.Cell: 33 | """Can retrieve for single population circuits, supports cells[gid].""" 34 | cell_id: CellId = create_cell_id(key) 35 | return super().__getitem__(cell_id) 36 | -------------------------------------------------------------------------------- /tests/mechanisms/CaDynamics_DC0.mod: -------------------------------------------------------------------------------- 1 | : Dynamics that track inside calcium concentration 2 | : modified from Destexhe et al. 1994 3 | : Dan Keller and Christian Roessert - removed shell, made dependent on geometry of individual sections via the surface to volume ratio 4 | : LJP: OK, correction not necessary, no voltage values 5 | 6 | NEURON { 7 | SUFFIX CaDynamics_DC0 8 | USEION ca READ ica WRITE cai 9 | RANGE decay, gamma 10 | } 11 | 12 | UNITS { 13 | (mV) = (millivolt) 14 | (mA) = (milliamp) 15 | FARADAY = (faraday) (coulombs) 16 | PI = (pi) (1) 17 | (molar) = (1/liter) 18 | (mM) = (millimolar) 19 | (um) = (micron) 20 | } 21 | 22 | PARAMETER { 23 | 24 | : Percent of free calcium (not buffered), Helmchen et al. 1996: (L5) kappa_e = 100 25 | gamma = 0.01 (1) 26 | 27 | : rate of removal of calcium: 28 | : L5 proximal dendrite: (Helmchen 1996) 70ms @ 7um diam 29 | decay = 70 (ms) 30 | 31 | : baseline calcium 32 | : CA1: (Sabatini 2002) 65 nM 33 | minCai = 6.5e-5 (mM) 34 | } 35 | 36 | ASSIGNED { 37 | ica (mA/cm2) 38 | diam (um) : diameter of current segment (automatically available within NMODL, like v) 39 | surftovol (1/um) 40 | } 41 | 42 | STATE { 43 | cai (mM) 44 | } 45 | 46 | BREAKPOINT { SOLVE states METHOD cnexp } 47 | 48 | INITIAL { 49 | : surface = 2*PI*(diam/2)*L 50 | : volume = PI*(diam/2)*(diam/2)*L 51 | surftovol = 4 / diam 52 | cai = minCai 53 | } 54 | 55 | DERIVATIVE states { 56 | cai' = -(10000)*ica*surftovol*gamma/(2*FARADAY) - (cai - minCai)/decay 57 | } 58 | -------------------------------------------------------------------------------- /examples/mechanisms/CaDynamics_DC0.mod: -------------------------------------------------------------------------------- 1 | : Dynamics that track inside calcium concentration 2 | : modified from Destexhe et al. 1994 3 | : Dan Keller and Christian Roessert - removed shell, made dependent on geometry of individual sections via the surface to volume ratio 4 | : LJP: OK, correction not necessary, no voltage values 5 | 6 | NEURON { 7 | SUFFIX CaDynamics_DC0 8 | USEION ca READ ica WRITE cai 9 | RANGE decay, gamma 10 | } 11 | 12 | UNITS { 13 | (mV) = (millivolt) 14 | (mA) = (milliamp) 15 | FARADAY = (faraday) (coulombs) 16 | PI = (pi) (1) 17 | (molar) = (1/liter) 18 | (mM) = (millimolar) 19 | (um) = (micron) 20 | } 21 | 22 | PARAMETER { 23 | 24 | : Percent of free calcium (not buffered), Helmchen et al. 1996: (L5) kappa_e = 100 25 | gamma = 0.01 (1) 26 | 27 | : rate of removal of calcium: 28 | : L5 proximal dendrite: (Helmchen 1996) 70ms @ 7um diam 29 | decay = 70 (ms) 30 | 31 | : baseline calcium 32 | : CA1: (Sabatini 2002) 65 nM 33 | minCai = 6.5e-5 (mM) 34 | } 35 | 36 | ASSIGNED { 37 | ica (mA/cm2) 38 | diam (um) : diameter of current segment (automatically available within NMODL, like v) 39 | surftovol (1/um) 40 | } 41 | 42 | STATE { 43 | cai (mM) 44 | } 45 | 46 | BREAKPOINT { SOLVE states METHOD cnexp } 47 | 48 | INITIAL { 49 | : surface = 2*PI*(diam/2)*L 50 | : volume = PI*(diam/2)*(diam/2)*L 51 | surftovol = 4 / diam 52 | cai = minCai 53 | } 54 | 55 | DERIVATIVE states { 56 | cai' = -(10000)*ica*surftovol*gamma/(2*FARADAY) - (cai - minCai)/decay 57 | } 58 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/test_sonata_proxy_gpfs.py: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Blue Brain Project / EPFL 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """Tests the sonata proxy using a sim on gpfs.""" 15 | 16 | from pytest import approx, mark 17 | 18 | from bluecellulab.cell import SonataProxy 19 | from bluecellulab.circuit import BluepyCircuitAccess 20 | from bluecellulab.circuit.node_id import CellId 21 | 22 | 23 | test_relative_ornstein_path = ( 24 | "/gpfs/bbp.cscs.ch/project/proj96/home/tuncel/simulations/" 25 | "test_sonata_proxy/BlueConfig" 26 | ) 27 | 28 | 29 | class TestSonataProxy: 30 | def setup_method(self): 31 | circuit_access = BluepyCircuitAccess(test_relative_ornstein_path) 32 | cell_id = CellId("", 1) 33 | self.sonata_proxy = SonataProxy(cell_id, circuit_access) 34 | 35 | @mark.v6 36 | def test_get_input_resistance(self): 37 | assert self.sonata_proxy.get_input_resistance().iloc[0] == approx(262.087372) 38 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/examples/sim_twocell_minis_replay/BlueConfig: -------------------------------------------------------------------------------- 1 | Run Default 2 | { 3 | Date 22:11:12 4 | Time 14:27:09 5 | svnPath https://bbpteam.epfl.ch/svn/bluebrain 6 | Version 1094 7 | Prefix /bgscratch/bbp/release/02.04.12 8 | MorphologyPath ../circuit_twocell_example1/morphologies 9 | METypePath ../circuit_twocell_example1/ccells 10 | 11 | CircuitPath ../circuit_twocell_example1 12 | nrnPath ../circuit_twocell_example1/ncsFunctionalAllRecipePathways 13 | 14 | CurrentDir ./ 15 | OutputRoot .//output 16 | TargetFile .//user.target 17 | 18 | CircuitTarget mc2_Layer5 19 | Duration 100 20 | Dt 0.025 21 | 22 | } 23 | 24 | Report soma 25 | { 26 | Target Mosaic 27 | Type compartment 28 | ReportOn v 29 | Unit mV 30 | Format Bin 31 | Dt 0.1 32 | StartTime 0 33 | EndTime 20000 34 | } 35 | 36 | Stimulus spikeReplay 37 | { 38 | Mode Current 39 | Delay 0 40 | Duration 100 41 | Pattern SynapseReplay 42 | SpikeFile output/out.dat.original 43 | } 44 | 45 | StimulusInject spikeReplayIntooneCell 46 | { 47 | Stimulus spikeReplay 48 | Target Mosaic 49 | } 50 | 51 | Connection changeUse 52 | { 53 | Source Excitatory 54 | Destination Excitatory 55 | Weight 1.0 56 | SynapseConfigure %s.Dep = 1.0 57 | SpontMinis 100.0 58 | } 59 | -------------------------------------------------------------------------------- /tests/test_exceptions.py: -------------------------------------------------------------------------------- 1 | # Copyright 2023-2024 Blue Brain Project / EPFL 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """Unit tests for the exceptions module.""" 15 | 16 | from bluecellulab.exceptions import error_context 17 | 18 | 19 | def test_error_context(): 20 | """Unit test for the error_context function.""" 21 | attr_err_msg = "hoc.HocObject' object has no attribute 'minis_single_vesicle_" 22 | lookup_err_msg = "'X' is not a defined hoc variable name" 23 | context_info = "mechanism/s for minis_single_vesicle need to be compiled" 24 | try: 25 | with error_context(context_info): 26 | raise AttributeError(attr_err_msg) 27 | except AttributeError as error: 28 | assert str(error) == f"{context_info}: {attr_err_msg}" 29 | try: 30 | with error_context(context_info): 31 | raise LookupError(lookup_err_msg) 32 | except LookupError as error: 33 | assert str(error) == f"{context_info}: {lookup_err_msg}" 34 | -------------------------------------------------------------------------------- /examples/mechanisms/Ca_HVA2.mod: -------------------------------------------------------------------------------- 1 | :Comment : 2 | :Reference : : Reuveni, Friedman, Amitai, and Gutnick, J.Neurosci. 1993 3 | : activation from Sayer, Schwindt and Crill (1990) 4 | : inactivation from Dichter and Zona 1989 5 | : LJP: OK, inactivation corrected by 12.3 mV 6 | 7 | NEURON { 8 | SUFFIX Ca_HVA2 9 | USEION ca READ eca WRITE ica 10 | RANGE gCa_HVAbar, gCa_HVA, ica 11 | } 12 | 13 | UNITS { 14 | (S) = (siemens) 15 | (mV) = (millivolt) 16 | (mA) = (milliamp) 17 | } 18 | 19 | PARAMETER { 20 | gCa_HVAbar = 0.00001 (S/cm2) 21 | } 22 | 23 | ASSIGNED { 24 | v (mV) 25 | eca (mV) 26 | ica (mA/cm2) 27 | gCa (S/cm2) 28 | mInf 29 | mTau 30 | mAlpha 31 | mBeta 32 | hInf 33 | hTau 34 | hAlpha 35 | hBeta 36 | } 37 | 38 | STATE { 39 | m 40 | h 41 | } 42 | 43 | BREAKPOINT { 44 | SOLVE states METHOD cnexp 45 | gCa = gCa_HVAbar*m*m*h 46 | ica = gCa*(v-eca) 47 | } 48 | 49 | DERIVATIVE states { 50 | rates() 51 | m' = (mInf-m)/mTau 52 | h' = (hInf-h)/hTau 53 | } 54 | 55 | INITIAL{ 56 | rates() 57 | m = mInf 58 | h = hInf 59 | } 60 | 61 | PROCEDURE rates(){ 62 | UNITSOFF 63 | if((v == -27) ){ 64 | v = v+0.0001 65 | } 66 | mAlpha = (0.055*(-27-v))/(exp((-27-v)/3.8) - 1) 67 | mBeta = (0.94*exp((-75-v)/17)) 68 | mInf = mAlpha/(mAlpha + mBeta) 69 | mTau = 1/(mAlpha + mBeta) 70 | v = v + 12.3 71 | hAlpha = (0.000457*exp((-13-v)/50)) 72 | hBeta = (0.0065/(exp((-v-15)/28)+1)) 73 | hInf = hAlpha/(hAlpha + hBeta) 74 | hTau = 1/(hAlpha + hBeta) 75 | v = v - 12.3 76 | UNITSON 77 | } 78 | -------------------------------------------------------------------------------- /tests/mechanisms/Ca_HVA2.mod: -------------------------------------------------------------------------------- 1 | :Comment : 2 | :Reference : : Reuveni, Friedman, Amitai, and Gutnick, J.Neurosci. 1993 3 | : activation from Sayer, Schwindt and Crill (1990) 4 | : inactivation from Dichter and Zona 1989 5 | : LJP: OK, inactivation corrected by 12.3 mV 6 | 7 | NEURON { 8 | SUFFIX Ca_HVA2 9 | USEION ca READ eca WRITE ica 10 | RANGE gCa_HVAbar, gCa_HVA, ica 11 | } 12 | 13 | UNITS { 14 | (S) = (siemens) 15 | (mV) = (millivolt) 16 | (mA) = (milliamp) 17 | } 18 | 19 | PARAMETER { 20 | gCa_HVAbar = 0.00001 (S/cm2) 21 | } 22 | 23 | ASSIGNED { 24 | v (mV) 25 | eca (mV) 26 | ica (mA/cm2) 27 | gCa (S/cm2) 28 | mInf 29 | mTau 30 | mAlpha 31 | mBeta 32 | hInf 33 | hTau 34 | hAlpha 35 | hBeta 36 | } 37 | 38 | STATE { 39 | m 40 | h 41 | } 42 | 43 | BREAKPOINT { 44 | SOLVE states METHOD cnexp 45 | gCa = gCa_HVAbar*m*m*h 46 | ica = gCa*(v-eca) 47 | } 48 | 49 | DERIVATIVE states { 50 | rates() 51 | m' = (mInf-m)/mTau 52 | h' = (hInf-h)/hTau 53 | } 54 | 55 | INITIAL{ 56 | rates() 57 | m = mInf 58 | h = hInf 59 | } 60 | 61 | PROCEDURE rates(){ 62 | UNITSOFF 63 | if((v == -27) ){ 64 | v = v+0.0001 65 | } 66 | mAlpha = (0.055*(-27-v))/(exp((-27-v)/3.8) - 1) 67 | mBeta = (0.94*exp((-75-v)/17)) 68 | mInf = mAlpha/(mAlpha + mBeta) 69 | mTau = 1/(mAlpha + mBeta) 70 | v = v + 12.3 71 | hAlpha = (0.000457*exp((-13-v)/50)) 72 | hBeta = (0.0065/(exp((-v-15)/28)+1)) 73 | hInf = hAlpha/(hAlpha + hBeta) 74 | hTau = 1/(hAlpha + hBeta) 75 | v = v - 12.3 76 | UNITSON 77 | } 78 | -------------------------------------------------------------------------------- /tests/test_cell/test_cell_dict.py: -------------------------------------------------------------------------------- 1 | # Copyright 2023-2024 Blue Brain Project / EPFL 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """Unit tests for the cell_dict module.""" 15 | from pathlib import Path 16 | 17 | import pytest 18 | 19 | from bluecellulab.cell import Cell, CellDict 20 | from bluecellulab.circuit.node_id import CellId 21 | 22 | 23 | parent_dir = Path(__file__).resolve().parent.parent 24 | 25 | 26 | @pytest.mark.v5 27 | def test_cell_dict(): 28 | """Unit test for the CellDict class.""" 29 | cell = Cell( 30 | "%s/examples/cell_example1/test_cell_longname1.hoc" % str(parent_dir), 31 | "%s/examples/cell_example1" % str(parent_dir)) 32 | 33 | cell_dict = CellDict() 34 | cell_dict[1] = cell 35 | assert cell_dict[("", 1)] == cell 36 | assert cell_dict[1] == cell 37 | 38 | cell_dict[("population1", 2)] = cell 39 | cell_id = CellId("population1", 2) 40 | assert cell_dict[cell_id] == cell 41 | assert cell_dict[("population1", 2)] == cell 42 | -------------------------------------------------------------------------------- /bluecellulab/verbosity.py: -------------------------------------------------------------------------------- 1 | """Functions for configuring the verbosity of BlueCelluLab.""" 2 | 3 | 4 | import logging 5 | import os 6 | from typing import Optional 7 | 8 | import bluecellulab 9 | 10 | 11 | logger = logging.getLogger(__name__) 12 | 13 | VERBOSE_LEVEL = 0 14 | ENV_VERBOSE_LEVEL: Optional[str] = None 15 | 16 | 17 | def set_verbose(level: int = 1) -> None: 18 | """Set the verbose level of BluecellulabError. 19 | 20 | Parameters 21 | ---------- 22 | level : 23 | Verbose level, the higher the more verbosity. 24 | Level 0 means 'completely quiet', except if some very serious 25 | errors or warnings are encountered. 26 | """ 27 | bluecellulab.VERBOSE_LEVEL = level 28 | 29 | if level <= 0: 30 | logging.getLogger('bluecellulab').setLevel(logging.CRITICAL) 31 | elif level == 1: 32 | logging.getLogger('bluecellulab').setLevel(logging.ERROR) 33 | elif level == 2: 34 | logging.getLogger('bluecellulab').setLevel(logging.WARNING) 35 | elif level > 2 and level <= 5: 36 | logging.getLogger('bluecellulab').setLevel(logging.INFO) 37 | else: 38 | logging.getLogger('bluecellulab').setLevel(logging.DEBUG) 39 | 40 | 41 | def set_verbose_from_env() -> None: 42 | """Get verbose level from environment.""" 43 | bluecellulab.ENV_VERBOSE_LEVEL = os.environ.get('BLUECELLULAB_VERBOSE_LEVEL') 44 | 45 | if bluecellulab.ENV_VERBOSE_LEVEL is not None: 46 | set_verbose(int(bluecellulab.ENV_VERBOSE_LEVEL)) 47 | 48 | 49 | set_verbose_from_env() 50 | -------------------------------------------------------------------------------- /tests/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 | : LJP: OK 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 | -------------------------------------------------------------------------------- /tests/mechanisms/kmb.mod: -------------------------------------------------------------------------------- 1 | TITLE CA1 KM channel from Mala Shah 2 | : M. Migliore June 2006 3 | 4 | UNITS { 5 | (mA) = (milliamp) 6 | (mV) = (millivolt) 7 | 8 | } 9 | 10 | PARAMETER { 11 | v (mV) 12 | ek 13 | celsius (degC) 14 | gbar=.0001 (mho/cm2) 15 | vhalfl=-40 (mV) 16 | kl=-10 17 | vhalft=-42 (mV) 18 | a0t=0.003 (/ms) 19 | zetat=7 (1) 20 | gmt=.4 (1) 21 | q10=5 22 | b0=60 23 | st=1 24 | sh =0 25 | } 26 | 27 | 28 | NEURON { 29 | SUFFIX kmb 30 | USEION k READ ek WRITE ik 31 | RANGE gbar,ik, sh 32 | RANGE inf, tau 33 | } 34 | 35 | STATE { 36 | m 37 | } 38 | 39 | ASSIGNED { 40 | ik (mA/cm2) 41 | inf 42 | tau 43 | taua 44 | taub 45 | } 46 | 47 | INITIAL { 48 | rate(v) 49 | m=inf 50 | } 51 | 52 | 53 | BREAKPOINT { 54 | SOLVE state METHOD cnexp 55 | ik = gbar*m^st*(v-ek) 56 | } 57 | 58 | 59 | FUNCTION alpt(v(mV)) { 60 | alpt = exp(0.0378*zetat*(v-vhalft-sh)) 61 | } 62 | 63 | FUNCTION bett(v(mV)) { 64 | bett = exp(0.0378*zetat*gmt*(v-vhalft-sh)) 65 | } 66 | 67 | DERIVATIVE state { 68 | rate(v) 69 | m' = (inf - m)/tau 70 | } 71 | 72 | PROCEDURE rate(v (mV)) { :callable from hoc 73 | LOCAL a,qt 74 | qt=q10^((celsius-35)/10) 75 | inf = (1/(1 + exp((v-vhalfl-sh)/kl))) 76 | a = alpt(v) 77 | tau = b0 + bett(v)/(a0t*(1+a)) 78 | } 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /examples/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 | : LJP: OK 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/4-epsp/hippocampus_mechanisms/kmb.mod: -------------------------------------------------------------------------------- 1 | TITLE CA1 KM channel from Mala Shah 2 | : M. Migliore June 2006 3 | 4 | UNITS { 5 | (mA) = (milliamp) 6 | (mV) = (millivolt) 7 | 8 | } 9 | 10 | PARAMETER { 11 | v (mV) 12 | ek 13 | celsius (degC) 14 | gbar=.0001 (mho/cm2) 15 | vhalfl=-40 (mV) 16 | kl=-10 17 | vhalft=-42 (mV) 18 | a0t=0.003 (/ms) 19 | zetat=7 (1) 20 | gmt=.4 (1) 21 | q10=5 22 | b0=60 23 | st=1 24 | sh =0 25 | } 26 | 27 | 28 | NEURON { 29 | SUFFIX kmb 30 | USEION k READ ek WRITE ik 31 | RANGE gbar,ik, sh 32 | GLOBAL inf, tau 33 | } 34 | 35 | STATE { 36 | m 37 | } 38 | 39 | ASSIGNED { 40 | ik (mA/cm2) 41 | inf 42 | tau 43 | taua 44 | taub 45 | } 46 | 47 | INITIAL { 48 | rate(v) 49 | m=inf 50 | } 51 | 52 | 53 | BREAKPOINT { 54 | SOLVE state METHOD cnexp 55 | ik = gbar*m^st*(v-ek) 56 | } 57 | 58 | 59 | FUNCTION alpt(v(mV)) { 60 | alpt = exp(0.0378*zetat*(v-vhalft-sh)) 61 | } 62 | 63 | FUNCTION bett(v(mV)) { 64 | bett = exp(0.0378*zetat*gmt*(v-vhalft-sh)) 65 | } 66 | 67 | DERIVATIVE state { 68 | rate(v) 69 | m' = (inf - m)/tau 70 | } 71 | 72 | PROCEDURE rate(v (mV)) { :callable from hoc 73 | LOCAL a,qt 74 | qt=q10^((celsius-35)/10) 75 | inf = (1/(1 + exp((v-vhalfl-sh)/kl))) 76 | a = alpt(v) 77 | tau = b0 + bett(v)/(a0t*(1+a)) 78 | } 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /tests/bluecellulab-bb5-tests/tests/test_helpers.py: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Blue Brain Project / EPFL 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """Tests of the helper functions used in tests.""" 15 | 16 | import os 17 | from helpers.circuit import blueconfig_append_path 18 | 19 | script_dir = os.path.dirname(__file__) 20 | 21 | 22 | def test_blueconfig_append_path(): 23 | """Tools: Test blueconfig_append_path.""" 24 | conf_pre_path = os.path.join(script_dir, "examples", "sim_twocell_empty") 25 | blueconfig_path = os.path.join(conf_pre_path, "BlueConfig") 26 | 27 | fields = [ 28 | "MorphologyPath", 29 | "METypePath", 30 | "CircuitPath", 31 | "nrnPath", 32 | "CurrentDir", 33 | "OutputRoot", 34 | "TargetFile", 35 | ] 36 | 37 | modified_config = blueconfig_append_path( 38 | blueconfig_path, conf_pre_path, fields=fields 39 | ) 40 | 41 | for field in fields: 42 | field_val = modified_config.Run.__getattr__(field) 43 | assert os.path.isabs(field_val) 44 | -------------------------------------------------------------------------------- /tests/mechanisms/kdb.mod: -------------------------------------------------------------------------------- 1 | TITLE K-D channel 2 | : M.Migliore jun 2006 3 | 4 | UNITS { 5 | (mA) = (milliamp) 6 | (mV) = (millivolt) 7 | 8 | } 9 | 10 | PARAMETER { 11 | v (mV) 12 | ek (mV) : must be explicitely def. in hoc 13 | celsius (degC) 14 | gkdbar=.0 (mho/cm2) 15 | vhalfn=-33 (mV) 16 | a0n=0.005 (/ms) 17 | zetan=3 (1) 18 | gmn=0.7 (1) 19 | nmax=2 (1) 20 | q10=1 21 | sh = 0 22 | } 23 | 24 | 25 | NEURON { 26 | SUFFIX kdb 27 | USEION k READ ek WRITE ik 28 | RANGE gkd,gkdbar, sh 29 | RANGE ninf,taun 30 | } 31 | 32 | STATE { 33 | n 34 | } 35 | 36 | ASSIGNED { 37 | ik (mA/cm2) 38 | ninf 39 | gkd 40 | taun 41 | } 42 | 43 | BREAKPOINT { 44 | SOLVE states METHOD cnexp 45 | gkd = gkdbar*n 46 | ik = gkd*(v-ek) 47 | 48 | } 49 | 50 | INITIAL { 51 | rates(v) 52 | n=ninf 53 | } 54 | 55 | 56 | FUNCTION alpn(v(mV)) { 57 | alpn = exp(1.e-3*zetan*(v-vhalfn-sh)*9.648e4/(8.315*(273.16+celsius))) 58 | } 59 | 60 | FUNCTION betn(v(mV)) { 61 | betn = exp(1.e-3*zetan*gmn*(v-vhalfn-sh)*9.648e4/(8.315*(273.16+celsius))) 62 | } 63 | 64 | DERIVATIVE states { : exact when v held constant; integrates over dt step 65 | rates(v) 66 | n' = (ninf - n)/taun 67 | } 68 | 69 | PROCEDURE rates(v (mV)) { :callable from hoc 70 | LOCAL a,qt 71 | qt=q10^((celsius-24)/10) 72 | a = alpn(v) 73 | ninf = 1/(1+a) 74 | taun = betn(v)/(qt*a0n*(1+a)) 75 | if (taun= 0) 45 | -------------------------------------------------------------------------------- /tests/test_synapse/test_synapse.py: -------------------------------------------------------------------------------- 1 | # Copyright 2023-2024 Blue Brain Project / EPFL 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """Unit tests for the synapse module.""" 15 | 16 | import numpy as np 17 | from pytest import approx 18 | 19 | from bluecellulab.synapse import Synapse 20 | 21 | 22 | def test_calc_u_scale_factor(): 23 | """Test calculation of u_scale_factor against its old implementation.""" 24 | def hill(extracellular_calcium, y, K_half): 25 | return y * extracellular_calcium**4 / ( 26 | K_half**4 + extracellular_calcium**4) 27 | 28 | def constrained_hill(K_half): 29 | y_max = (K_half**4 + 16) / 16 30 | return lambda x: hill(x, y_max, K_half) 31 | 32 | def f_scale(x, y): 33 | return constrained_hill(x)(y) 34 | 35 | scale_factor = np.vectorize(f_scale) 36 | 37 | a = 4.62799366 38 | b = 3.27495564 39 | 40 | assert scale_factor(a, 2) == approx(Synapse.calc_u_scale_factor(a, 2)) 41 | assert scale_factor(a, 2.2) == approx(Synapse.calc_u_scale_factor(a, 2.2)) 42 | assert scale_factor(a, b) == approx(Synapse.calc_u_scale_factor(a, b)) 43 | -------------------------------------------------------------------------------- /tests/test_ssim.py: -------------------------------------------------------------------------------- 1 | # Copyright 2023-2024 Blue Brain Project / EPFL 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """Unit tests for CircuitSimulation.""" 15 | import numpy as np 16 | 17 | from bluecellulab import CircuitSimulation 18 | 19 | 20 | def test_merge_pre_spike_trains(): 21 | """CircuitSimulation: Testing merge_pre_spike_trains""" 22 | 23 | train1 = {1: [5, 100], 2: [5, 8, 120]} 24 | train2 = {2: [7], 3: [8]} 25 | train3 = {1: [5, 100]} 26 | 27 | trains_merged = {1: [5, 5, 100, 100], 2: [5, 7, 8, 120], 3: [8]} 28 | 29 | np.testing.assert_equal( 30 | {}, 31 | CircuitSimulation.merge_pre_spike_trains(None)) 32 | np.testing.assert_equal( 33 | train1, 34 | CircuitSimulation.merge_pre_spike_trains(train1)) 35 | np.testing.assert_equal( 36 | train1, 37 | CircuitSimulation.merge_pre_spike_trains( 38 | None, 39 | train1)) 40 | np.testing.assert_equal( 41 | trains_merged, 42 | CircuitSimulation.merge_pre_spike_trains( 43 | train1, 44 | None, 45 | train2, 46 | train3)) 47 | -------------------------------------------------------------------------------- /tests/mechanisms/h.mod: -------------------------------------------------------------------------------- 1 | TITLE I-h channel from Magee 1998 for distal dendrites 2 | 3 | UNITS { 4 | (mA) = (milliamp) 5 | (mV) = (millivolt) 6 | 7 | } 8 | 9 | PARAMETER { 10 | v (mV) 11 | ehd = -30 (mV) 12 | celsius (degC) 13 | ghdbar=.0001 (mho/cm2) 14 | vhalfl=-81 (mV) 15 | kl=-8 16 | vhalft=-75 (mV) 17 | a0t=0.011 (/ms) 18 | zetat=2.2 (1) 19 | gmt=.4 (1) 20 | q10=4.5 21 | qtl=1 22 | } 23 | 24 | 25 | NEURON { 26 | SUFFIX hd 27 | NONSPECIFIC_CURRENT i 28 | RANGE ghdbar, vhalfl 29 | RANGE linf,taul 30 | } 31 | 32 | STATE { 33 | l 34 | } 35 | 36 | ASSIGNED { 37 | i (mA/cm2) 38 | linf 39 | taul 40 | ghd 41 | } 42 | 43 | INITIAL { 44 | rate(v) 45 | l=linf 46 | } 47 | 48 | 49 | BREAKPOINT { 50 | SOLVE states METHOD cnexp 51 | ghd = ghdbar*l 52 | i = ghd*(v-ehd) 53 | 54 | } 55 | 56 | 57 | FUNCTION alpt(v(mV)) { 58 | alpt = exp(0.0378*zetat*(v-vhalft)) 59 | } 60 | 61 | FUNCTION bett(v(mV)) { 62 | bett = exp(0.0378*zetat*gmt*(v-vhalft)) 63 | } 64 | 65 | DERIVATIVE states { : exact when v held constant; integrates over dt step 66 | rate(v) 67 | l' = (linf - l)/taul 68 | } 69 | 70 | PROCEDURE rate(v (mV)) { :callable from hoc 71 | LOCAL a,qt 72 | qt=q10^((celsius-33)/10) 73 | a = alpt(v) 74 | linf = 1/(1 + exp(-(v-vhalfl)/kl)) 75 | : linf = 1/(1+ alpl(v)) 76 | taul = bett(v)/(qtl*qt*a0t*(1+a)) 77 | } 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /tests/mechanisms/kd.mod: -------------------------------------------------------------------------------- 1 | TITLE K-D channel 2 | : M.Migliore jun 2006 3 | 4 | UNITS { 5 | (mA) = (milliamp) 6 | (mV) = (millivolt) 7 | 8 | } 9 | 10 | PARAMETER { 11 | v (mV) 12 | ek (mV) : must be explicitely def. in hoc 13 | celsius (degC) 14 | gkdbar=.0 (mho/cm2) 15 | vhalfn=-33 (mV) 16 | a0n=0.01 (/ms) 17 | zetan=3 (1) 18 | gmn=0.7 (1) 19 | nmax=2 (1) 20 | q10=1 21 | sh = 5 22 | } 23 | 24 | 25 | NEURON { 26 | SUFFIX kd 27 | USEION k READ ek WRITE ik 28 | RANGE gkd,gkdbar, sh 29 | RANGE ninf,taun 30 | } 31 | 32 | STATE { 33 | n 34 | } 35 | 36 | ASSIGNED { 37 | ik (mA/cm2) 38 | ninf 39 | gkd 40 | taun 41 | } 42 | 43 | BREAKPOINT { 44 | SOLVE states METHOD cnexp 45 | gkd = gkdbar*n 46 | ik = gkd*(v-ek) 47 | 48 | } 49 | 50 | INITIAL { 51 | rates(v) 52 | n=ninf 53 | } 54 | 55 | 56 | FUNCTION alpn(v(mV)) { 57 | alpn = exp(1.e-3*zetan*(v-vhalfn-sh)*9.648e4/(8.315*(273.16+celsius))) 58 | } 59 | 60 | FUNCTION betn(v(mV)) { 61 | betn = exp(1.e-3*zetan*gmn*(v-vhalfn-sh)*9.648e4/(8.315*(273.16+celsius))) 62 | } 63 | 64 | DERIVATIVE states { : exact when v held constant; integrates over dt step 65 | rates(v) 66 | n' = (ninf - n)/taun 67 | } 68 | 69 | PROCEDURE rates(v (mV)) { :callable from hoc 70 | LOCAL a,qt 71 | qt=q10^((celsius-24)/10) 72 | a = alpn(v) 73 | ninf = 1/(1+a) 74 | taun = betn(v)/(qt*a0n*(1+a)) 75 | if (taun None: 27 | self.cell_id = cell_id 28 | self.circuit_access = circuit_access 29 | 30 | def get_property(self, property_name: str) -> Any: 31 | """Get a property of a cell.""" 32 | if property_name in self.circuit_access.available_cell_properties: 33 | return self.circuit_access.get_cell_properties(self.cell_id, property_name) 34 | raise MissingSonataPropertyError(f"{property_name} property is not available.") 35 | 36 | get_input_resistance = partialmethod(get_property, "@dynamics:input_resistance") 37 | -------------------------------------------------------------------------------- /tests/mechanisms/kd2.mod: -------------------------------------------------------------------------------- 1 | TITLE K-D channel 2 | : M.Migliore jun 2006 3 | 4 | UNITS { 5 | (mA) = (milliamp) 6 | (mV) = (millivolt) 7 | 8 | } 9 | 10 | PARAMETER { 11 | v (mV) 12 | ek (mV) : must be explicitely def. in hoc 13 | celsius (degC) 14 | gkdbar=.0 (mho/cm2) 15 | vhalfn=-63 (mV) 16 | a0n=0.02 (/ms) 17 | zetan=6 (1) 18 | gmn=0.9 (1) 19 | nmax=2 (1) 20 | q10=1 21 | sh = 0 22 | } 23 | 24 | 25 | NEURON { 26 | SUFFIX kd2 27 | USEION k READ ek WRITE ik 28 | RANGE gkd,gkdbar, sh 29 | RANGE ninf,taun 30 | } 31 | 32 | STATE { 33 | n 34 | } 35 | 36 | ASSIGNED { 37 | ik (mA/cm2) 38 | ninf 39 | gkd 40 | taun 41 | } 42 | 43 | BREAKPOINT { 44 | SOLVE states METHOD cnexp 45 | gkd = gkdbar*n 46 | ik = gkd*(v-ek) 47 | 48 | } 49 | 50 | INITIAL { 51 | rates(v) 52 | n=ninf 53 | } 54 | 55 | 56 | FUNCTION alpn(v(mV)) { 57 | alpn = exp(1.e-3*zetan*(v-vhalfn-sh)*9.648e4/(8.315*(273.16+celsius))) 58 | } 59 | 60 | FUNCTION betn(v(mV)) { 61 | betn = exp(1.e-3*zetan*gmn*(v-vhalfn-sh)*9.648e4/(8.315*(273.16+celsius))) 62 | } 63 | 64 | DERIVATIVE states { : exact when v held constant; integrates over dt step 65 | rates(v) 66 | n' = (ninf - n)/taun 67 | } 68 | 69 | PROCEDURE rates(v (mV)) { :callable from hoc 70 | LOCAL a,qt 71 | qt=q10^((celsius-24)/10) 72 | a = alpn(v) 73 | ninf = 1/(1+a) 74 | taun = betn(v)/(qt*a0n*(1+a)) 75 | if (taun None: 27 | self.isec2sec: dict[int, NeuronSection] = {} 28 | n = cell.nSecAll 29 | 30 | for index, sec in enumerate(cell.all, start=1): 31 | v_value = sec(0.0001).v 32 | if v_value >= n: 33 | logging.debug(f"{sec.name()} v(1)={sec(1).v} n3d()={sec.n3d()}") 34 | raise ValueError("Error: failure in mk2_isec2sec()") 35 | 36 | if v_value < 0: 37 | logging.debug( 38 | f"[Warning] SerializedSections: v(0.0001) < 0. index={index} v()={v_value}" 39 | ) 40 | else: 41 | self.isec2sec[int(v_value)] = neuron.h.SectionRef(sec=sec) 42 | -------------------------------------------------------------------------------- /tests/mechanisms/kdrca1.mod: -------------------------------------------------------------------------------- 1 | TITLE K-DR channel 2 | : from Klee Ficker and Heinemann 3 | : modified to account for Dax et al. 4 | : M.Migliore 1997 5 | 6 | UNITS { 7 | (mA) = (milliamp) 8 | (mV) = (millivolt) 9 | 10 | } 11 | 12 | PARAMETER { 13 | v (mV) 14 | ek (mV) : must be explicitely def. in hoc 15 | celsius (degC) 16 | gkdrbar=.003 (mho/cm2) 17 | vhalfn=13 (mV) 18 | a0n=0.02 (/ms) 19 | zetan=-3 (1) 20 | gmn=0.7 (1) 21 | nmax=2 (1) 22 | q10=1 23 | } 24 | 25 | 26 | NEURON { 27 | SUFFIX kdr 28 | USEION k READ ek WRITE ik 29 | RANGE gkdr,gkdrbar 30 | RANGE ninf,taun 31 | } 32 | 33 | STATE { 34 | n 35 | } 36 | 37 | ASSIGNED { 38 | ik (mA/cm2) 39 | ninf 40 | gkdr 41 | taun 42 | } 43 | 44 | BREAKPOINT { 45 | SOLVE states METHOD cnexp 46 | gkdr = gkdrbar*n 47 | ik = gkdr*(v-ek) 48 | 49 | } 50 | 51 | INITIAL { 52 | rates(v) 53 | n=ninf 54 | } 55 | 56 | 57 | FUNCTION alpn(v(mV)) { 58 | alpn = exp(1.e-3*zetan*(v-vhalfn)*9.648e4/(8.315*(273.16+celsius))) 59 | } 60 | 61 | FUNCTION betn(v(mV)) { 62 | betn = exp(1.e-3*zetan*gmn*(v-vhalfn)*9.648e4/(8.315*(273.16+celsius))) 63 | } 64 | 65 | DERIVATIVE states { : exact when v held constant; integrates over dt step 66 | rates(v) 67 | n' = (ninf - n)/taun 68 | } 69 | 70 | PROCEDURE rates(v (mV)) { :callable from hoc 71 | LOCAL a,qt 72 | qt=q10^((celsius-24)/10) 73 | a = alpn(v) 74 | ninf = 1/(1+a) 75 | taun = betn(v)/(qt*a0n*(1+a)) 76 | if (taun dict[CellId, np.ndarray]: 29 | """Parse the replay spiketrains in a out.dat formatted file pointed to by 30 | path.""" 31 | spikes = bluepy.impl.spike_report.SpikeReport.load(path).get() 32 | # convert Series to DataFrame with 2 columns for `groupby` operation 33 | spike_df = spikes.to_frame().reset_index() 34 | if (spike_df["t"] < 0).any(): 35 | logger.warning('Found negative spike times in out.dat ! ' 36 | 'Clipping them to 0') 37 | spike_df["t"].clip(lower=0., inplace=True) 38 | 39 | outdat = spike_df.groupby("gid")["t"].apply(np.array) 40 | # convert outdat's index from int to CellId 41 | outdat.index = [CellId("", gid) for gid in outdat.index] 42 | return outdat.to_dict() 43 | -------------------------------------------------------------------------------- /bluecellulab/utils.py: -------------------------------------------------------------------------------- 1 | """Utility functions used within BlueCellulab.""" 2 | 3 | from __future__ import annotations 4 | import contextlib 5 | import io 6 | import json 7 | 8 | import numpy as np 9 | 10 | 11 | def run_once(func): 12 | """A decorator to ensure a function is only called once.""" 13 | 14 | def wrapper(*args, **kwargs): 15 | if not wrapper.has_run: 16 | wrapper.has_run = True 17 | return func(*args, **kwargs) 18 | 19 | wrapper.has_run = False 20 | return wrapper 21 | 22 | 23 | class CaptureOutput(list): 24 | def __enter__(self): 25 | self._stringio = io.StringIO() 26 | self._redirect_stdout = contextlib.redirect_stdout(self._stringio) 27 | self._redirect_stdout.__enter__() 28 | return self 29 | 30 | def __exit__(self, exc_type, exc_val, exc_tb): 31 | self._redirect_stdout.__exit__(exc_type, exc_val, exc_tb) 32 | self.extend(self._stringio.getvalue().splitlines()) 33 | 34 | 35 | class NumpyEncoder(json.JSONEncoder): 36 | def default(self, obj): 37 | if isinstance( 38 | obj, 39 | ( 40 | np.int_, 41 | np.intc, 42 | np.intp, 43 | np.int8, 44 | np.int16, 45 | np.int32, 46 | np.int64, 47 | np.uint8, 48 | np.uint16, 49 | np.uint32, 50 | np.uint64, 51 | ), 52 | ): 53 | return int(obj) 54 | elif isinstance(obj, (np.float_, np.float16, np.float32, np.float64)): 55 | return float(obj) 56 | elif isinstance(obj, np.ndarray): 57 | return obj.tolist() 58 | return json.JSONEncoder.default(self, obj) 59 | -------------------------------------------------------------------------------- /tests/examples/tapertest_cells/notaper_cell.hoc: -------------------------------------------------------------------------------- 1 | //test 2 | 3 | {load_file("Cell.hoc")} 4 | {load_file("TDistFunc.hoc")} 5 | begintemplate notaper_cell 6 | public init, printInfo, delete_axon, getCell, init_biophys, insertChannel 7 | public gid, CellRef, getThreshold, geom_nseg, gmechdistribute, biophys 8 | objref this, CellRef, gmechdistribute 9 | 10 | proc init() { local ind localobj strMorphName, strTmp, sf 11 | strMorphName = new String("test_cell.asc") 12 | strTmp = new String() 13 | sf = new StringFunctions() 14 | if(numarg() == 2){ 15 | sscanf($s2, "%s", strTmp.s) 16 | ind = sf.substr(strTmp.s, ".asc") 17 | if((ind>0) && (ind == (sf.len(strTmp.s)-4))){ 18 | CellRef = new Cell($1, $s2) 19 | }else{ 20 | sprint(strMorphName.s, "%s/%s", $s2, strMorphName.s) 21 | CellRef = new Cell($1, strMorphName.s) 22 | } 23 | } 24 | gmechdistribute = new TDistFunc() 25 | CellRef.setCCell(this) 26 | gid = CellRef.gid 27 | geom_nseg() //This function is called to have count of actual axon sections 28 | CellRef.delete_axon() 29 | insertChannel() 30 | init_biophys() 31 | biophys() 32 | } 33 | 34 | func getThreshold() { return 0.184062 } 35 | 36 | proc geom_nseg() { 37 | CellRef.geom_nseg_fixed(40) 38 | CellRef.geom_nsec() //To count all sections 39 | } 40 | 41 | obfunc getCell(){ 42 | return CellRef 43 | } 44 | 45 | //proc delete_axon(){ 46 | // CellRef.delete_axon() 47 | //} 48 | 49 | proc init_biophys() { 50 | CellRef.soma[0] distance() 51 | } 52 | 53 | proc insertChannel() { 54 | 55 | } 56 | 57 | proc biophys() { 58 | } 59 | 60 | public getHypAmp 61 | 62 | func getHypAmp(){return (-0.070557) } 63 | 64 | endtemplate notaper_cell 65 | -------------------------------------------------------------------------------- /examples/4-epsp/hippocampus_mechanisms/kdrbca1.mod: -------------------------------------------------------------------------------- 1 | TITLE K-DR channel 2 | : from Klee Ficker and Heinemann 3 | : modified to account for Dax et al. 4 | : M.Migliore 1997 5 | 6 | UNITS { 7 | (mA) = (milliamp) 8 | (mV) = (millivolt) 9 | 10 | } 11 | 12 | PARAMETER { 13 | v (mV) 14 | ek (mV) : must be explicitely def. in hoc 15 | celsius (degC) 16 | gkdrbar=.003 (mho/cm2) 17 | vhalfn=13 (mV) 18 | a0n=0.02 (/ms) 19 | zetan=-3 (1) 20 | gmn=0.7 (1) 21 | nmax=2 (1) 22 | q10=1 23 | sh = 0 24 | } 25 | 26 | 27 | NEURON { 28 | SUFFIX kdrb 29 | USEION k READ ek WRITE ik 30 | RANGE gkdr,gkdrbar, sh 31 | GLOBAL ninf,taun 32 | } 33 | 34 | STATE { 35 | n 36 | } 37 | 38 | ASSIGNED { 39 | ik (mA/cm2) 40 | ninf 41 | gkdr 42 | taun 43 | } 44 | 45 | BREAKPOINT { 46 | SOLVE states METHOD cnexp 47 | gkdr = gkdrbar*n 48 | ik = gkdr*(v-ek) 49 | 50 | } 51 | 52 | INITIAL { 53 | rates(v) 54 | n=ninf 55 | } 56 | 57 | 58 | FUNCTION alpn(v(mV)) { 59 | alpn = exp(1.e-3*zetan*(v-vhalfn-sh)*9.648e4/(8.315*(273.16+celsius))) 60 | } 61 | 62 | FUNCTION betn(v(mV)) { 63 | betn = exp(1.e-3*zetan*gmn*(v-vhalfn-sh)*9.648e4/(8.315*(273.16+celsius))) 64 | } 65 | 66 | DERIVATIVE states { : exact when v held constant; integrates over dt step 67 | rates(v) 68 | n' = (ninf - n)/taun 69 | } 70 | 71 | PROCEDURE rates(v (mV)) { :callable from hoc 72 | LOCAL a,qt 73 | qt=q10^((celsius-24)/10) 74 | a = alpn(v) 75 | ninf = 1/(1+a) 76 | taun = betn(v)/(qt*a0n*(1+a)) 77 | if (taun