### Setup development environment Source: https://github.com/bluebrain/neurodamus/blob/main/CONTRIBUTING.md Initialize a virtual environment and install project dependencies. ```sh virtualenv venv . venv/bin/activate # Install neurodamus in development mode pip install -e . # Install test requirements pip install -r tests/requirements.txt ``` -------------------------------- ### Install Neurodamus Source: https://github.com/bluebrain/neurodamus/blob/main/README.rst Standard installation procedure using git and pip. ```sh git clone https://github.com/BlueBrain/neurodamus.git cd neurodamus pip install . ``` -------------------------------- ### Install Neurodamus-py for Development Source: https://github.com/bluebrain/neurodamus/blob/main/docs/development.md Commands to clone the repository, create a virtual environment, and install the package in editable mode. ```bash # ensure a recent python is loaded. Consider loading together with dependencies from BB5 # module load unstable git py-h5py py-libsonata # will also bring Python and mpi # Get your copy of neurodamus: git clone git@bbpgitlab.epfl.ch:hpc/sim/neurodamus-py.git # Create a virtualenv and install in dev-mode (no copies): python -m venv venv . venv/bin/activate pip install -e neurodamus-py # Test it neurodamus Usage: neurodamus [options] neurodamus --help ``` -------------------------------- ### Neuron Tutorial Synapses with Neurodamus Source: https://github.com/bluebrain/neurodamus/blob/main/docs/examples.md This example demonstrates setting up synaptic connections in a Neuron model using Neurodamus. It covers basic section properties, applying mechanisms, creating stimuli, and connecting NetStim to ExpSyn. ```python def test_tut2(): c = Cell(0, MORPHO) print("The morphology {} basal, {} apical, {} axonal sections.".format( len(c.dendrites), len(c.apical_dendrites), len(c.axons))) for sec in c.all: sec.nseg = 1 + 2 * int(sec.L / 40) sec.cm = 1 sec.Ra = 100 hh = mechanisms.HH(gkbar=.0, gnabar=.0, el=-70) hh.apply(c.all) hh.gkbar = 0.01 hh.gnabar = 0.2 hh.apply(c.soma) hh.gnabar = 0.25 hh.apply(c.axons) clamp = CurrentSource.Constant(0.5, 200, 10).attach_to(c.soma) Neuron.run_sim(300, c.soma, v_init=-70).plot() # Part 2 clamp.detach() stim = synapses.NetStim(5, 5, 20, 0) for sect in c.dendrites: sr = synapses.ExpSyn(sect(0.5)) stim.connect_to(sr, weight=0.001) Neuron.run_sim(80, c.soma, v_init=-70).plot() ``` -------------------------------- ### Run Neurodamus simulation using Node class Source: https://github.com/bluebrain/neurodamus/blob/main/docs/examples.md Demonstrates the manual initialization sequence for a Neurodamus simulation. Requires a valid recipe file and appropriate logging setup. ```python def test_node_run(trace=False): """Node is more of a low-level class, where all initialization steps are manual """ setup_logging(DEFAULT_LOG_LEVEL) if trace: # Some additional logging is available at special level 5 print("TRACE mode is ON") logging.root.setLevel(TRACE_LOG_LEVEL) node = Node(RECIPE_FILE) node.load_targets() node.compute_load_balance() node.create_cells() node.execute_neuron_configures() logging.info("Create connections") node.create_synapses() logging.info("Enable Stimulus") node.enable_stimulus() logging.info("Enable Modifications") node.enable_modifications() if trace: logging.info("Dumping config") Nd.stdinit() node.dump_circuit_config("") logging.info("Enable Reports") node.enable_reports() logging.info("Run") node.run_all() logging.info("Simulation finished.") node.cleanup() ``` -------------------------------- ### Define legacy BlueConfig simulation parameters Source: https://github.com/bluebrain/neurodamus/blob/main/docs/sonata-simulation.md Example of a legacy BlueConfig simulation configuration block for comparison with SONATA. ```console Run Default { Duration 100 Dt 0.025 BaseSeed 264118 Simulator NEURON # BlueConfig had circuit defs inline TargetFile mooc-circuit/user.target CircuitTarget hippocampus_neurons:central OutputRoot output RNGMode Random123 # deprecated RunMode RR # deprecated. use CLI } ``` -------------------------------- ### Developing a Custom Neurodamus Source: https://github.com/bluebrain/neurodamus/blob/main/docs/index.md Guide on how to develop custom Neurodamus functionalities, including installation and testing. ```APIDOC ## Developing a Custom Neurodamus ### Description This guide covers the process of developing custom Neurodamus features, from package requirements to installation and testing. ### Endpoint /development.md #### Sections - Neurodamus-py package - Requirements - Install Neurodamus for development - Editing HOC Files - Running Tests - Prepared Config Files - The quick path way - Installing With Spack ``` -------------------------------- ### Get or Create Connection Source: https://github.com/bluebrain/neurodamus/blob/main/docs/api/subpackages/top.md Retrieves a connection by pre- and post-synaptic GIDs, creating it if it does not exist. ```python get_or_create_connection(sgid, tgid, **kwargs) ``` -------------------------------- ### Run Neurodamus Docker Container Source: https://github.com/bluebrain/neurodamus/blob/main/docker/README.md Starts an interactive Neurodamus container, mounting a local directory for mods and circuit data. ```bash docker run --rm -it -v :/mnt/mydata bluebrain/neurodamus ``` -------------------------------- ### Launch Neurodamus-py with MPI Source: https://github.com/bluebrain/neurodamus/blob/main/docs/examples.md Use 'srun' or 'mpiexec' to launch neurodamus-py for parallel execution. This example shows launching with 'srun' and 'special'. ```sh srun special -mpi -python $NEURODAMUS_PYTHON/init.py ``` -------------------------------- ### Define Sonata simulation parameters Source: https://github.com/bluebrain/neurodamus/blob/main/docs/sonata-simulation.md Example of a JSON configuration block for a SONATA simulation, including run parameters, network definition, and output settings. ```json "run": { "tstop": 100.0, "dt": 0.025, "random_seed": 264118, }, "target_simulator": "NEURON", "network": "circuit_config.json", "node_sets_file": "node_sets.json", "node_set": "most_central_100_SP_PC", "output": { "output_dir": "output_sonata", "spikes_file": "out.h5", "spikes_sort_order": "by_time" }, ``` -------------------------------- ### Running Neurodamus with MPI Source: https://github.com/bluebrain/neurodamus/blob/main/docs/overview.md Launch neurodamus using 'srun' or 'mpiexec' for parallel execution. This example shows how to set environment variables for the Python path and HOC library, then execute the simulation. ```sh export NEURODAMUS_PYTHON=$(python -c "import neurodamus; from pathlib import Path; print(Path(neurodamus.__file__).parent / 'data')") export HOC_LIBRARY_PATH= srun -mpi -python $NEURODAMUS_PYTHON/init.py ``` -------------------------------- ### Build Single Compartment Neuron Model with Neurodamus Source: https://github.com/bluebrain/neurodamus/blob/main/docs/examples.md This example demonstrates building a basic single compartment neuron model, adding membrane mechanisms, creating stimuli, and running simulations using Neurodamus's high-level API for Neuron. It includes options for quick execution or detailed simulation with active channels. ```python #!/usr/bin/env python """ Neuron tutorial I using the new HighLevel API. Original tutorial at https://github.com/BlueBrain/SimulationTutorials/blob/master/CNS2017/NEURON/NEURON_intro.ipynb """ from neurodamus.core import Cell from neurodamus.core import CurrentSource from neurodamus.core import Neuron from neurodamus.core import mechanisms # Change v_init globally # Alternatively v_init can be configured per simulation in run_sim(**kw) Neuron.Simulation.v_init = -70 def test_tut1(quick=True): c = Cell.Builder.add_soma(60).create() hh = Cell.Mechanisms.HH(gkbar=0.0, gnabar=0.0, el=-70) hh.apply(c.soma) # clamp = StimuliSource.pulse(0.1, 50, delay=10).attach_to(c.soma) # eqv. to Constant() CurrentSource.Constant(0.1, 50, 10).attach_to(c.soma) Neuron.run_sim(100, c.soma).plot() if quick: return # Execution with Active channels hh.gkbar = 0.01 hh.gnabar = 0.2 hh.apply(c.soma) sim = Neuron.run_sim(100, c.soma) # sim.run_continue(100) sim.plot() # Extending the model with dendrites c = (c.builder .add_dendrite("dend", 400, 9, diam=2, Ra=100) .add_dendrite("dend2", 400, 9, diam=2, Ra=100) .create()) mechanisms.HH(el=-70, gl=5e-4, gkbar=.0, gnabar=.0).apply(c.dendrites) Neuron.run_sim(50, c.dendrites[0]).plot() Cell.show_topology() Neuron.h.psection(sec=c.dendrites[0]) if __name__ == "__main__": test_tut1(False) from six.moves import input input("Press enter to quit") ``` -------------------------------- ### Configure Development Environment with Modules and Virtualenv Source: https://github.com/bluebrain/neurodamus/blob/main/docs/development.md Sets up the environment by loading modules, creating a virtual environment for testing, and configuring the PYTHONPATH. ```bash module load unstable py-neurodamus neurodamus-neocortex # Set up a virtualenv for other packages, e.g. pytest # Remember that any installed package in this venv takes precedence over the loaded module python -m venv venv . venv/bin/activate pip install pytest pytest-forked # Make dev neurodamus-py take precedence over everything export PYTHONPATH=$PWD/neurodamus-py:$PYTHONPATH # You should be good to go cd neurodamus-py pytest -s -k scientific/test_projections ``` -------------------------------- ### Get METype Cell Threshold Source: https://github.com/bluebrain/neurodamus/blob/main/docs/api/subpackages/top.md Retrieves the threshold value for an METype or PointCell. ```python METype.getThreshold() ``` ```python PointCell.getThreshold() ``` -------------------------------- ### GET /connection Source: https://github.com/bluebrain/neurodamus/blob/main/docs/api/subpackages/top.md Retrieves a connection object based on pre and post gids. ```APIDOC ## GET /connection ### Description Retrieves a connection from the pre and post gids. ### Parameters #### Query Parameters - **sgid** (int) - Required - The pre-gid of the cell - **tgid** (int) - Required - The post-gid of the cell ### Response #### Success Response (200) - **connection** (object) - A connection object if it exists, otherwise null ``` -------------------------------- ### Prepare Model: Full Simulation with --keep-build Source: https://github.com/bluebrain/neurodamus/wiki/Using-CoreNeuron-in-Practice Run a normal simulation while retaining intermediate files for later direct CoreNEURON execution. This option instantiates the model, runs the simulation, and preserves the 'coreneuron_input' directory and configuration files. ```bash srun special -mpi -python $NEURODAMUS_PYTHON/init.py --configFile=simulation_config.json --keep-build ``` -------------------------------- ### Get All Spikes Map Source: https://github.com/bluebrain/neurodamus/blob/main/docs/api/subpackages/top.md Returns the GroupedMultiMap containing all the spike data managed by the SpikeManager. ```python SpikeManager.get_map() ``` -------------------------------- ### Get Static METype Version Source: https://github.com/bluebrain/neurodamus/blob/main/docs/api/subpackages/top.md Retrieves the static version information for the METype class. ```python METype.getVersion() ``` -------------------------------- ### Execute Simulation with Model Building Steps Source: https://github.com/bluebrain/neurodamus/wiki/Using-CoreNeuron-in-Practice Use the --modelbuilding-steps command line option to split the model building phase for large networks. This option is only compatible with CoreNEURON. ```bash srun dplace special -mpi -python $NEURODAMUS_PYTHON/init.py --configFile=simulation_config.json --modelbuilding-steps=2 ``` -------------------------------- ### Memory Load Balance Tutorial Source: https://github.com/bluebrain/neurodamus/blob/main/docs/index.md A tutorial on memory load balancing within Neurodamus, covering simulation and rebalancing. ```APIDOC ## Memory Load Balance Tutorial ### Description This tutorial explains memory load balancing in Neurodamus, including introduction, dry run, model instantiation, rebalance, and simulation. ### Endpoint /memory_load_balance.md #### Sections - Introduction - Dry Run - Model Instantiation - Rebalance - Simulation ``` -------------------------------- ### Get METype Cell Hyperpolarization Amplitude Source: https://github.com/bluebrain/neurodamus/blob/main/docs/api/subpackages/top.md Retrieves the hyperpolarization amplitude (HypAmp) for an METype or PointCell. ```python METype.getHypAmp() ``` ```python PointCell.getHypAmp() ``` -------------------------------- ### neurodamus.utils.logging.setup_logging Source: https://github.com/bluebrain/neurodamus/blob/main/docs/api/subpackages/utils.md Configures the logging system for the Neurodamus project, supporting stdout and file output with MPI rank identification. ```APIDOC ## setup_logging(loglevel, logfile=None, rank=None) ### Description Setup neurodamus logging. Features tabs and colors output to stdout and pydamus.log. ### Parameters #### Query Parameters - **loglevel** (int) - Required - Minimum loglevel for emitting messages - **logfile** (str) - Optional - The destination for log messages besides stdout - **rank** (int) - Optional - A tag so warnings/errors are correctly identified in case of MPI ``` -------------------------------- ### GET /connections Source: https://github.com/bluebrain/neurodamus/blob/main/docs/api/subpackages/top.md Retrieves connections based on pre and post synaptic GIDs and population IDs. ```APIDOC ## GET /connections ### Description Retrieves all connections that match post and pre gids eventually in a subset of the populations. ### Method GET ### Endpoint /connections ### Parameters #### Query Parameters - **post_gids** (list) - Required - The target gids of the connections to search (None = All) - **pre_gids** (list) - Optional - The pre-gids to search. Default: all - **population_ids** (int/tuple) - Optional - A int/tuple of populations ids. Default: all ``` -------------------------------- ### Prepare Model: Instantiation Only with --simulate-model=OFF Source: https://github.com/bluebrain/neurodamus/wiki/Using-CoreNeuron-in-Practice Instantiate the model without running CoreNEURON, generating necessary input files. This option is useful for preparing the environment for direct CoreNEURON execution without performing the simulation itself. ```bash srun special -mpi -python $NEURODAMUS_PYTHON/init.py --configFile=simulation_config.json --simulate-model=OFF ``` -------------------------------- ### SonataReader Get Counts Source: https://github.com/bluebrain/neurodamus/blob/main/docs/api/subpackages/io.md Counts synapses for the given target neuron IDs. Returns a dictionary. ```python get_counts(tgids) ``` -------------------------------- ### Run Simulations with Neurodamus-py Source: https://github.com/bluebrain/neurodamus/blob/main/docs/development.md Steps to load the required Neuron model, set the PYTHONPATH, and execute a simulation. ```bash # now, yeah, load a compiled model for Neuron module load neurodamus-neocortex # Make our neurodamus-py take precedence (see note below) export PYTHONPATH=$PWD/neurodamus-py:$PYTHONPATH # find the usecase3 simulation in tests cd neurodamus-py/tests/simulations/usecase3 # Run it! neurodamus simulation_sonata.json # You should get # ::INIT:: Special available. Replacing binary... # numprocs=1 # NEURON -- VERSION 9.0.dev-1349-g67a672a2c+ HEAD (67a672a2c+) 2023-05-04 # ... # In order to run on 4 MPI ranks: srun -n4 [--account=proj16] neurodamus simulation_sonata.json ``` -------------------------------- ### Synaptic Release Log Output Source: https://github.com/bluebrain/neurodamus/wiki/Make-a-connection-output-additional-information-following-an-Action-Potential-(AP) Example of the log message generated when a synapse successfully releases. ```text [Syn 1633] Release! t = 99.9902, vals: 1.05995 0.939071 1.12872 0.939071 ``` -------------------------------- ### Initialize Spack Environment Source: https://github.com/bluebrain/neurodamus/blob/main/docs/development.md Commands to load Spack and create a new environment for Neurodamus. ```default module load unstable spack # and follow the instructions provided to get an editable version. ``` ```default spack env create neurodamus spack env activate -p neurodamus spack add neurodamus-neocortex ``` -------------------------------- ### Synaptic Failure Log Output Source: https://github.com/bluebrain/neurodamus/wiki/Make-a-connection-output-additional-information-following-an-Action-Potential-(AP) Example of the log message generated when a synapse fails to release. ```text [Syn 2868] Failure! t = 99.9752: urand = 0.528058 ``` -------------------------------- ### SynapseReader Get Synapse Parameters Source: https://github.com/bluebrain/neurodamus/blob/main/docs/api/subpackages/io.md Obtains the synapse parameters record for a given GID from the synapse reader. ```python get_synapse_parameters(gid) ``` -------------------------------- ### Initialize and Update Progress Bar Source: https://github.com/bluebrain/neurodamus/blob/main/docs/api/subpackages/utils.md Demonstrates basic usage of the ProgressBar class with default settings. ```pycon >>> from progressbar import ProgressBar >>> p = ProgressBar() >>> print p [>............] 0% >>> p + 1 >>> print p [=>...........] 10% >>> p + 9 >>> print p [============>] 0% ``` -------------------------------- ### Clone BlueConfigs Repository Source: https://github.com/bluebrain/neurodamus/blob/main/docs/development.md Retrieve the repository containing input files for simulations. ```default git clone git@bbpgitlab.epfl.ch:hpc/sim/blueconfigs.git ``` -------------------------------- ### SonataReader Get Property Source: https://github.com/bluebrain/neurodamus/blob/main/docs/api/subpackages/io.md Retrieves a pre-loaded property for a given GID and field name from SONATA data. ```python get_property(gid, field_name) ``` -------------------------------- ### View Neurodamus Help and Options Source: https://github.com/bluebrain/neurodamus/wiki/Using-CoreNeuron-in-Practice Display available command line options for Neurodamus, including save and restore functionality. ```bash >neurodamus --help neurodamus Usage: neurodamus [options] neurodamus --help Options: ... --save= Path to create a save point to enable resume. --save-time=